]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/go.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / go.py
index fba98d79f501bc5a5dfd67836d58049882c5b032..bbb23ffc0aeea0e4b1d48e3d79e5fa618dbccd70 100644 (file)
@@ -1,7 +1,6 @@
 import re
 
 from .adobepass import AdobePassIE
-from ..compat import compat_str
 from ..utils import (
     ExtractorError,
     determine_ext,
@@ -50,14 +49,14 @@ class GoIE(AdobePassIE):
     _VALID_URL = r'''(?x)
                     https?://
                         (?P<sub_domain>
-                            (?:%s\.)?go|fxnow\.fxnetworks|
+                            (?:{}\.)?go|fxnow\.fxnetworks|
                             (?:www\.)?(?:abc|freeform|disneynow)
                         )\.com/
                         (?:
                             (?:[^/]+/)*(?P<id>[Vv][Dd][Kk][Aa]\w+)|
                             (?:[^/]+/)*(?P<display_id>[^/?\#]+)
                         )
-                    ''' % r'\.|'.join(list(_SITE_INFO.keys()))
+                    '''.format(r'\.|'.join(list(_SITE_INFO.keys())))
     _TESTS = [{
         'url': 'http://abc.go.com/shows/designated-survivor/video/most-recent/VDKA3807643',
         'info_dict': {
@@ -94,7 +93,7 @@ class GoIE(AdobePassIE):
             'series': 'Shadowhunters',
             'episode_number': 1,
             'timestamp': 1483387200,
-            'ext': 'mp4'
+            'ext': 'mp4',
         },
         'params': {
             'geo_bypass_ip_block': '3.244.239.0/24',
@@ -168,7 +167,7 @@ class GoIE(AdobePassIE):
     def _extract_videos(self, brand, video_id='-1', show_id='-1'):
         display_id = video_id if video_id != '-1' else show_id
         return self._download_json(
-            'http://api.contents.watchabc.go.com/vp2/ws/contents/3000/videos/%s/001/-1/%s/-1/%s/-1/-1.json' % (brand, show_id, video_id),
+            f'http://api.contents.watchabc.go.com/vp2/ws/contents/3000/videos/{brand}/001/-1/{show_id}/-1/{video_id}/-1/-1.json',
             display_id)['video']
 
     def _real_extract(self, url):
@@ -191,7 +190,7 @@ def _real_extract(self, url):
                 video_id = try_get(
                     layout,
                     (lambda x: x['videoid'], lambda x: x['video']['id']),
-                    compat_str)
+                    str)
             if not video_id:
                 video_id = self._search_regex(
                     (
@@ -201,7 +200,7 @@ def _real_extract(self, url):
                         # page.analytics.videoIdCode
                         r'\bvideoIdCode["\']\s*:\s*["\']((?:vdka|VDKA)\w+)',
                         # https://abc.com/shows/the-rookie/episode-guide/season-02/03-the-bet
-                        r'\b(?:video)?id["\']\s*:\s*["\'](VDKA\w+)'
+                        r'\b(?:video)?id["\']\s*:\s*["\'](VDKA\w+)',
                     ), webpage, 'video id', default=video_id)
             if not site_info:
                 brand = self._search_regex(
@@ -266,7 +265,7 @@ def _real_extract(self, url):
                             self.raise_geo_restricted(
                                 error['message'], countries=['US'])
                     error_message = ', '.join([error['message'] for error in errors])
-                    raise ExtractorError('%s said: %s' % (self.IE_NAME, error_message), expected=True)
+                    raise ExtractorError(f'{self.IE_NAME} said: {error_message}', expected=True)
                 asset_url += '?' + entitlement['uplynkData']['sessionKey']
                 fmts, subs = self._extract_m3u8_formats_and_subtitles(
                     asset_url, video_id, 'mp4', m3u8_id=format_id or 'hls', fatal=False)
@@ -280,7 +279,7 @@ def _real_extract(self, url):
                 }
                 if re.search(r'(?:/mp4/source/|_source\.mp4)', asset_url):
                     f.update({
-                        'format_id': ('%s-' % format_id if format_id else '') + 'SOURCE',
+                        'format_id': (f'{format_id}-' if format_id else '') + 'SOURCE',
                         'quality': 1,
                     })
                 else:
@@ -288,7 +287,7 @@ def _real_extract(self, url):
                     if mobj:
                         height = int(mobj.group(2))
                         f.update({
-                            'format_id': ('%s-' % format_id if format_id else '') + '%dP' % height,
+                            'format_id': (f'{format_id}-' if format_id else '') + f'{height}P',
                             'width': int(mobj.group(1)),
                             'height': height,
                         })