mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
[youtube] s_to_sig: no substitution for 3-char main function names
This commit is contained in:
parent
699391135b
commit
5d41240860
@ -78,6 +78,7 @@ class YouTube(VideoExtractor):
|
||||
# - https://www.youtube.com/yts/jsbin/player_ias-vfl-jbnrr/da_DK/base.js
|
||||
# - https://www.youtube.com/s/player/0b643cd1/player_ias.vflset/sv_SE/base.js
|
||||
# - https://www.youtube.com/s/player/50e823fc/player_ias.vflset/sv_SE/base.js
|
||||
# - https://www.youtube.com/s/player/3b5d5649/player_ias.vflset/sv_SE/base.js
|
||||
def tr_js(code):
|
||||
code = re.sub(r'function', r'def', code)
|
||||
# add prefix '_sig_' to prevent namespace pollution
|
||||
@ -117,7 +118,9 @@ class YouTube(VideoExtractor):
|
||||
f2 = re.sub(r'\$', '_dollar', f2)
|
||||
code = code + 'global _sig_%s\n' % f2 + tr_js(f2def)
|
||||
|
||||
f1 = re.sub(r'(as|if|in|is|or)', r'_\1', f1)
|
||||
# if f1 contains more than 2 characters, no need to do substitution
|
||||
# FIXME: we probably shouldn't do any substitution here at all?
|
||||
f1 = re.sub(r'^(as|if|in|is|or)$', r'_\1', f1)
|
||||
f1 = re.sub(r'\$', '_dollar', f1)
|
||||
code = code + '_sig=_sig_%s(s)' % f1
|
||||
exec(code, globals(), locals())
|
||||
|
Loading…
Reference in New Issue
Block a user