mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[utils] add update_url_query function
This commit is contained in:
parent
fa9e259fd9
commit
38f9ef31dc
2 changed files with 8 additions and 8 deletions
|
@ -20,7 +20,6 @@
|
|||
compat_urllib_error,
|
||||
compat_urllib_parse,
|
||||
compat_urlparse,
|
||||
compat_parse_qs,
|
||||
compat_str,
|
||||
compat_etree_fromstring,
|
||||
)
|
||||
|
@ -518,13 +517,6 @@ def _parse_json(self, json_string, video_id, transform_source=None, fatal=True):
|
|||
else:
|
||||
self.report_warning(errmsg + str(ve))
|
||||
|
||||
def update_url_params(self, url, params):
|
||||
parsed_url = compat_urlparse.urlparse(url)
|
||||
qs = compat_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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue