From: Sergey M․ Date: Sun, 20 Dec 2015 00:26:26 +0000 (+0600) Subject: [utils] Add encode_compat_str X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=8e60dc7526596f456c0b5d7dc48daa6cae08ebb6;p=youtube-dl [utils] Add encode_compat_str --- 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,