1
0
mirror of https://codeberg.org/polarisfm/youtube-dl synced 2024-11-26 02:14:32 +01:00

[utils] Fix comment handling in js_to_json for Python <3.5

This commit is contained in:
TinyToweringTree 2020-01-29 08:47:05 +01:00
parent 13a91f1642
commit 3acb64abd5

View File

@ -3984,7 +3984,7 @@ def js_to_json(code):
# This regular expression is based on this Stack Overflow answer: # This regular expression is based on this Stack Overflow answer:
# https://stackoverflow.com/a/25735600 # https://stackoverflow.com/a/25735600
code = re.sub(r'("(?:[^"\\]|\\[\s\S])*"|\'(?:[^\'\\]|\\[\s\S])*\')|[ \t]*//.*|[ \t]*/\*(?:[^*]|\*(?!/))*\*/', code = re.sub(r'("(?:[^"\\]|\\[\s\S])*"|\'(?:[^\'\\]|\\[\s\S])*\')|[ \t]*//.*|[ \t]*/\*(?:[^*]|\*(?!/))*\*/',
'\\1', code) lambda m: m.group(1) or '', code)
def fix_kv(m): def fix_kv(m):
v = m.group(0) v = m.group(0)