From cb0aa20d4fd74fe2ba0975d9e98de8d777bd2b31 Mon Sep 17 00:00:00 2001 From: subrat-lima Date: Fri, 20 Sep 2024 01:59:28 +0530 Subject: [PATCH] [ie/afl] updated AFCVideoIE & CarltonFCVideoIE mediaId parser --- yt_dlp/extractor/afl.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/yt_dlp/extractor/afl.py b/yt_dlp/extractor/afl.py index a56bbc49ac..8c07741c3f 100644 --- a/yt_dlp/extractor/afl.py +++ b/yt_dlp/extractor/afl.py @@ -156,11 +156,11 @@ def _real_extract(self, url): account_id = video_attrs['data-account-id'] video_element_html = get_element_html_by_attribute('data-id', display_id, webpage) - if video_element_html is None: - data = self._download_json(f'https://aflapi.afc.com.au/content/aflc-adel/video/en/{display_id}', display_id) - video_id = traverse_obj(data, ('mediaId', {str_or_none})) + if not video_element_html: + video_data = self._download_json(f'https://aflapi.afc.com.au/content/aflc-adel/video/en/{display_id}', display_id) else: - video_id = self._search_regex(r'"mediaId"\s*:\s*"(\d+)"', video_element_html, 'video-id', fatal=False) + video_data = self._search_json(r'data-ui-args\s*=\s*["\']', video_element_html, 'video-id', display_id) + video_id = video_data['mediaId'] video_url = f'https://players.brightcove.net/{account_id}/{player_id}/index.html?videoId={video_id}' video_url = smuggle_url(video_url, {'referrer': url}) @@ -193,12 +193,14 @@ class CarltonFCVideoIE(InfoExtractor): def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) - video_tag = get_element_html_by_attribute('data-id', display_id, webpage) - video_id = self._search_regex(r'"mediaId"\s*:\s*"(\d+)"', video_tag, 'video-id') video_attrs = extract_attributes(get_element_html_by_id('VideoModal', webpage)) player_id = video_attrs['data-player-id'] + '_default' account_id = video_attrs['data-account-id'] + video_element_html = get_element_html_by_attribute('data-id', display_id, webpage) + video_data = self._search_json(r'data-ui-args\s*=\s*["\']', video_element_html, 'video-id', display_id) + video_id = video_data['mediaId'] + video_url = f'https://players.brightcove.net/{account_id}/{player_id}/index.html?videoId={video_id}' video_url = smuggle_url(video_url, {'referrer': url}) return self.url_result(video_url, BrightcoveNewIE)