瀏覽代碼

Strip hash info from URL when making requests (Fixes #1038)

Philipp Hagemeister 12 年之前
父節點
當前提交
b9d3e1635f
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      youtube_dl/extractor/common.py

+ 5 - 0
youtube_dl/extractor/common.py

@@ -125,6 +125,11 @@ class InfoExtractor(object):
 
     def _download_webpage_handle(self, url_or_request, video_id, note=None, errnote=None):
         """ Returns a tuple (page content as string, URL handle) """
+
+        # Strip hashes from the URL (#1038)
+        if isinstance(url_or_request, (compat_str, str)):
+            url_or_request = url_or_request.partition('#')[0]
+
         urlh = self._request_webpage(url_or_request, video_id, note, errnote)
         content_type = urlh.headers.get('Content-Type', '')
         m = re.match(r'[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+\s*;\s*charset=(.+)', content_type)