diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-10-15 12:05:13 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-10-15 12:05:13 +0200 |
commit | 9d4660cab15f374176f87d3f747a559142e4af9b (patch) | |
tree | 6b3fe1b19cc7ca4c8123a0e0dcd80508105f5028 /youtube_dl/utils.py | |
parent | cd054fc491198a5a7c69d76f19693b1cd4d5c086 (diff) |
[generic] Support embedded vimeo videos (#1602)
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 3e81c308b..833f981f2 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -945,3 +945,20 @@ class locked_file(object): def shell_quote(args): return ' '.join(map(pipes.quote, args)) + + +def smuggle_url(url, data): + """ Pass additional data in a URL for internal use. """ + + sdata = compat_urllib_parse.urlencode( + {u'__youtubedl_smuggle': json.dumps(data)}) + return url + u'#' + sdata + + +def unsmuggle_url(smug_url): + if not '#__youtubedl_smuggle' in smug_url: + return smug_url, None + url, _, sdata = smug_url.rpartition(u'#') + jsond = compat_parse_qs(sdata)[u'__youtubedl_smuggle'][0] + data = json.loads(jsond) + return url, data |