diff options
Diffstat (limited to 'youtube_dlc/utils.py')
-rw-r--r-- | youtube_dlc/utils.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/youtube_dlc/utils.py b/youtube_dlc/utils.py index a374a31bf..9ae105331 100644 --- a/youtube_dlc/utils.py +++ b/youtube_dlc/utils.py @@ -4099,7 +4099,8 @@ def strip_jsonp(code): r'\g<callback_data>', code) -def js_to_json(code): +def js_to_json(code, vars={}): + # vars is a dict of var, val pairs to substitute COMMENT_RE = r'/\*(?:(?!\*/).)*?\*/|//[^\n]*' SKIP_RE = r'\s*(?:{comment})?\s*'.format(comment=COMMENT_RE) INTEGER_TABLE = ( @@ -4128,6 +4129,9 @@ def js_to_json(code): i = int(im.group(1), base) return '"%d":' % i if v.endswith(':') else '%d' % i + if v in vars: + return vars[v] + return '"%s"' % v return re.sub(r'''(?sx) |