3 from .common
import InfoExtractor
15 class NovaEmbedIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://media\.cms\.nova\.cz/embed/(?P<id>[^/?#&]+)'
18 'url': 'https://media.cms.nova.cz/embed/8o0n0r?autoplay=1',
22 'thumbnail': r
're:^https?://.*\.jpg',
26 'skip_download': True,
27 'ignore_no_formats_error': True,
29 'expected_warnings': ['DRM protected', 'Requested format is not available'],
31 'url': 'https://media.cms.nova.cz/embed/KybpWYvcgOa',
35 'title': 'Borhyová oslavila 60? Soutěžící z pořadu odboural moderátora Ondřeje Sokola',
36 'thumbnail': r
're:^https?://.*\.jpg',
39 'params': {'skip_download': 'm3u8'}
,
42 def _real_extract(self
, url
):
43 video_id
= self
._match
_id
(url
)
45 webpage
= self
._download
_webpage
(url
, video_id
)
51 def process_format_list(format_list
, format_id
=""):
52 nonlocal formats
, has_drm
53 if not isinstance(format_list
, list):
54 format_list
= [format_list
]
55 for format_dict
in format_list
:
56 if not isinstance(format_dict
, dict):
58 if (not self
.get_param('allow_unplayable_formats')
59 and traverse_obj(format_dict
, ('drm', 'keySystem'))):
62 format_url
= url_or_none(format_dict
.get('src'))
63 format_type
= format_dict
.get('type')
64 ext
= determine_ext(format_url
)
65 if (format_type
== 'application/x-mpegURL'
66 or format_id
== 'HLS' or ext
== 'm3u8'):
67 formats
.extend(self
._extract
_m
3u8_formats
(
68 format_url
, video_id
, 'mp4',
69 entry_protocol
='m3u8_native', m3u8_id
='hls',
71 elif (format_type
== 'application/dash+xml'
72 or format_id
== 'DASH' or ext
== 'mpd'):
73 formats
.extend(self
._extract
_mpd
_formats
(
74 format_url
, video_id
, mpd_id
='dash', fatal
=False))
80 player
= self
._search
_json
(
81 r
'player:', webpage
, 'player', video_id
, fatal
=False, end_pattern
=r
';\s*</script>')
83 for src
in traverse_obj(player
, ('lib', 'source', 'sources', ...)):
84 process_format_list(src
)
85 duration
= traverse_obj(player
, ('sourceInfo', 'duration', {int_or_none}
))
86 if not formats
and not has_drm
:
87 # older code path, in use before August 2023
88 player
= self
._parse
_json
(
90 (r
'(?:(?:replacePlaceholders|processAdTagModifier).*?:\s*)?(?:replacePlaceholders|processAdTagModifier)\s*\(\s*(?P<json>{.*?})\s*\)(?:\s*\))?\s*,',
91 r
'Player\.init\s*\([^,]+,(?P<cndn>\s*\w+\s*\?)?\s*(?P<json>{(?(cndn).+?|.+)})\s*(?(cndn):|,\s*{.+?}\s*\)\s*;)'),
92 webpage
, 'player', group
='json'), video_id
)
94 for format_id
, format_list
in player
['tracks'].items():
95 process_format_list(format_list
, format_id
)
96 duration
= int_or_none(player
.get('duration'))
98 if not formats
and has_drm
:
99 self
.report_drm(video_id
)
101 title
= self
._og
_search
_title
(
102 webpage
, default
=None) or self
._search
_regex
(
103 (r
'<value>(?P<title>[^<]+)',
104 r
'videoTitle\s*:\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1'), webpage,
105 'title
', group='value
')
106 thumbnail = self._og_search_thumbnail(
107 webpage, default=None) or self._search_regex(
108 r'poster\s
*:\s
*(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
109 'thumbnail', fatal=False, group='value')
110 duration = int_or_none(self._search_regex(
111 r'videoDuration\s*:\s*(\d+)', webpage, 'duration',
117 'thumbnail': thumbnail,
118 'duration': duration,
123 class NovaIE(InfoExtractor):
124 IE_DESC = 'TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz'
125 _VALID_URL = r'https?://(?:[^.]+\.)?(?P<site>tv(?:noviny)?|tn|novaplus|vymena|fanda|krasna|doma|prask)\.nova\.cz/(?:[^/]+/)+(?P<id>[^/]+?)(?:\.html|/|$)'
127 'url': 'http://tn.nova.cz/clanek/tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci.html#player_13260',
128 'md5': '249baab7d0104e186e78b0899c7d5f28',
131 'display_id': 'tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci',
133 'title': 'Podzemní nemocnice v pražské Krči',
134 'description': 'md5:f0a42dd239c26f61c28f19e62d20ef53',
135 'thumbnail': r're:^https?://.*\.(?:jpg)',
138 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
142 'title': 'Zaklínač 3: Divoký hon',
143 'description': 're:.*Pokud se stejně jako my nemůžete.*',
144 'thumbnail': r're:https?://.*\.jpg(\?.*)?',
145 'upload_date': '20150521',
149 'skip_download': True,
153 # media.cms.nova.cz embed
154 'url': 'https://novaplus.nova.cz/porad/ulice/epizoda/18760-2180-dil',
158 'title': '2180. díl',
159 'thumbnail': r're:^https?://.*\.jpg',
163 'skip_download': True,
165 'add_ie': [NovaEmbedIE.ie_key()],
166 'skip': 'CHYBA 404: STRÁNKA NENALEZENA',
168 'url': 'http://sport.tn.nova.cz/clanek/sport/hokej/nhl/zivot-jde-dal-hodnotil-po-vyrazeni-z-playoff-jiri-sekac.html',
169 'only_matching': True,
171 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
172 'only_matching': True,
174 'url': 'http://doma.nova.cz/clanek/zdravi/prijdte-se-zapsat-do-registru-kostni-drene-jiz-ve-stredu-3-cervna.html',
175 'only_matching': True,
177 'url': 'http://prask.nova.cz/clanek/novinky/co-si-na-sobe-nase-hvezdy-nechaly-pojistit.html',
178 'only_matching': True,
180 'url': 'http://tv.nova.cz/clanek/novinky/zivot-je-zivot-bondovsky-trailer.html',
181 'only_matching': True,
184 def _real_extract(self, url):
185 mobj = self._match_valid_url(url)
186 display_id = mobj.group('id')
187 site = mobj.group('site')
189 webpage = self._download_webpage(url, display_id)
191 description = clean_html(self._og_search_description(webpage, default=None))
192 if site == 'novaplus':
193 upload_date = unified_strdate(self._search_regex(
194 r'(\d{1,2}-\d{1,2}-\d{4})$', display_id, 'upload date', default=None))
195 elif site == 'fanda':
196 upload_date = unified_strdate(self._search_regex(
197 r'<span class="date_time
">(\d{1,2}\.\d{1,2}\.\d{4})', webpage, 'upload date', default=None))
202 embed_id = self._search_regex(
203 r'<iframe[^>]+\bsrc=["\'](?
:https?
:)?
//media\
.cms\
.nova\
.cz
/embed
/([^
/?
#&]+)',
204 webpage
, 'embed url', default
=None)
207 '_type': 'url_transparent',
208 'url': 'https://media.cms.nova.cz/embed/%s' % embed_id
,
209 'ie_key': NovaEmbedIE
.ie_key(),
211 'description': description
,
212 'upload_date': upload_date
215 video_id
= self
._search
_regex
(
216 [r
"(?:media|video_id)\s*:\s*'(\d+)'",
218 r
'id="article_video_(\d+)"',
219 r
'id="player_(\d+)"'],
222 config_url
= self
._search
_regex
(
223 r
'src="(https?://(?:tn|api)\.nova\.cz/bin/player/videojs/config\.php\?[^"]+)"',
224 webpage
, 'config url', default
=None)
228 player
= self
._parse
_json
(
230 r
'(?s)Player\s*\(.+?\s*,\s*({.+?\bmedia\b["\']?\s*:\s*["\']?\d+.+?})\s*\)', webpage
,
231 'player', default
='{}'),
232 video_id
, transform_source
=js_to_json
, fatal
=False)
234 config_url
= url_or_none(player
.get('configUrl'))
235 params
= player
.get('configParams')
236 if isinstance(params
, dict):
237 config_params
= params
240 DEFAULT_SITE_ID
= '23000'
242 'tvnoviny': DEFAULT_SITE_ID
,
243 'novaplus': DEFAULT_SITE_ID
,
244 'vymena': DEFAULT_SITE_ID
,
245 'krasna': DEFAULT_SITE_ID
,
251 site_id
= self
._search
_regex
(
252 r
'site=(\d+)', webpage
, 'site id', default
=None) or SITES
.get(
253 site
, DEFAULT_SITE_ID
)
255 config_url
= 'https://api.nova.cz/bin/player/videojs/config.php'
263 config
= self
._download
_json
(
264 config_url
, display_id
,
265 'Downloading config JSON', query
=config_params
,
266 transform_source
=lambda s
: s
[s
.index('{'):s.rindex('}') + 1])
268 mediafile
= config
['mediafile']
269 video_url
= mediafile
['src']
271 m
= re
.search(r
'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+?))/&*(?P<playpath>.+)$', video_url
)
274 'url': m
.group('url'),
275 'app': m
.group('app'),
276 'play_path': m
.group('playpath'),
277 'player_path': 'http://tvnoviny.nova.cz/static/shared/app/videojs/video-js.swf',
285 title
= mediafile
.get('meta', {}).get('title') or self
._og
_search
_title
(webpage
)
286 thumbnail
= config
.get('poster')
290 'display_id': display_id
,
292 'description': description
,
293 'upload_date': upload_date
,
294 'thumbnail': thumbnail
,