aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/ruv.py
blob: 518fb502702eba02d753584d595ac7d7b74e6a84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor


class RuvIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ruv\.is/sarpurinn/ruv/\w+/(?P<id>[0-9]+)'
    _TEST = {
        'url': 'http://ruv.is/sarpurinn/ruv/frettir/20170614',
        'md5': 'a07ea1ebaba64082d90323b1c96f264b',
        'info_dict': {
            'id': '20170614',
            'ext': 'mp4',
            'title': 'Fréttir',
        }
    }

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        title = self._og_search_title(webpage)
        video_url = self._html_search_regex(r'video\.src\s*=\s*["\'](.+?)["\']', webpage, 'video URL')

        return {
            'id': video_id,
            'title': title,
            'url': video_url,
            'ext': 'mp4'
        }