def download_video(self, url, filename): if PathUtil.check_path(filename): PathUtil.remove(filename) retry_times = 2 while retry_times > 0: try: request = BilibiliApi.build_video_download_request(url) response = RequestUtil.do_request(request, load_json=False, stream=True) self.before_response(response) self.save_video(response.raw_response, filename) break except: print( f'{filename} download fail, retry times = {retry_times}, restart...' ) retry_times -= 1 if retry_times == 0: raise Exception('retry times exceed, stop downloading...') continue
def merge_video(self, output, *files): if PathUtil.check_path(output): PathUtil.remove(output) return print('正在尝试合并视频,请参考控制台输出') FFmpegUtil(CONFIG['FFMPEG_PATH']).merge(*files, output=output)