diff --git a/src/you_get/extractors/bilibili.py b/src/you_get/extractors/bilibili.py index a696b398..644c5af4 100644 --- a/src/you_get/extractors/bilibili.py +++ b/src/you_get/extractors/bilibili.py @@ -181,7 +181,7 @@ class Bilibili(VideoExtractor): self.download_playlist_by_url(self.url, **kwargs) return - # regular av video + # regular video if sort == 'video': initial_state_text = match1(html_content, r'__INITIAL_STATE__=(.*?);\(function\(\)') # FIXME initial_state = json.loads(initial_state_text) @@ -601,13 +601,21 @@ class Bilibili(VideoExtractor): log.e('[Error] Unsupported URL pattern.') exit(1) - # regular av video + # regular video if sort == 'video': initial_state_text = match1(html_content, r'__INITIAL_STATE__=(.*?);\(function\(\)') # FIXME initial_state = json.loads(initial_state_text) aid = initial_state['videoData']['aid'] pn = initial_state['videoData']['videos'] - if pn!= len(initial_state['videoData']['pages']):#interaction video 互动视频 + + if pn == len(initial_state['videoData']['pages']): + # non-interative video + for pi in range(1, pn + 1): + purl = 'https://www.bilibili.com/video/av%s?p=%s' % (aid, pi) + self.__class__().download_by_url(purl, **kwargs) + + else: + # interative video search_node_list = [] download_cid_set = set([initial_state['videoData']['cid']]) params = { @@ -658,24 +666,6 @@ class Bilibili(VideoExtractor): self.streams_sorted = [dict([('itag', stream_type['itag'])] + list(self.streams[stream_type['itag']].items())) for stream_type in self.__class__.stream_types if stream_type['itag'] in self.streams] self.extract(**kwargs) self.download(**kwargs) - else: - playinfo_text = match1(html_content, r'__playinfo__=(.*?)