[acfun] Fix test cases

This commit is contained in:
johnsmith2077 2020-10-07 02:39:21 +08:00
parent 345bd3b026
commit d96564c350

View File

@ -70,10 +70,10 @@ class AcfunIE(BasicAcfunInfoExtractor):
"note": "single video in playlist", "note": "single video in playlist",
"url": "https://www.acfun.cn/v/ac17532274_3", "url": "https://www.acfun.cn/v/ac17532274_3",
"info_dict": { "info_dict": {
"id": "17532274", "id": "17532274_3",
"ext": "mp4", "ext": "mp4",
"duration": 233.770, "duration": 233.770,
"title": "【AC娘x竾颜音】【周六狂欢24小时】TRAP七夕恋歌落入本娘爱的陷阱 - TRAP 阿婵", "title": "【AC娘x竾颜音】【周六狂欢24小时】TRAP七夕恋歌落入本娘爱的陷阱-TRAP 阿婵",
"uploader": "AC娘本体", "uploader": "AC娘本体",
"uploader_id": 23682490, "uploader_id": 23682490,
}, },
@ -87,8 +87,8 @@ class AcfunIE(BasicAcfunInfoExtractor):
"uploader": "AC娘本体", "uploader": "AC娘本体",
"uploader_id": 23682490, "uploader_id": 23682490,
}, },
"playlist_count": 5 "playlist_count": 5,
} },
] ]
def _real_extract(self, url): def _real_extract(self, url):
@ -106,26 +106,36 @@ class AcfunIE(BasicAcfunInfoExtractor):
uploader = str_or_none(json_data.get("user").get("name")) uploader = str_or_none(json_data.get("user").get("name"))
uploader_id = str_to_int(json_data.get("user").get("id")) uploader_id = str_to_int(json_data.get("user").get("id"))
videoList = json_data.get('videoList') videoList = json_data.get("videoList")
if videoList: if videoList:
video_num = len(videoList) video_num = len(videoList)
if not page_id and video_num and video_num > 1: if not page_id and video_num and video_num > 1:
if not self._downloader.params.get('noplaylist'): if not self._downloader.params.get("noplaylist"):
self.to_screen('Downloading all pages %s - add --no-playlist to just download video' % video_id) self.to_screen(
entries = [self.url_result( "Downloading all pages %s - add --no-playlist to just download video"
'%s_%d' % (url, pid), % video_id
)
entries = [
self.url_result(
"%s_%d" % (url, pid),
self.IE_NAME, self.IE_NAME,
video_id='%s_%d' % (video_id, pid)) video_id="%s_%d" % (video_id, pid),
for pid in range(1, video_num+1)] )
for pid in range(1, video_num + 1)
]
playlist = self.playlist_result(entries, video_id, title) playlist = self.playlist_result(entries, video_id, title)
playlist.update({ playlist.update(
'uploader': uploader, {
'uploader_id': uploader_id, "uploader": uploader,
}) "uploader_id": uploader_id,
}
)
return playlist return playlist
self.to_screen('Downloading just video %s because of --no-playlist' % video_id) self.to_screen(
"Downloading just video %s because of --no-playlist" % video_id
)
p_title = self._html_search_regex( p_title = self._html_search_regex(
r"<li\s[^<]*?class='[^']*active[^']*'.*?>(.*?)</li>", r"<li\s[^<]*?class='[^']*active[^']*'.*?>(.*?)</li>",