]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/hidive.py
[extractor] Deprecate `_sort_formats`
[yt-dlp.git] / yt_dlp / extractor / hidive.py
index ef1ca197e283f79b9a255ddfda4892a2c40edce4..3a53f2c459c251d3754663794b8775705b7cda0f 100644 (file)
@@ -1,4 +1,3 @@
-# coding: utf-8
 import re
 
 from .common import InfoExtractor
@@ -35,18 +34,16 @@ class HiDiveIE(InfoExtractor):
         'skip': 'Requires Authentication',
     }]
 
-    def _real_initialize(self):
-        email, password = self._get_login_info()
-        if email is None:
-            return
-
+    def _perform_login(self, username, password):
         webpage = self._download_webpage(self._LOGIN_URL, None)
         form = self._search_regex(
             r'(?s)<form[^>]+action="/account/login"[^>]*>(.+?)</form>',
-            webpage, 'login form')
+            webpage, 'login form', default=None)
+        if not form:  # logged in
+            return
         data = self._hidden_inputs(form)
         data.update({
-            'Email': email,
+            'Email': username,
             'Password': password,
         })
         self._download_webpage(
@@ -72,8 +69,9 @@ def _extract_subtitles_from_rendition(self, rendition, subtitles, parsed_urls):
                 parsed_urls.add(cc_url)
                 subtitles.setdefault(cc_lang, []).append({'url': cc_url})
 
-    def _get_subtitles(self, url, video_id, title, key, subtitles, parsed_urls):
+    def _get_subtitles(self, url, video_id, title, key, parsed_urls):
         webpage = self._download_webpage(url, video_id, fatal=False) or ''
+        subtitles = {}
         for caption in set(re.findall(r'data-captions=\"([^\"]+)\"', webpage)):
             renditions = self._call_api(
                 video_id, title, key, {'Captions': caption}, fatal=False,
@@ -93,7 +91,7 @@ def _real_extract(self, url):
             raise ExtractorError(
                 '%s said: %s' % (self.IE_NAME, restriction), expected=True)
 
-        formats, parsed_urls = [], {}, {None}
+        formats, parsed_urls = [], {None}
         for rendition_id, rendition in settings['renditions'].items():
             audio, version, extra = rendition_id.split('_')
             m3u8_url = url_or_none(try_get(rendition, lambda x: x['bitrates']['hls']))
@@ -105,7 +103,6 @@ def _real_extract(self, url):
                     f['language'] = audio
                     f['format_note'] = f'{version}, {extra}'
                 formats.extend(frmt)
-        self._sort_formats(formats)
 
         return {
             'id': video_id,