aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-09-06 07:22:20 +0600
committerSergey M․ <dstftw@gmail.com>2015-09-06 07:22:20 +0600
commit1639282434c77f4de005fb0a6b81a49425e64d08 (patch)
treef782f95b040dff305a62c6e2b27e5c8818e29fd4
parentbe0e5dbd8356e92f8032d4cf8be2e668f1b30539 (diff)
downloadyoutube-dl-1639282434c77f4de005fb0a6b81a49425e64d08.tar.xz
[utils] Add encode_dict
-rw-r--r--youtube_dl/utils.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 7cf91ac19..5529d5291 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1638,6 +1638,10 @@ def urlencode_postdata(*args, **kargs):
return compat_urllib_parse.urlencode(*args, **kargs).encode('ascii')
+def encode_dict(d, encoding='utf-8'):
+ return dict((k.encode(encoding), v.encode(encoding)) for k, v in d.items())
+
+
try:
etree_iter = xml.etree.ElementTree.Element.iter
except AttributeError: # Python <=2.6