def test_bilibil(self): bilibili.download( "https://www.bilibili.com/watchlater/#/BV1PE411q7mZ/p6", info_only=True) bilibili.download( "https://www.bilibili.com/watchlater/#/av74906671/p6", info_only=True)
def test_bilibili(self): bilibili.download( 'https://www.bilibili.com/video/av16907446/', info_only=True ) bilibili.download( 'https://www.bilibili.com/video/av13228063/', info_only=True )
def get_info(self, url): video_urls = [] # 获取缩略图 response = requests.get(url=url, headers=self.header).text # 类型为str duration = int(re.search(r'(?<="timelength":).*?(?=,)', response).group()) # 获取时长 pic_url = re.search(r'(?<=itemprop="image" content=").*?(?=">)', response).group(0) pic = requests.get(url=pic_url, headers=self.header).content # 获取封面图 with open('./temp/pic.jpg', 'wb') as f: f.write(pic) info = eval(bilibili.download(url, json_output=True)) name = info['title'] for i in info['streams'].values(): q = i['quality'][3:] + ' ' + i['container'] temp = [url, q, i['size'], i['src'][0]] # 分别为视频原地址,视频质量,大小,下载地址 video_urls.append(temp) return name, duration, video_urls
def download_bilibili_video(bv): download(bilibili_url(bv), output_dir='/download', merge=True) return site.title