[crunchyroll] reduce requests for formats extraction
This commit is contained in:
parent
67167920db
commit
065216d94f
|
@ -26,6 +26,7 @@ from ..utils import (
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
urlencode_postdata,
|
urlencode_postdata,
|
||||||
xpath_text,
|
xpath_text,
|
||||||
|
extract_attributes,
|
||||||
)
|
)
|
||||||
from ..aes import (
|
from ..aes import (
|
||||||
aes_cbc_decrypt,
|
aes_cbc_decrypt,
|
||||||
|
@ -305,9 +306,18 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
|
||||||
r'<a[^>]+href="/publisher/[^"]+"[^>]*>([^<]+)</a>', webpage,
|
r'<a[^>]+href="/publisher/[^"]+"[^>]*>([^<]+)</a>', webpage,
|
||||||
'video_uploader', fatal=False)
|
'video_uploader', fatal=False)
|
||||||
|
|
||||||
formats = []
|
available_fmts = []
|
||||||
|
for a, fmt in re.findall(r'(<a[^>]+token="showmedia\.([0-9]{3,4})p"[^>]+>.*?</a>)', webpage):
|
||||||
|
attrs = extract_attributes(a)
|
||||||
|
href = attrs.get('href')
|
||||||
|
if href and '/freetrial' in href:
|
||||||
|
continue
|
||||||
|
available_fmts.append(fmt)
|
||||||
|
if not available_fmts:
|
||||||
|
available_fmts = re.findall(r'token="showmedia\.([0-9]{3,4})p"', webpage)
|
||||||
video_encode_ids = []
|
video_encode_ids = []
|
||||||
for fmt in re.findall(r'token="showmedia\.([0-9]{3,4})p"', webpage):
|
formats = []
|
||||||
|
for fmt in available_fmts:
|
||||||
stream_quality, stream_format = self._FORMAT_IDS[fmt]
|
stream_quality, stream_format = self._FORMAT_IDS[fmt]
|
||||||
video_format = fmt + 'p'
|
video_format = fmt + 'p'
|
||||||
streamdata_req = sanitized_Request(
|
streamdata_req = sanitized_Request(
|
||||||
|
|
Loading…
Reference in New Issue