]> jfr.im git - yt-dlp.git/commitdiff
[crunhyroll] Fix inheritance
authorpukkandan <redacted>
Wed, 30 Mar 2022 12:49:22 +0000 (18:19 +0530)
committerpukkandan <redacted>
Wed, 30 Mar 2022 12:49:51 +0000 (18:19 +0530)
https://github.com/yt-dlp/yt-dlp/pull/2955#issuecomment-1083060465

yt_dlp/extractor/crunchyroll.py
yt_dlp/extractor/vrv.py

index bf1bf8c1c4753e18f421f209e549c8154040d74c..bb4ae12f50bc257fef9cd1e867f3bf0dca8f063a 100644 (file)
@@ -9,7 +9,7 @@
 from hashlib import sha1
 from math import pow, sqrt, floor
 from .common import InfoExtractor
-from .vrv import VRVIE
+from .vrv import VRVBaseIE
 from ..compat import (
     compat_b64decode,
     compat_etree_Element,
@@ -100,7 +100,7 @@ def _add_skip_wall(url):
             parsed_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
 
 
-class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
+class CrunchyrollIE(CrunchyrollBaseIE, VRVBaseIE):
     IE_NAME = 'crunchyroll'
     _VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|(?:[^/]*/){1,2}[^/?&]*?)(?P<id>[0-9]+))(?:[/?&]|$)'
     _TESTS = [{
index 10e6be7ed42adabb321b9a668584b9d4d66cabef..00e1006c4512c9e52f27c2565b2605319b441404 100644 (file)
@@ -85,7 +85,30 @@ def _get_cms_resource(self, resource_key, video_id):
                 'resource_key': resource_key,
             })['__links__']['cms_resource']['href']
 
-    def _initialize_pre_login(self):
+    def _extract_vrv_formats(self, url, video_id, stream_format, audio_lang, hardsub_lang):
+        if not url or stream_format not in ('hls', 'dash', 'adaptive_hls'):
+            return []
+        format_id = join_nonempty(
+            stream_format,
+            audio_lang and 'audio-%s' % audio_lang,
+            hardsub_lang and 'hardsub-%s' % hardsub_lang)
+        if 'hls' in stream_format:
+            adaptive_formats = self._extract_m3u8_formats(
+                url, video_id, 'mp4', m3u8_id=format_id,
+                note='Downloading %s information' % format_id,
+                fatal=False)
+        elif stream_format == 'dash':
+            adaptive_formats = self._extract_mpd_formats(
+                url, video_id, mpd_id=format_id,
+                note='Downloading %s information' % format_id,
+                fatal=False)
+        if audio_lang:
+            for f in adaptive_formats:
+                if f.get('acodec') != 'none':
+                    f['language'] = audio_lang
+        return adaptive_formats
+
+    def _set_api_params(self):
         webpage = self._download_webpage(
             'https://vrv.co/', None, headers=self.geo_verification_headers())
         self._API_PARAMS = self._parse_json(self._search_regex(
@@ -133,28 +156,8 @@ def _perform_login(self, username, password):
         self._TOKEN = token_credentials['oauth_token']
         self._TOKEN_SECRET = token_credentials['oauth_token_secret']
 
-    def _extract_vrv_formats(self, url, video_id, stream_format, audio_lang, hardsub_lang):
-        if not url or stream_format not in ('hls', 'dash', 'adaptive_hls'):
-            return []
-        format_id = join_nonempty(
-            stream_format,
-            audio_lang and 'audio-%s' % audio_lang,
-            hardsub_lang and 'hardsub-%s' % hardsub_lang)
-        if 'hls' in stream_format:
-            adaptive_formats = self._extract_m3u8_formats(
-                url, video_id, 'mp4', m3u8_id=format_id,
-                note='Downloading %s information' % format_id,
-                fatal=False)
-        elif stream_format == 'dash':
-            adaptive_formats = self._extract_mpd_formats(
-                url, video_id, mpd_id=format_id,
-                note='Downloading %s information' % format_id,
-                fatal=False)
-        if audio_lang:
-            for f in adaptive_formats:
-                if f.get('acodec') != 'none':
-                    f['language'] = audio_lang
-        return adaptive_formats
+    def _initialize_pre_login(self):
+        return self._set_api_params()
 
     def _real_extract(self, url):
         video_id = self._match_id(url)
@@ -249,6 +252,9 @@ class VRVSeriesIE(VRVBaseIE):
         'playlist_mincount': 11,
     }
 
+    def _initialize_pre_login(self):
+        return self._set_api_params()
+
     def _real_extract(self, url):
         series_id = self._match_id(url)