aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorremitamine <remitamine@gmail.com>2016-03-03 19:24:04 +0100
committerremitamine <remitamine@gmail.com>2016-03-03 19:24:04 +0100
commit12557339453e25dbb18dfc51dc1e88ca5325d8e9 (patch)
tree037c493326e3967c16fb69746853e181ac7f8a44 /youtube_dl/utils.py
parentd0ff690d68016f24d8cc90e69fac20847e7afa8e (diff)
parent3201a67f618f3bb7b13b4df2a9c7f68f481940a4 (diff)
Merge pull request #8739 from remitamine/update_url_params
[utils] add update_url_query function to create or update query string params
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 91c9d8200..d431aa6b7 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1739,6 +1739,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