]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/tumblr.py
[ie/matchtv] Fix extractor (#10190)
[yt-dlp.git] / yt_dlp / extractor / tumblr.py
index a3e0e15f2887d77db2bdb54a4771b0b556362e1a..7f851bf63be8e76ca9295a292505dc4ce2be0a3c 100644 (file)
@@ -1,13 +1,9 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-
 from .common import InfoExtractor
 from ..utils import (
     ExtractorError,
     int_or_none,
     traverse_obj,
-    urlencode_postdata
+    urlencode_postdata,
 )
 
 
@@ -32,7 +28,7 @@ class TumblrIE(InfoExtractor):
             'repost_count': int,
             'age_limit': 0,
             'tags': ['Orphan Black', 'Tatiana Maslany', 'Interview', 'Video', 'OB S1 DVD Extras'],
-        }
+        },
     }, {
         'note': 'multiple formats',
         'url': 'https://maskofthedragon.tumblr.com/post/626907179849564160/mona-talking-in-english',
@@ -69,7 +65,7 @@ class TumblrIE(InfoExtractor):
             'repost_count': int,
             'age_limit': 0,
             'tags': [],
-        }
+        },
     }, {
         'note': 'dashboard only (original post)',
         'url': 'https://jujanon.tumblr.com/post/159704441298/my-baby-eating',
@@ -86,7 +82,7 @@ class TumblrIE(InfoExtractor):
             'repost_count': int,
             'age_limit': 0,
             'tags': ['crabs', 'my video', 'my pets'],
-        }
+        },
     }, {
         'note': 'dashboard only (reblog)',
         'url': 'https://bartlebyshop.tumblr.com/post/180294460076/duality-of-bird',
@@ -103,7 +99,7 @@ class TumblrIE(InfoExtractor):
             'repost_count': int,
             'age_limit': 0,
             'tags': [],
-        }
+        },
     }, {
         'note': 'dashboard only (external)',
         'url': 'https://afloweroutofstone.tumblr.com/post/675661759168823296/the-blues-remembers-everything-the-country-forgot',
@@ -153,7 +149,7 @@ class TumblrIE(InfoExtractor):
             'uploader': 'naked-yogi',
         },
         # 'add_ie': ['Vidme'],
-        'skip': 'dead embedded video host'
+        'skip': 'dead embedded video host',
     }, {
         'url': 'https://prozdvoices.tumblr.com/post/673201091169681408/what-recording-voice-acting-sounds-like',
         'md5': 'a0063fc8110e6c9afe44065b4ea68177',
@@ -247,11 +243,7 @@ class TumblrIE(InfoExtractor):
 
     _ACCESS_TOKEN = None
 
-    def _real_initialize(self):
-        self.get_access_token()
-        self._login()
-
-    def get_access_token(self):
+    def _initialize_pre_login(self):
         login_page = self._download_webpage(
             self._LOGIN_URL, None, 'Downloading login page', fatal=False)
         if login_page:
@@ -260,11 +252,7 @@ def get_access_token(self):
         if not self._ACCESS_TOKEN:
             self.report_warning('Failed to get access token; metadata will be missing and some videos may not work')
 
-    def _login(self):
-        username, password = self._get_login_info()
-        if not username:
-            return
-
+    def _perform_login(self, username, password):
         if not self._ACCESS_TOKEN:
             return
 
@@ -286,7 +274,7 @@ def _real_extract(self, url):
         url = f'http://{blog}.tumblr.com/post/{video_id}/'
         webpage, urlh = self._download_webpage_handle(url, video_id)
 
-        redirect_url = urlh.geturl()
+        redirect_url = urlh.url
 
         api_only = bool(self._search_regex(
             r'(tumblr.com|^)/(safe-mode|login_required|blog/view)',
@@ -370,14 +358,13 @@ def _real_extract(self, url):
             'height': int_or_none(
                 media_json.get('height') or self._og_search_property('video:height', webpage, default=None)),
         }]
-        self._sort_formats(formats)
 
         # the url we're extracting from might be an original post or it might be a reblog.
         # if it's a reblog, og:description will be the reblogger's comment, not the uploader's.
         # content_json is always the op, so if it exists but has no text, there's no description
         if content_json:
-            description = '\n\n'.join((
-                item.get('text') for item in content_json if item.get('type') == 'text')) or None
+            description = '\n\n'.join(
+                item.get('text') for item in content_json if item.get('type') == 'text') or None
         else:
             description = self._og_search_description(webpage, default=None)
         uploader_id = traverse_obj(post_json, 'reblogged_root_name', 'blog_name')