about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMantas Mikulėnas <grawity@nullroute.eu.org>2012-01-16 12:05:59 +0200
committerMantas Mikulėnas <grawity@nullroute.eu.org>2012-01-16 12:08:01 +0200
commit4afdff39d74d25f5b7b09822361ed49f4a9ee2cd (patch)
tree2eaf05a71f50321fabb8bf06d2e8c2609a007dbf
parent661a807c65a154eccdddb875b45e4782ca86132c (diff)
downloadyoutube-dl-4afdff39d74d25f5b7b09822361ed49f4a9ee2cd.tar.gz
youtube-dl-4afdff39d74d25f5b7b09822361ed49f4a9ee2cd.tar.xz
youtube-dl-4afdff39d74d25f5b7b09822361ed49f4a9ee2cd.zip
Support Unicode in file names on Windows NT
-rwxr-xr-xyoutube_dl/__init__.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index be599a2b2..52da3b859 100755
--- 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.