1 from .common
import InfoExtractor
10 class RuvIE(InfoExtractor
):
11 _VALID_URL
= r
'https?://(?:www\.)?ruv\.is/(?:sarpurinn/[^/]+|node)/(?P<id>[^/]+(?:/\d+)?)'
14 'url': 'http://ruv.is/sarpurinn/ruv-aukaras/fh-valur/20170516',
15 'md5': '66347652f4e13e71936817102acc1724',
18 'display_id': 'fh-valur/20170516',
20 'title': 'FH - Valur',
21 'description': 'Bein útsending frá 3. leik FH og Vals í úrslitum Olísdeildar karla í handbolta.',
22 'timestamp': 1494963600,
23 'upload_date': '20170516',
27 'url': 'http://ruv.is/sarpurinn/ras-2/morgunutvarpid/20170619',
28 'md5': '395ea250c8a13e5fdb39d4670ef85378',
31 'display_id': 'morgunutvarpid/20170619',
33 'title': 'Morgunútvarpið',
34 'description': 'md5:a4cf1202c0a1645ca096b06525915418',
35 'timestamp': 1497855000,
36 'upload_date': '20170619',
39 'url': 'http://ruv.is/sarpurinn/ruv/frettir/20170614',
40 'only_matching': True,
42 'url': 'http://www.ruv.is/node/1151854',
43 'only_matching': True,
45 'url': 'http://ruv.is/sarpurinn/klippa/secret-soltice-hefst-a-morgun',
46 'only_matching': True,
48 'url': 'http://ruv.is/sarpurinn/ras-1/morgunvaktin/20170619',
49 'only_matching': True,
52 def _real_extract(self
, url
):
53 display_id
= self
._match
_id
(url
)
55 webpage
= self
._download
_webpage
(url
, display_id
)
57 title
= self
._og
_search
_title
(webpage
)
59 FIELD_RE
= r
'video\.%s\s*=\s*(["\'])(?P
<url
>(?
:(?
!\
1).)+)\
1'
61 media_url = self._html_search_regex(
62 FIELD_RE % 'src
', webpage, 'video URL
', group='url
')
64 video_id = self._search_regex(
65 r'<link
\b[^
>]+\bhref
=["\']https?://www\.ruv\.is/node/(\d+)',
66 webpage, 'video id', default=display_id)
68 ext = determine_ext(media_url)
71 formats = self._extract_m3u8_formats(
72 media_url, video_id, 'mp4', entry_protocol='m3u8_native',
85 description = self._og_search_description(webpage, default=None)
86 thumbnail = self._og_search_thumbnail(
87 webpage, default=None) or self._search_regex(
88 FIELD_RE % 'poster', webpage, 'thumbnail', fatal=False)
89 timestamp = unified_timestamp(self._html_search_meta(
90 'article:published_time', webpage, 'timestamp', fatal=False))
94 'display_id': display_id,
96 'description': description,
97 'thumbnail': thumbnail,
98 'timestamp': timestamp,
103 class RuvSpilaIE(InfoExtractor):
104 IE_NAME = 'ruv.is:spila'
105 _VALID_URL = r'https?://(?:www\.)?ruv\.is/(?:(?:sjon|ut)varp|(?:krakka|ung)ruv)/spila/.+/(?P<series_id>[0-9]+)/(?P<id>[a-z0-9]+)'
107 'url': 'https://www.ruv.is/sjonvarp/spila/ithrottir/30657/9jcnd4',
111 'title': '01.02.2022',
112 'chapters': 'count:4',
113 'timestamp': 1643743500,
114 'upload_date': '20220201',
115 'thumbnail': 'https://d38kdhuogyllre.cloudfront.net/fit-in/1960x/filters:quality(65)/hd_posters/94boog-iti3jg.jpg',
116 'description': 'Íþróttafréttir.',
120 'url': 'https://www.ruv.is/utvarp/spila/i-ljosi-sogunnar/23795/7hqkre',
124 'thumbnail': 'https://d38kdhuogyllre.cloudfront.net/fit-in/1960x/filters:quality(65)/hd_posters/7hqkre-7uepao.jpg',
125 'description': 'md5:8d7046549daff35e9a3190dc9901a120',
127 'upload_date': '20220204',
128 'timestamp': 1643965500,
129 'title': 'Nellie Bly II',
133 'url': 'https://www.ruv.is/ungruv/spila/ungruv/28046/8beuph',
134 'only_matching': True,
136 'url': 'https://www.ruv.is/krakkaruv/spila/krakkafrettir/30712/9jbgb0',
137 'only_matching': True,
140 def _real_extract(self, url):
141 display_id, series_id = self._match_valid_url(url).group('id', 'series_id')
142 program = self._download_json(
143 'https://www.ruv.is/gql/', display_id, query={'query': '''{
145 title image description short_description
146 episodes(id: {value: "%s"}) {
147 rating title duration file image firstrun description
156 }''' % (series_id, display_id)})['data']['Program'] # noqa: UP031
157 episode = program['episodes'][0]
160 for trk in episode.get('subtitles'):
161 if trk.get('name') and trk.get('value'):
162 subs.setdefault(trk['name'], []).append({'url': trk['value'], 'ext': 'vtt'})
164 media_url = episode['file']
165 if determine_ext(media_url) == 'm3u8':
166 formats = self._extract_m3u8_formats(media_url, display_id)
168 formats = [{'url': media_url}]
171 {'start_time': parse_duration(c.get('time')), 'title': c.get('text')}
172 for c in episode.get('clips') or []]
176 'title': traverse_obj(program, ('episodes', 0, 'title'), 'title'),
177 'description': traverse_obj(
178 program, ('episodes', 0, 'description'), 'description', 'short_description',
179 expected_type=lambda x: x or None),
181 'thumbnail': episode.get('image', '').replace('$$IMAGESIZE$$', '1960') or None,
182 'timestamp': unified_timestamp(episode.get('firstrun')),
184 'age_limit': episode.get('rating'),