diff options
author | remitamine <remitamine@gmail.com> | 2016-03-03 10:27:22 +0100 |
---|---|---|
committer | remitamine <remitamine@gmail.com> | 2016-03-03 10:27:22 +0100 |
commit | f3bdae76de7265475277c265f9fff12cdc59825b (patch) | |
tree | a9d2365c8b2216e18c2cdc6b643c8ef91285a55f | |
parent | 03879ff0547b6d1b96c530075cd99f99b8c74a2b (diff) |
[extractor/common] add update_url_params helper method to add or update query string params
-rw-r--r-- | youtube_dl/extractor/common.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py index 402f2f436..282559597 100644 --- a/youtube_dl/extractor/common.py +++ b/youtube_dl/extractor/common.py @@ -517,6 +517,13 @@ class InfoExtractor(object): else: self.report_warning(errmsg + str(ve)) + def update_url_params(self, url, params): + parsed_url = compat_urlparse.urlparse(url) + qs = compat_urlparse.parse_qs(parsed_url.query) + qs.update(params) + return compat_urlparse.urlunparse( + parsed_url._replace(query=compat_urllib_parse.urlencode(qs, True))) + def report_warning(self, msg, video_id=None): idstr = '' if video_id is None else '%s: ' % video_id self._downloader.report_warning( |