mirror of https://github.com/yt-dlp/yt-dlp.git
Improve preferred encoding detection method
This commit is contained in:
parent
0833f1eb83
commit
f94b636c3e
18
youtube-dl
18
youtube-dl
|
@ -33,15 +33,15 @@ def preferredencoding():
|
||||||
Returns the best encoding scheme for the system, based on
|
Returns the best encoding scheme for the system, based on
|
||||||
locale.getpreferredencoding() and some further tweaks.
|
locale.getpreferredencoding() and some further tweaks.
|
||||||
"""
|
"""
|
||||||
try:
|
def yield_preferredencoding():
|
||||||
pref = locale.getpreferredencoding()
|
try:
|
||||||
# Mac OSX systems have this problem sometimes
|
pref = locale.getpreferredencoding()
|
||||||
if pref == '':
|
u'TEST'.encode(pref)
|
||||||
return 'UTF-8'
|
except:
|
||||||
return pref
|
pref = 'UTF-8'
|
||||||
except:
|
while True:
|
||||||
sys.stderr.write('WARNING: problem obtaining preferred encoding. Falling back to UTF-8.\n')
|
yield pref
|
||||||
return 'UTF-8'
|
return yield_preferredencoding().next()
|
||||||
|
|
||||||
class DownloadError(Exception):
|
class DownloadError(Exception):
|
||||||
"""Download Error exception.
|
"""Download Error exception.
|
||||||
|
|
Loading…
Reference in New Issue