Merge branch 'bangumi-no-dash' of https://github.com/chrisww/you-get into chrisww-bangumi-no-dash

This commit is contained in:
Mort Yao 2020-07-19 16:12:03 +02:00
commit be8d298344
No known key found for this signature in database
GPG Key ID: 07DA00CB78203251

View File

@ -81,8 +81,8 @@ class Bilibili(VideoExtractor):
return 'https://www.bilibili.com/audio/music-service-c/web/song/of-menu?sid=%s&pn=1&ps=%s' % (sid, ps) return 'https://www.bilibili.com/audio/music-service-c/web/song/of-menu?sid=%s&pn=1&ps=%s' % (sid, ps)
@staticmethod @staticmethod
def bilibili_bangumi_api(avid, cid, ep_id, qn=0): def bilibili_bangumi_api(avid, cid, ep_id, qn=0, fnval=16):
return 'https://api.bilibili.com/pgc/player/web/playurl?avid=%s&cid=%s&qn=%s&type=&otype=json&ep_id=%s&fnver=0&fnval=16' % (avid, cid, qn, ep_id) return 'https://api.bilibili.com/pgc/player/web/playurl?avid=%s&cid=%s&qn=%s&type=&otype=json&ep_id=%s&fnver=0&fnval=%s' % (avid, cid, qn, ep_id, fnval)
@staticmethod @staticmethod
def bilibili_interface_api(cid, qn=0): def bilibili_interface_api(cid, qn=0):
@ -316,15 +316,16 @@ class Bilibili(VideoExtractor):
return return
current_quality = api_playinfo['result']['quality'] current_quality = api_playinfo['result']['quality']
# get alternative formats from API # get alternative formats from API
for qn in [120, 112, 80, 64, 32, 16]: for fnval in [8, 16]:
# automatic format for durl: qn=0 for qn in [120, 112, 80, 64, 32, 16]:
# for dash, qn does not matter # automatic format for durl: qn=0
if qn != current_quality: # for dash, qn does not matter
api_url = self.bilibili_bangumi_api(avid, cid, ep_id, qn=qn) if qn != current_quality:
api_content = get_content(api_url, headers=self.bilibili_headers(referer=self.url)) api_url = self.bilibili_bangumi_api(avid, cid, ep_id, qn=qn, fnval=fnval)
api_playinfo = json.loads(api_content) api_content = get_content(api_url, headers=self.bilibili_headers(referer=self.url))
if api_playinfo['code'] == 0: # success api_playinfo = json.loads(api_content)
playinfos.append(api_playinfo) if api_playinfo['code'] == 0: # success
playinfos.append(api_playinfo)
for playinfo in playinfos: for playinfo in playinfos:
if 'durl' in playinfo['result']: if 'durl' in playinfo['result']: