修复acfun的视频下载

This commit is contained in:
xiaohe 2019-11-20 23:07:23 +08:00
parent 61b74e3ce9
commit b82d1be079
2 changed files with 15 additions and 4 deletions

View File

@ -121,8 +121,16 @@ def acfun_download(url, output_dir='.', merge=True, info_only=False, **kwargs):
video_list = json_data.get('videoList') video_list = json_data.get('videoList')
if len(video_list) > 1: if len(video_list) > 1:
title += " - " + [p.get('title') for p in video_list if p.get('id') == vid][0] title += " - " + [p.get('title') for p in video_list if p.get('id') == vid][0]
currentVideoInfo = json_data.get('currentVideoInfo')
m3u8_url = json_data.get('currentVideoInfo')['playInfos'][0]['playUrls'][0] if 'playInfos' in currentVideoInfo:
m3u8_url = currentVideoInfo['playInfos'][0]['playUrls'][0]
elif 'ksPlayJson' in currentVideoInfo:
ksPlayJson = json.loads( currentVideoInfo['ksPlayJson'] )
representation = ksPlayJson.get('adaptationSet').get('representation')
reps = []
for one in representation:
reps.append( (one['width']* one['height'], one['url'], one['backupUrl']) )
m3u8_url = max(reps)[1]
elif re.match("https?://[^\.]*\.*acfun\.[^\.]+/bangumi/ab(\d+)", url): elif re.match("https?://[^\.]*\.*acfun\.[^\.]+/bangumi/ab(\d+)", url):
html = get_content(url, headers=fake_headers) html = get_content(url, headers=fake_headers)

View File

@ -6,7 +6,8 @@ from you_get.extractors import (
imgur, imgur,
magisto, magisto,
youtube, youtube,
missevan missevan,
acfun
) )
@ -38,6 +39,8 @@ class YouGetTests(unittest.TestCase):
info_only=True info_only=True
) )
def test_acfun(self):
acfun.download('https://www.acfun.cn/v/ac11701912', info_only=True)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()