From 93d34f9d8846cd76e405ba29ac4f33788b77b8c1 Mon Sep 17 00:00:00 2001 From: balibell Date: Wed, 14 Mar 2018 17:10:27 +0800 Subject: [PATCH] add new patterns for play parameters; add new patterns for title; update payload to v2; --- youtube_dl/extractor/bilibili.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/youtube_dl/extractor/bilibili.py b/youtube_dl/extractor/bilibili.py index beffcecd0..a2240b900 100644 --- a/youtube_dl/extractor/bilibili.py +++ b/youtube_dl/extractor/bilibili.py @@ -94,6 +94,7 @@ class BiliBiliIE(InfoExtractor): if 'anime/' not in url: cid = compat_parse_qs(self._search_regex( [r'EmbedPlayer\([^)]+,\s*"([^"]+)"\)', + r'EmbedPlayer\([^)]+,\s*\\"([^"]+)\\"\)', r']+src="https://secure\.bilibili\.com/secure,([^"]+)"'], webpage, 'player parameters'))['cid'][0] else: @@ -114,7 +115,8 @@ class BiliBiliIE(InfoExtractor): self._report_error(js) cid = js['result']['cid'] - payload = 'appkey=%s&cid=%s&otype=json&quality=2&type=mp4' % (self._APP_KEY, cid) + + payload = 'appkey=%s&cid=%s&otype=json&qn=0&quality=0&type=' % (self._APP_KEY, cid) sign = hashlib.md5((payload + self._BILIBILI_KEY).encode('utf-8')).hexdigest() headers = { @@ -123,7 +125,7 @@ class BiliBiliIE(InfoExtractor): headers.update(self.geo_verification_headers()) video_info = self._download_json( - 'http://interface.bilibili.com/playurl?%s&sign=%s' % (payload, sign), + 'http://interface.bilibili.com/v2/playurl?%s&sign=%s' % (payload, sign), video_id, note='Downloading video info page', headers=headers) @@ -157,7 +159,7 @@ class BiliBiliIE(InfoExtractor): 'formats': formats, }) - title = self._html_search_regex(']*>([^<]+)', webpage, 'title') + title = self._html_search_regex(['

]*>', ']*>([^<]+)

'], webpage, 'title') description = self._html_search_meta('description', webpage) timestamp = unified_timestamp(self._html_search_regex( r']+datetime="([^"]+)"', webpage, 'upload time', default=None))