fix bilibili extraction (closes #15171)
authorLuca Steeb <contact@luca-steeb.com>
Sat, 6 Jan 2018 19:27:26 +0000 (20:27 +0100)
committerChih-Hsuan Yen <yan12125@gmail.com>
Sun, 7 Jan 2018 17:30:04 +0000 (01:30 +0800)
youtube_dl/extractor/bilibili.py

index 1e57310d657fee2c47cb8e63a9868a36724f0f6a..beffcecd09f55ad4bd5365639ffb2d0459a624f2 100644 (file)
@@ -102,6 +102,7 @@ class BiliBiliIE(InfoExtractor):
                     video_id, anime_id, compat_urlparse.urljoin(url, '//bangumi.bilibili.com/anime/%s' % anime_id)))
             headers = {
                 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
+                'Referer': url
             }
             headers.update(self.geo_verification_headers())
 
@@ -116,10 +117,15 @@ class BiliBiliIE(InfoExtractor):
         payload = 'appkey=%s&cid=%s&otype=json&quality=2&type=mp4' % (self._APP_KEY, cid)
         sign = hashlib.md5((payload + self._BILIBILI_KEY).encode('utf-8')).hexdigest()
 
+        headers = {
+            'Referer': url
+        }
+        headers.update(self.geo_verification_headers())
+
         video_info = self._download_json(
             'http://interface.bilibili.com/playurl?%s&sign=%s' % (payload, sign),
             video_id, note='Downloading video info page',
-            headers=self.geo_verification_headers())
+            headers=headers)
 
         if 'durl' not in video_info:
             self._report_error(video_info)