commit 99d46e8c276c6705b2b0fee9cf4660e56ae825be parent 661a807c65a154eccdddb875b45e4782ca86132c Author: Philipp Hagemeister <phihag@phihag.de> Date: Mon, 16 Jan 2012 03:23:22 -0800 Merge pull request #275 from grawity/winnt-unicode Support Unicode in file names on Windows NT Diffstat:
M | youtube_dl/__init__.py | | | 9 | ++++++++- |
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py @@ -305,7 +305,14 @@ def _encodeFilename(s): """ assert type(s) == type(u'') - return s.encode(sys.getfilesystemencoding(), 'ignore') + + if sys.platform == 'win32' and sys.getwindowsversion().major >= 5: + # Pass u'' directly to use Unicode APIs on Windows 2000 and up + # (Detecting Windows NT 4 is tricky because 'major >= 4' would + # match Windows 9x series as well. Besides, NT 4 is obsolete.) + return s + else: + return s.encode(sys.getfilesystemencoding(), 'ignore') class DownloadError(Exception): """Download Error exception.