diff options
author | remitamine <remitamine@gmail.com> | 2016-03-03 18:34:52 +0100 |
---|---|---|
committer | remitamine <remitamine@gmail.com> | 2016-03-03 18:34:52 +0100 |
commit | 38f9ef31dc434a6702686844b421085955137c55 (patch) | |
tree | 853f3fea3ca91b0dafebe72be7cbcf6c2efc2e85 /youtube_dl/utils.py | |
parent | fa9e259fd91ce1bf31310330adc20ddef2b1d948 (diff) |
[utils] add update_url_query function
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 210c47fce..31d60f323 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -1719,6 +1719,14 @@ def urlencode_postdata(*args, **kargs): return compat_urllib_parse.urlencode(*args, **kargs).encode('ascii') +def update_url_query(url, query): + parsed_url = compat_urlparse.urlparse(url) + qs = compat_parse_qs(parsed_url.query) + qs.update(query) + return compat_urlparse.urlunparse(parsed_url._replace( + query=compat_urllib_parse.urlencode(qs, True))) + + def encode_dict(d, encoding='utf-8'): def encode(v): return v.encode(encoding) if isinstance(v, compat_basestring) else v |