]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/eagleplatform.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / eagleplatform.py
index 739d17912ae6d4b6058268d10813553b836e389d..685f8c05902dd461fe370e47c0e6eff87471e18b 100644 (file)
@@ -70,14 +70,14 @@ def _extract_embed_urls(cls, url, webpage):
                     '''
         # "Basic usage" embedding (see http://dultonmedia.github.io/eplayer/)
         mobj = re.search(
-            r'''(?xs)
-                    %s
+            rf'''(?xs)
+                    {PLAYER_JS_RE}
                     <div[^>]+
                         class=(?P<qclass>["\'])eagleplayer(?P=qclass)[^>]+
                         data-id=["\'](?P<id>\d+)
-            ''' % PLAYER_JS_RE, webpage)
+            ''', webpage)
         if mobj is not None:
-            return [add_referer('eagleplatform:%(host)s:%(id)s' % mobj.groupdict())]
+            return [add_referer('eagleplatform:{host}:{id}'.format(**mobj.groupdict()))]
         # Generalization of "Javascript code usage", "Combined usage" and
         # "Usage without attaching to DOM" embeddings (see
         # http://dultonmedia.github.io/eplayer/)
@@ -96,9 +96,9 @@ def _extract_embed_urls(cls, url, webpage):
                     \s*\)
                     .+?
                     </script>
-            ''' % PLAYER_JS_RE, webpage)
+            ''' % PLAYER_JS_RE, webpage)  # noqa: UP031
         if mobj is not None:
-            return [add_referer('eagleplatform:%(host)s:%(id)s' % mobj.groupdict())]
+            return [add_referer('eagleplatform:{host}:{id}'.format(**mobj.groupdict()))]
 
     @staticmethod
     def _handle_error(response):
@@ -108,7 +108,7 @@ def _handle_error(response):
 
     def _download_json(self, url_or_request, video_id, *args, **kwargs):
         try:
-            response = super(EaglePlatformIE, self)._download_json(
+            response = super()._download_json(
                 url_or_request, video_id, *args, **kwargs)
         except ExtractorError as ee:
             if isinstance(ee.cause, HTTPError):
@@ -137,7 +137,7 @@ def _real_extract(self, url):
             query['referrer'] = referrer
 
         player_data = self._download_json(
-            'http://%s/api/player_data' % host, video_id,
+            f'http://{host}/api/player_data', video_id,
             headers=headers, query=query)
 
         media = player_data['data']['playlist']['viewports'][0]['medialist'][0]
@@ -186,7 +186,7 @@ def _real_extract(self, url):
                     })
                 else:
                     f = {
-                        'format_id': 'http-%s' % format_id,
+                        'format_id': f'http-{format_id}',
                         'height': int_or_none(format_id),
                     }
                 f['url'] = format_url
@@ -212,4 +212,4 @@ def _extract_embed_urls(cls, url, webpage):
         mobj = re.search(
             r'<iframe[^>]+src="https?://(?P<host>media\.clipyou\.ru)/index/player\?.*\brecord_id=(?P<id>\d+).*"', webpage)
         if mobj is not None:
-            yield smuggle_url('eagleplatform:%(host)s:%(id)s' % mobj.groupdict(), {'referrer': url})
+            yield smuggle_url('eagleplatform:{host}:{id}'.format(**mobj.groupdict()), {'referrer': url})