Skip to content

Commit

Permalink
[ie/afl] refactored AFCVideoIE
Browse files Browse the repository at this point in the history
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
  • Loading branch information
subrat-lima committed Sep 24, 2024
1 parent cb0aa20 commit 090fb58
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions yt_dlp/extractor/afl.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,11 @@ def _real_extract(self, url):
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}'
Expand Down

0 comments on commit 090fb58

Please sign in to comment.