X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/a687226b48f71b874fa18b0165ec528d591f53fb..5dbac313ae4e3e8521dfe2e1a6a048a98ff4b4fe:/yt_dlp/extractor/rcti.py diff --git a/yt_dlp/extractor/rcti.py b/yt_dlp/extractor/rcti.py index 6a7c7f399..61b73a550 100644 --- a/yt_dlp/extractor/rcti.py +++ b/yt_dlp/extractor/rcti.py @@ -5,11 +5,11 @@ from .common import InfoExtractor from ..networking.exceptions import HTTPError from ..utils import ( - dict_get, ExtractorError, + dict_get, strip_or_none, traverse_obj, - try_get + try_get, ) @@ -154,34 +154,34 @@ def _real_extract(self, url): is_upcoming = try_get(video_json, lambda x: x['current_date'] < x['start_date']) if is_upcoming: self.raise_no_formats( - 'This event will start at %s.' % video_json['live_label'] if video_json.get('live_label') else 'This event has not started yet.', expected=True) + 'This event will start at {}.'.format(video_json['live_label']) if video_json.get('live_label') else 'This event has not started yet.', expected=True) if 'akamaized' in video_url: # For some videos hosted on Akamai's CDN (possibly AES-encrypted ones?), a session needs to at least be made via Conviva's API conviva_json_data = { **self._CONVIVA_JSON_TEMPLATE, 'url': video_url, - 'sst': int(time.time()) + 'sst': int(time.time()), } conviva_json_res = self._download_json( 'https://ff84ae928c3b33064b76dec08f12500465e59a6f.cws.conviva.com/0/wsg', display_id, 'Creating Conviva session', 'Failed to create Conviva session', - fatal=False, data=json.dumps(conviva_json_data).encode('utf-8')) + fatal=False, data=json.dumps(conviva_json_data).encode()) if conviva_json_res and conviva_json_res.get('err') != 'ok': - self.report_warning('Conviva said: %s' % str(conviva_json_res.get('err'))) + self.report_warning('Conviva said: {}'.format(str(conviva_json_res.get('err')))) video_meta, meta_paths = self._call_api( - 'https://api.rctiplus.com/api/v1/%s/%s' % (video_type, video_id), display_id, 'Downloading video metadata') + f'https://api.rctiplus.com/api/v1/{video_type}/{video_id}', display_id, 'Downloading video metadata') thumbnails, image_path = [], meta_paths.get('image_path', 'https://rstatic.akamaized.net/media/') if video_meta.get('portrait_image'): thumbnails.append({ 'id': 'portrait_image', - 'url': '%s%d%s' % (image_path, 2000, video_meta['portrait_image']) # 2000px seems to be the highest resolution that can be given + 'url': '{}{}{}'.format(image_path, 2000, video_meta['portrait_image']), # 2000px seems to be the highest resolution that can be given }) if video_meta.get('landscape_image'): thumbnails.append({ 'id': 'landscape_image', - 'url': '%s%d%s' % (image_path, 2000, video_meta['landscape_image']) + 'url': '{}{}{}'.format(image_path, 2000, video_meta['landscape_image']), }) try: formats = self._extract_m3u8_formats(video_url, display_id, 'mp4', headers={'Referer': 'https://www.rctiplus.com/'}) @@ -241,7 +241,7 @@ class RCTIPlusSeriesIE(RCTIPlusBaseIE): 'age_limit': 2, 'tags': 'count:11', 'display_id': 'inews-pagi', - } + }, }] _AGE_RATINGS = { # Based off https://id.wikipedia.org/wiki/Sistem_rating_konten_televisi with additional ratings 'S-SU': 2, @@ -255,13 +255,13 @@ class RCTIPlusSeriesIE(RCTIPlusBaseIE): @classmethod def suitable(cls, url): - return False if RCTIPlusIE.suitable(url) else super(RCTIPlusSeriesIE, cls).suitable(url) + return False if RCTIPlusIE.suitable(url) else super().suitable(url) def _entries(self, url, display_id=None, note='Downloading entries JSON', metadata={}): total_pages = 0 try: total_pages = self._call_api( - '%s&length=20&page=0' % url, + f'{url}&length=20&page=0', display_id, note)[1]['pagination']['total_page'] except ExtractorError as e: if 'not found' in str(e): @@ -272,8 +272,8 @@ def _entries(self, url, display_id=None, note='Downloading entries JSON', metada for page_num in range(1, total_pages + 1): episode_list = self._call_api( - '%s&length=20&page=%s' % (url, page_num), - display_id, '%s page %s' % (note, page_num))[0] or [] + f'{url}&length=20&page={page_num}', + display_id, f'{note} page {page_num}')[0] or [] for video_json in episode_list: yield { @@ -288,7 +288,7 @@ def _entries(self, url, display_id=None, note='Downloading entries JSON', metada 'duration': video_json.get('duration'), 'season_number': video_json.get('season'), 'episode_number': video_json.get('episode'), - **metadata + **metadata, } def _series_entries(self, series_id, display_id=None, video_type=None, metadata={}): @@ -348,7 +348,7 @@ class RCTIPlusTVIE(RCTIPlusBaseIE): }, 'params': { 'skip_download': True, - } + }, }, { # Returned video will always change 'url': 'https://www.rctiplus.com/live-event', @@ -361,7 +361,7 @@ class RCTIPlusTVIE(RCTIPlusBaseIE): @classmethod def suitable(cls, url): - return False if RCTIPlusIE.suitable(url) else super(RCTIPlusTVIE, cls).suitable(url) + return False if RCTIPlusIE.suitable(url) else super().suitable(url) def _real_extract(self, url): match = self._match_valid_url(url).groupdict()