1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 10:24:33 +01:00

[meipai] decode url

This commit is contained in:
Zhang Weijie 2017-05-11 16:37:04 +08:00
parent 3166b1f0ac
commit 4d75f2cb31

View File

@ -7,7 +7,35 @@ from ..utils import (
parse_duration, parse_duration,
unified_timestamp, unified_timestamp,
) )
import base64
def decode(encoded_string):
def getHex(param1):
return {
'str': param1[4:],
'hex': ''.join(list(param1[:4])[::-1]),
}
def getDec(param1):
loc2 = str(int(param1, 16))
return {
'pre': list(loc2[:2]),
'tail': list(loc2[2:]),
}
def substr(param1, param2):
loc3 = param1[0: int(param2[0])]
loc4 = param1[int(param2[0]): int(param2[0]) + int(param2[1])]
return loc3 + param1[int(param2[0]):].replace(loc4, "")
def getPos(param1, param2):
param2[0] = len(param1) - int(param2[0]) - int(param2[1])
return param2
dict2 = getHex(encoded_string)
dict3 = getDec(dict2['hex'])
str4 = substr(dict2['str'], dict3['pre'])
return base64.b64decode(substr(str4, getPos(str4, dict3['tail'])))
class MeipaiIE(InfoExtractor): class MeipaiIE(InfoExtractor):
IE_DESC = '美拍' IE_DESC = '美拍'
@ -73,7 +101,7 @@ class MeipaiIE(InfoExtractor):
group='url', default=None) group='url', default=None)
if video_url: if video_url:
formats.append({ formats.append({
'url': video_url, 'url': decode(video_url),
'format_id': 'http', 'format_id': 'http',
}) })