1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

[streamango] Fix extraction (closes #14160)

This commit is contained in:
gfabiano 2017-09-18 23:59:14 +02:00 committed by Sergey M․
parent d6a0350253
commit 6e72ea4775
No known key found for this signature in database
GPG Key ID: 2C393E0F18A9236D

View File

@ -38,6 +38,27 @@ class StreamangoIE(InfoExtractor):
}]
def _real_extract(self, url):
def decrypt_src(str_, val):
k = '=/+9876543210zyxwvutsrqponmlkjihgfedcbaZYXWVUTSRQPONMLKJIHGFEDCBA'
str_ = re.sub(r'[^A-Za-z0-9+/=]', '', str_)
src = ''
sm = [None] * 4
i = 0
str_len = len(str_)
while i < str_len:
for j in range(4):
sm[j % 4] = k.index(str_[i])
i += 1
charCode = ((sm[0] << 0x2) | (sm[1] >> 0x4)) ^ val
src += chr(charCode)
if (sm[2] != 0x40):
charCode = ((sm[1] & 0xf) << 0x4) | (sm[2] >> 0x2)
src += chr(charCode)
if (sm[3] != 0x40):
charCode = ((sm[2] & 0x3) << 0x6) | sm[3]
src += chr(charCode)
return src
video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id)
@ -45,14 +66,22 @@ class StreamangoIE(InfoExtractor):
title = self._og_search_title(webpage, default=video_id)
formats = []
for format_ in re.findall(r'({[^}]*\bsrc\s*:\s*[^}]*})', webpage):
for format_ in re.findall(r'\(\s*({[^}]*\bsrc\s*:\s*[^}]*})', webpage):
mobj = re.search(r'(src\s*:\s*[^(]\(([^)]*)\)[\s,]*)', format_)
if mobj is None:
continue
format_ = format_.replace(mobj.group(0), '')
video = self._parse_json(
format_, video_id, transform_source=js_to_json, fatal=False)
if not video:
continue
src = video.get('src')
if not src:
mobj = re.search(r'[\'"](?P<src>[^\'"]+)[\'"]\s*,\s*(?P<val>\d+)', mobj.group(1))
if mobj is None:
continue
src = decrypt_src(mobj.group('src'), int_or_none(mobj.group('val')))
ext = determine_ext(src, default_ext=None)
if video.get('type') == 'application/dash+xml' or ext == 'mpd':
formats.extend(self._extract_mpd_formats(