]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/imdb.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / imdb.py
index 7eb66d821672971cf37b95e4e8e6dd2304c1cf5e..a786ce32e8b4f39886f6c337666719da9ce500fe 100644 (file)
@@ -1,5 +1,3 @@
-from __future__ import unicode_literals
-
 import base64
 import json
 import re
@@ -30,7 +28,7 @@ class ImdbIE(InfoExtractor):
             'description': 'md5:87bd0bdc61e351f21f20d2d7441cb4e7',
             'duration': 152,
             'thumbnail': r're:^https?://.+\.jpg',
-        }
+        },
     }, {
         'url': 'https://www.imdb.com/video/vi3516832537',
         'info_dict': {
@@ -40,7 +38,7 @@ class ImdbIE(InfoExtractor):
             'description': 'md5:17fcc4fe11ec29b4399be9d4c5ef126c',
             'duration': 153,
             'thumbnail': r're:^https?://.+\.jpg',
-        }
+        },
     }, {
         'url': 'http://www.imdb.com/video/_/vi2524815897',
         'only_matching': True,
@@ -68,14 +66,14 @@ def _real_extract(self, url):
         video_info = traverse_obj(info, ('props', 'pageProps', 'videoPlaybackData', 'video'), default={})
         title = (traverse_obj(video_info, ('name', 'value'), ('primaryTitle', 'titleText', 'text'))
                  or self._html_search_meta(('og:title', 'twitter:title'), webpage, default=None)
-                 or self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title'))
+                 or self._html_extract_title(webpage))
         data = video_info.get('playbackURLs') or try_get(self._download_json(
             'https://www.imdb.com/ve/data/VIDEO_PLAYBACK_DATA', video_id,
             query={
                 'key': base64.b64encode(json.dumps({
                     'type': 'VIDEO_PLAYER',
                     'subType': 'FORCE_LEGACY',
-                    'id': 'vi%s' % video_id,
+                    'id': f'vi{video_id}',
                 }).encode()).decode(),
             }), lambda x: x[0]['videoLegacyEncodings'])
         quality = qualities(('SD', '480p', '720p', '1080p'))
@@ -102,7 +100,6 @@ def _real_extract(self, url):
                 'ext': ext,
                 'quality': quality(format_id),
             })
-        self._sort_formats(formats)
 
         return {
             'id': video_id,
@@ -135,7 +132,7 @@ def _real_extract(self, url):
         webpage = self._download_webpage(url, list_id)
         entries = [
             self.url_result('http://www.imdb.com' + m, 'Imdb')
-            for m in re.findall(r'href="(/list/ls%s/videoplayer/vi[^"]+)"' % list_id, webpage)]
+            for m in re.findall(rf'href="(/list/ls{list_id}/videoplayer/vi[^"]+)"', webpage)]
 
         list_title = self._html_search_regex(
             r'<h1[^>]+class="[^"]*header[^"]*"[^>]*>(.*?)</h1>',