aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2015-12-20 06:26:26 +0600
committerSergey M․ <dstftw@gmail.com>2015-12-20 06:26:26 +0600
commit8e60dc7526596f456c0b5d7dc48daa6cae08ebb6 (patch)
tree37390b79004ebc74e98237d1941d5e05f4835643 /youtube_dl/utils.py
parent8900ab4d9bc6bf8a05a1a2608efaff08561945e8 (diff)
[utils] Add encode_compat_str
Diffstat (limited to 'youtube_dl/utils.py')
-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 6d3119760..9a2dd1439 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1712,6 +1712,10 @@ def encode_dict(d, encoding='utf-8'):
return dict((encode(k), encode(v)) for k, v in d.items())
+def encode_compat_str(string, encoding=preferredencoding(), errors='strict'):
+ return string if isinstance(string, compat_str) else compat_str(string, encoding, errors)
+
+
US_RATINGS = {
'G': 0,
'PG': 10,