瀏覽代碼

Deal with implicitly UTF-16 decoded webpages

These webpages don't specify an encoding and rely on the BOM
Philipp Hagemeister 11 年之前
父節點
當前提交
b60016e831
共有 1 個文件被更改,包括 2 次插入0 次删除
  1. 2 0
      youtube_dl/extractor/common.py

+ 2 - 0
youtube_dl/extractor/common.py

@@ -220,6 +220,8 @@ class InfoExtractor(object):
                           webpage_bytes[:1024])
             if m:
                 encoding = m.group(1).decode('ascii')
+            elif webpage_bytes.startswith(b'\xff\xfe'):
+                encoding = 'utf-16'
             else:
                 encoding = 'utf-8'
         if self._downloader.params.get('dump_intermediate_pages', False):