mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-26 21:59:08 +01:00
[crunhyroll] Fix inheritance
https://github.com/yt-dlp/yt-dlp/pull/2955#issuecomment-1083060465
This commit is contained in:
parent
5d0aeac0e9
commit
11078c6d57
2 changed files with 31 additions and 25 deletions
|
@ -9,7 +9,7 @@ import zlib
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
from math import pow, sqrt, floor
|
from math import pow, sqrt, floor
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from .vrv import VRVIE
|
from .vrv import VRVBaseIE
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_b64decode,
|
compat_b64decode,
|
||||||
compat_etree_Element,
|
compat_etree_Element,
|
||||||
|
@ -100,7 +100,7 @@ class CrunchyrollBaseIE(InfoExtractor):
|
||||||
parsed_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
|
parsed_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
|
||||||
|
|
||||||
|
|
||||||
class CrunchyrollIE(CrunchyrollBaseIE, VRVIE):
|
class CrunchyrollIE(CrunchyrollBaseIE, VRVBaseIE):
|
||||||
IE_NAME = 'crunchyroll'
|
IE_NAME = 'crunchyroll'
|
||||||
_VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|(?:[^/]*/){1,2}[^/?&]*?)(?P<id>[0-9]+))(?:[/?&]|$)'
|
_VALID_URL = r'https?://(?:(?P<prefix>www|m)\.)?(?P<url>crunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|(?:[^/]*/){1,2}[^/?&]*?)(?P<id>[0-9]+))(?:[/?&]|$)'
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
|
|
|
@ -85,7 +85,30 @@ class VRVBaseIE(InfoExtractor):
|
||||||
'resource_key': resource_key,
|
'resource_key': resource_key,
|
||||||
})['__links__']['cms_resource']['href']
|
})['__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(
|
webpage = self._download_webpage(
|
||||||
'https://vrv.co/', None, headers=self.geo_verification_headers())
|
'https://vrv.co/', None, headers=self.geo_verification_headers())
|
||||||
self._API_PARAMS = self._parse_json(self._search_regex(
|
self._API_PARAMS = self._parse_json(self._search_regex(
|
||||||
|
@ -133,28 +156,8 @@ class VRVIE(VRVBaseIE):
|
||||||
self._TOKEN = token_credentials['oauth_token']
|
self._TOKEN = token_credentials['oauth_token']
|
||||||
self._TOKEN_SECRET = token_credentials['oauth_token_secret']
|
self._TOKEN_SECRET = token_credentials['oauth_token_secret']
|
||||||
|
|
||||||
def _extract_vrv_formats(self, url, video_id, stream_format, audio_lang, hardsub_lang):
|
def _initialize_pre_login(self):
|
||||||
if not url or stream_format not in ('hls', 'dash', 'adaptive_hls'):
|
return self._set_api_params()
|
||||||
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 _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
@ -249,6 +252,9 @@ class VRVSeriesIE(VRVBaseIE):
|
||||||
'playlist_mincount': 11,
|
'playlist_mincount': 11,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _initialize_pre_login(self):
|
||||||
|
return self._set_api_params()
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
series_id = self._match_id(url)
|
series_id = self._match_id(url)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue