From 090fb58de7406b4800a70d7bfcae8f2d211e61ae Mon Sep 17 00:00:00 2001 From: subrat-lima Date: Tue, 24 Sep 2024 15:25:06 +0530 Subject: [PATCH] [ie/afl] refactored AFCVideoIE 1. added tag option to 'get_element_html_by_attribute' function. this removes the need for using '_search_json' 2. swapped 'if not' statement with 'if' for simplification feedback: pzhlkj6612 --- yt_dlp/extractor/afl.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yt_dlp/extractor/afl.py b/yt_dlp/extractor/afl.py index 8c07741c3f..3c0f029388 100644 --- a/yt_dlp/extractor/afl.py +++ b/yt_dlp/extractor/afl.py @@ -155,11 +155,11 @@ class AFCVideoIE(InfoExtractor): 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) - 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) + video_element_html = get_element_html_by_attribute('data-id', display_id, webpage, tag='a') + if video_element_html: + video_data = self._parse_json(extract_attributes(video_element_html)['data-ui-args'], display_id) else: - video_data = self._search_json(r'data-ui-args\s*=\s*["\']', video_element_html, 'video-id', display_id) + video_data = self._download_json(f'https://aflapi.afc.com.au/content/aflc-adel/video/en/{display_id}', display_id) video_id = video_data['mediaId'] video_url = f'https://players.brightcove.net/{account_id}/{player_id}/index.html?videoId={video_id}'