[videomega] better approach using str.translate()

This commit is contained in:
Mort Yao 2015-12-31 13:57:16 +01:00
parent cb3eded938
commit 56a5e63edb

View File

@ -29,14 +29,8 @@ class Videomega(VideoExtractor):
self.title = match1(content, r'<title>(.*)</title>') self.title = match1(content, r'<title>(.*)</title>')
js = match1(content, r'(eval.*)') js = match1(content, r'(eval.*)')
t = match1(js, r'\$\("\d+"\)\.\d+\("\d+","([^"]+)"\)') t = match1(js, r'\$\("\d+"\)\.\d+\("\d+","([^"]+)"\)')
t = re.sub(r'(\w)', r'{\1}', t) \ t = re.sub(r'(\w)', r'{\1}', t)
.replace('a', '10') \ t = t.translate({87 + i: str(i) for i in range(10, 36)})
.replace('b', '11') \
.replace('c', '12') \
.replace('d', '13') \
.replace('e', '14') \
.replace('f', '15') \
.replace('g', '16')
s = match1(js, r"'([^']+)'\.split").split('|') s = match1(js, r"'([^']+)'\.split").split('|')
self.streams['original'] = { self.streams['original'] = {
'url': t.format(*s) 'url': t.format(*s)