]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/hidive.py
[extractor/ViMP] Add thumbnail and support more sites (#4147)
[yt-dlp.git] / yt_dlp / extractor / hidive.py
index 18ae4d37923408095ed36360704ae64db9912753..a6a71d6307860b6864ca1d4363c42033c1bd9888 100644 (file)
@@ -1,4 +1,3 @@
-# coding: utf-8
 import re
 
 from .common import InfoExtractor
 import re
 
 from .common import InfoExtractor
@@ -35,18 +34,14 @@ class HiDiveIE(InfoExtractor):
         'skip': 'Requires Authentication',
     }]
 
         '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')
         data = self._hidden_inputs(form)
         data.update({
         webpage = self._download_webpage(self._LOGIN_URL, None)
         form = self._search_regex(
             r'(?s)<form[^>]+action="/account/login"[^>]*>(.+?)</form>',
             webpage, 'login form')
         data = self._hidden_inputs(form)
         data.update({
-            'Email': email,
+            'Email': username,
             'Password': password,
         })
         self._download_webpage(
             'Password': password,
         })
         self._download_webpage(
@@ -72,8 +67,9 @@ def _extract_subtitles_from_rendition(self, rendition, subtitles, parsed_urls):
                 parsed_urls.add(cc_url)
                 subtitles.setdefault(cc_lang, []).append({'url': cc_url})
 
                 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 ''
         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,
         for caption in set(re.findall(r'data-captions=\"([^\"]+)\"', webpage)):
             renditions = self._call_api(
                 video_id, title, key, {'Captions': caption}, fatal=False,
@@ -93,7 +89,7 @@ def _real_extract(self, url):
             raise ExtractorError(
                 '%s said: %s' % (self.IE_NAME, restriction), expected=True)
 
             raise ExtractorError(
                 '%s said: %s' % (self.IE_NAME, restriction), expected=True)
 
-        formats, subtitles, 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']))
         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,14 +101,12 @@ def _real_extract(self, url):
                     f['language'] = audio
                     f['format_note'] = f'{version}, {extra}'
                 formats.extend(frmt)
                     f['language'] = audio
                     f['format_note'] = f'{version}, {extra}'
                 formats.extend(frmt)
-
-            self._extract_subtitles_from_rendition(rendition, subtitles, parsed_urls)
         self._sort_formats(formats)
 
         return {
             'id': video_id,
             'title': video_id,
         self._sort_formats(formats)
 
         return {
             'id': video_id,
             'title': video_id,
-            'subtitles': self.extract_subtitles(url, video_id, title, key, subtitles, parsed_urls),
+            'subtitles': self.extract_subtitles(url, video_id, title, key, parsed_urls),
             'formats': formats,
             'series': title,
             'season_number': int_or_none(
             'formats': formats,
             'series': title,
             'season_number': int_or_none(