From 4d75f2cb31bd4c92ebf0dadb190e60ae01df5f32 Mon Sep 17 00:00:00 2001 From: Zhang Weijie Date: Thu, 11 May 2017 16:37:04 +0800 Subject: [PATCH] [meipai] decode url --- youtube_dl/extractor/meipai.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/youtube_dl/extractor/meipai.py b/youtube_dl/extractor/meipai.py index c8eacb4f4..af1ab824c 100644 --- a/youtube_dl/extractor/meipai.py +++ b/youtube_dl/extractor/meipai.py @@ -7,7 +7,35 @@ from ..utils import ( parse_duration, 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): IE_DESC = '美拍' @@ -73,7 +101,7 @@ class MeipaiIE(InfoExtractor): group='url', default=None) if video_url: formats.append({ - 'url': video_url, + 'url': decode(video_url), 'format_id': 'http', })