aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Kubeček <mkubecek@suse.cz>2021-12-07 17:44:43 +0100
committerGitHub <noreply@github.com>2021-12-07 22:14:43 +0530
commit443b21dc4e499286df3852f88fbd48e7f61b1f6a (patch)
tree3e6529a4f3dca6d3d576999284667690e2e1af13
parent66f4c04e50d9213522095247666d3d90345ad5d1 (diff)
downloadhypervideo-pre-443b21dc4e499286df3852f88fbd48e7f61b1f6a.tar.lz
hypervideo-pre-443b21dc4e499286df3852f88fbd48e7f61b1f6a.tar.xz
hypervideo-pre-443b21dc4e499286df3852f88fbd48e7f61b1f6a.zip
[ceskatelevize] Fetch iframe from nextJS data (#1904)
Closes #1899 Authored by: mkubecek
-rw-r--r--yt_dlp/extractor/ceskatelevize.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/yt_dlp/extractor/ceskatelevize.py b/yt_dlp/extractor/ceskatelevize.py
index f766dfbb7..6ca2f38b5 100644
--- a/yt_dlp/extractor/ceskatelevize.py
+++ b/yt_dlp/extractor/ceskatelevize.py
@@ -12,8 +12,7 @@ from ..utils import (
ExtractorError,
float_or_none,
sanitized_Request,
- unescapeHTML,
- update_url_query,
+ traverse_obj,
urlencode_postdata,
USER_AGENTS,
)
@@ -99,11 +98,13 @@ class CeskaTelevizeIE(InfoExtractor):
playlist_description = playlist_description.replace('\xa0', ' ')
if parsed_url.path.startswith('/porady/'):
- refer_url = update_url_query(unescapeHTML(self._search_regex(
- (r'<span[^>]*\bdata-url=(["\'])(?P<url>(?:(?!\1).)+)\1',
- r'<iframe[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//(?:www\.)?ceskatelevize\.cz/ivysilani/embed/iFramePlayer\.php.*?)\1'),
- webpage, 'iframe player url', group='url')), query={'autoStart': 'true'})
- webpage = self._download_webpage(refer_url, playlist_id)
+ next_data = self._search_nextjs_data(webpage, playlist_id)
+ idec = traverse_obj(next_data, ('props', 'pageProps', 'data', ('show', 'mediaMeta'), 'idec'), get_all=False)
+ if not idec:
+ raise ExtractorError('Failed to find IDEC id')
+ iframe_hash = self._download_webpage('https://www.ceskatelevize.cz/v-api/iframe-hash/', playlist_id)
+ webpage = self._download_webpage('https://www.ceskatelevize.cz/ivysilani/embed/iFramePlayer.php', playlist_id,
+ query={'hash': iframe_hash, 'origin': 'iVysilani', 'autoStart': 'true', 'IDEC': idec})
NOT_AVAILABLE_STRING = 'This content is not available at your territory due to limited copyright.'
if '%s</p>' % NOT_AVAILABLE_STRING in webpage: