# coding: utf-8 from __future__ import unicode_literals from .common import InfoExtractor from hashlib import sha1 import re,zlib from ..compat import ( compat_urllib_request ) class tvpleIE(InfoExtractor): _VALID_URL = r'https?://(?P(?:www\.)?tvple\.com/(?P[0-9]+))' _TEST = { 'url': 'http://tvple.com/311090', 'md5': '02e384fd3c3c6884e1bb997f6afd51e2', 'info_dict': { 'id': '311090', 'ext': 'mp4', 'uploader': '[디지털 드럭] 나비붙이', 'uploader_id': 'jack1609', 'title': '팜플렛으로 yee를 연주하는 김병만', 'description': '자작입니다. 첫 조교..인가..? 조교라긴 애매하지만, 어쨋든 노래로 만드는 건 이번이 처음입니다.\n원본 영상 출처: https://www.youtube.com/watch?v=E4BPHBL35dE\nyee는 유튜브에 치면 원본 영상이 나오는데 다들 아시죠??? 저작권 문제가 될 경우는 지우겠습니다...\n\n병만로이드라고 불러야 하나??' # TODO more properties, either as: # * A value # * MD5 checksum; start the string with md5: # * A regular expression; start the string with re: # * Any Python type (for example int or float) } } def decodetvple(self,key): """based on decompiled tvple player v2.50401""" #1st key checker #if((key[:4] != "feff") | (key[20:21] != "_")): # print("error:wrong key") #descramble key deckey = list(key[69:85]) code = key[125:][::-1] #descrambling hexed = code.replace(deckey[5], "g").replace(deckey[4], "h").replace(deckey[3], "i").replace(deckey[2], "j").replace(deckey[1], "k").replace(deckey[6], deckey[5]).replace(deckey[7], deckey[4]).replace(deckey[8], deckey[3]).replace(deckey[9], deckey[2]).replace(deckey[10], deckey[1]).replace("g", deckey[6]).replace("h", deckey[7]).replace("i", deckey[8]).replace("j", deckey[9]).replace("k", deckey[10]) decoded = hexed.decode("hex") #2nd key checker #if( sha1(decoded).hexdigest() != key[85:125]): # print("error:key checksum failed") return decoded #def downloadgurum(misc): def _real_extract(self, url): video_id = self._match_id(url) webpage = self._download_webpage(url, video_id) playurl = self._html_search_regex(r'http://tvple.com/crossdomain.xml\n(.*)\n1', self.decodetvple(re.search(r'data-key="(.*)"', webpage).group(1)), "playurl") playpage = self._download_webpage(playurl, "playurl_%d" % int(video_id)) videourl = re.search("