3 from .common
import InfoExtractor
15 class NovaEmbedIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://media(?:tn)?\.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'},
41 'url': 'https://mediatn.cms.nova.cz/embed/EU5ELEsmOHt?autoplay=1',
45 'title': 'Haptické křeslo, bionická ruka nebo roboti. Reportérka se podívala na Týden inovací',
46 'thumbnail': r
're:^https?://.*\.jpg',
49 'params': {'skip_download': 'm3u8'},
52 def _real_extract(self
, url
):
53 video_id
= self
._match
_id
(url
)
55 webpage
= self
._download
_webpage
(url
, video_id
)
61 def process_format_list(format_list
, format_id
=''):
62 nonlocal formats
, has_drm
63 if not isinstance(format_list
, list):
64 format_list
= [format_list
]
65 for format_dict
in format_list
:
66 if not isinstance(format_dict
, dict):
68 if (not self
.get_param('allow_unplayable_formats')
69 and traverse_obj(format_dict
, ('drm', 'keySystem'))):
72 format_url
= url_or_none(format_dict
.get('src'))
73 format_type
= format_dict
.get('type')
74 ext
= determine_ext(format_url
)
75 if (format_type
== 'application/x-mpegURL'
76 or format_id
== 'HLS' or ext
== 'm3u8'):
77 formats
.extend(self
._extract
_m
3u8_formats
(
78 format_url
, video_id
, 'mp4',
79 entry_protocol
='m3u8_native', m3u8_id
='hls',
81 elif (format_type
== 'application/dash+xml'
82 or format_id
== 'DASH' or ext
== 'mpd'):
83 formats
.extend(self
._extract
_mpd
_formats
(
84 format_url
, video_id
, mpd_id
='dash', fatal
=False))
90 player
= self
._search
_json
(
91 r
'player:', webpage
, 'player', video_id
, fatal
=False, end_pattern
=r
';\s*</script>')
93 for src
in traverse_obj(player
, ('lib', 'source', 'sources', ...)):
94 process_format_list(src
)
95 duration
= traverse_obj(player
, ('sourceInfo', 'duration', {int_or_none}
))
96 if not formats
and not has_drm
:
97 # older code path, in use before August 2023
98 player
= self
._parse
_json
(
100 (r
'(?:(?:replacePlaceholders|processAdTagModifier).*?:\s*)?(?:replacePlaceholders|processAdTagModifier)\s*\(\s*(?P<json>{.*?})\s*\)(?:\s*\))?\s*,',
101 r
'Player\.init\s*\([^,]+,(?P<cndn>\s*\w+\s*\?)?\s*(?P<json>{(?(cndn).+?|.+)})\s*(?(cndn):|,\s*{.+?}\s*\)\s*;)'),
102 webpage
, 'player', group
='json'), video_id
)
104 for format_id
, format_list
in player
['tracks'].items():
105 process_format_list(format_list
, format_id
)
106 duration
= int_or_none(player
.get('duration'))
108 if not formats
and has_drm
:
109 self
.report_drm(video_id
)
111 title
= self
._og
_search
_title
(
112 webpage
, default
=None) or self
._search
_regex
(
113 (r
'<value>(?P<title>[^<]+)',
114 r
'videoTitle\s*:\s*(["\'])(?P
<value
>(?
:(?
!\
1).)+)\
1'), webpage,
115 'title
', group='value
')
116 thumbnail = self._og_search_thumbnail(
117 webpage, default=None) or self._search_regex(
118 r'poster\s
*:\s
*(["\'])(?P<value>(?:(?!\1).)+)\1', webpage,
119 'thumbnail', fatal=False, group='value')
120 duration = int_or_none(self._search_regex(
121 r'videoDuration\s*:\s*(\d+)', webpage, 'duration',
127 'thumbnail': thumbnail,
128 'duration': duration,
133 class NovaIE(InfoExtractor):
134 IE_DESC = 'TN.cz, Prásk.tv, Nova.cz, Novaplus.cz, FANDA.tv, Krásná.cz and Doma.cz'
135 _VALID_URL = r'https?://(?:[^.]+\.)?(?P<site>tv(?:noviny)?|tn|novaplus|vymena|fanda|krasna|doma|prask)\.nova\.cz/(?:[^/]+/)+(?P<id>[^/]+?)(?:\.html|/|$)'
137 'url': 'http://tn.nova.cz/clanek/tajemstvi-ukryte-v-podzemi-specialni-nemocnice-v-prazske-krci.html#player_13260',
138 'md5': 'da8f3f1fcdaf9fb0f112a32a165760a3',
141 'display_id': '8OvQqEvV3MW',
143 'title': 'Podzemní nemocnice v pražské Krči',
144 'description': 'md5:f0a42dd239c26f61c28f19e62d20ef53',
145 'thumbnail': r're:^https?://.*\.(?:jpg)',
149 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
153 'title': 'Zaklínač 3: Divoký hon',
154 'description': 're:.*Pokud se stejně jako my nemůžete.*',
155 'thumbnail': r're:https?://.*\.jpg(\?.*)?',
156 'upload_date': '20150521',
160 'skip_download': True,
164 # media.cms.nova.cz embed
165 'url': 'https://novaplus.nova.cz/porad/ulice/epizoda/18760-2180-dil',
169 'title': '2180. díl',
170 'thumbnail': r're:^https?://.*\.jpg',
174 'skip_download': True,
176 'add_ie': [NovaEmbedIE.ie_key()],
177 'skip': 'CHYBA 404: STRÁNKA NENALEZENA',
179 'url': 'http://sport.tn.nova.cz/clanek/sport/hokej/nhl/zivot-jde-dal-hodnotil-po-vyrazeni-z-playoff-jiri-sekac.html',
180 'only_matching': True,
182 'url': 'http://fanda.nova.cz/clanek/fun-and-games/krvavy-epos-zaklinac-3-divoky-hon-vychazi-vyhrajte-ho-pro-sebe.html',
183 'only_matching': True,
185 'url': 'http://doma.nova.cz/clanek/zdravi/prijdte-se-zapsat-do-registru-kostni-drene-jiz-ve-stredu-3-cervna.html',
186 'only_matching': True,
188 'url': 'http://prask.nova.cz/clanek/novinky/co-si-na-sobe-nase-hvezdy-nechaly-pojistit.html',
189 'only_matching': True,
191 'url': 'http://tv.nova.cz/clanek/novinky/zivot-je-zivot-bondovsky-trailer.html',
192 'only_matching': True,
195 def _real_extract(self, url):
196 mobj = self._match_valid_url(url)
197 display_id = mobj.group('id')
198 site = mobj.group('site')
200 webpage = self._download_webpage(url, display_id)
202 description = clean_html(self._og_search_description(webpage, default=None))
203 if site == 'novaplus':
204 upload_date = unified_strdate(self._search_regex(
205 r'(\d{1,2}-\d{1,2}-\d{4})$', display_id, 'upload date', default=None))
206 elif site == 'fanda':
207 upload_date = unified_strdate(self._search_regex(
208 r'<span class="date_time
">(\d{1,2}\.\d{1,2}\.\d{4})', webpage, 'upload date', default=None))
213 embed_id = self._search_regex(
214 r'<iframe[^>]+\bsrc=["\'](?
:https?
:)?
//media(?
:tn
)?\
.cms\
.nova\
.cz
/embed
/([^
/?
#&"\']+)',
215 webpage
, 'embed url', default
=None)
218 '_type': 'url_transparent',
219 'url': f
'https://media.cms.nova.cz/embed/{embed_id}',
220 'ie_key': NovaEmbedIE
.ie_key(),
222 'description': description
,
223 'upload_date': upload_date
,
226 video_id
= self
._search
_regex
(
227 [r
"(?:media|video_id)\s*:\s*'(\d+)'",
229 r
'id="article_video_(\d+)"',
230 r
'id="player_(\d+)"'],
233 config_url
= self
._search
_regex
(
234 r
'src="(https?://(?:tn|api)\.nova\.cz/bin/player/videojs/config\.php\?[^"]+)"',
235 webpage
, 'config url', default
=None)
239 player
= self
._parse
_json
(
241 r
'(?s)Player\s*\(.+?\s*,\s*({.+?\bmedia\b["\']?\s
*:\s
*["\']?\d+.+?})\s*\)', webpage,
242 'player', default='{}'),
243 video_id, transform_source=js_to_json, fatal=False)
245 config_url = url_or_none(player.get('configUrl'))
246 params = player.get('configParams')
247 if isinstance(params, dict):
248 config_params = params
251 DEFAULT_SITE_ID = '23000'
253 'tvnoviny': DEFAULT_SITE_ID,
254 'novaplus': DEFAULT_SITE_ID,
255 'vymena': DEFAULT_SITE_ID,
256 'krasna': DEFAULT_SITE_ID,
262 site_id = self._search_regex(
263 r'site=(\d+)', webpage, 'site id', default=None) or SITES.get(
264 site, DEFAULT_SITE_ID)
266 config_url = 'https://api.nova.cz/bin/player/videojs/config.php'
274 config = self._download_json(
275 config_url, display_id,
276 'Downloading config JSON', query=config_params,
277 transform_source=lambda s: s[s.index('{'):s.rindex('}') + 1])
279 mediafile = config['mediafile']
280 video_url = mediafile['src']
282 m = re.search(r'^(?P<url>rtmpe?://[^/]+/(?P<app>[^/]+?))/&*(?P<playpath>.+)$', video_url)
285 'url': m.group('url'),
286 'app': m.group('app'),
287 'play_path': m.group('playpath'),
288 'player_path': 'http://tvnoviny.nova.cz/static/shared/app/videojs/video-js.swf',
296 title = mediafile.get('meta', {}).get('title') or self._og_search_title(webpage)
297 thumbnail = config.get('poster')
301 'display_id': display_id,
303 'description': description,
304 'upload_date': upload_date,
305 'thumbnail': thumbnail,