首先需要安装you-get库 再执行代码 import subprocess import concurrent.futures # 视频链接列表 urls = [ # 添加更多的视频链接url ] # 下载路径 output_path = '本地保存路径' # 错误日志路径 error_log_path = '' # 下载视频的函数 def download_video(url): try: command = ['you-get', url, '-o', output_path, '--no-caption', '--debug'] subprocess.call(command) except Exception as e: with open(error_log_path, 'a') as log_file: log_file.write(f"Failed to download {url}: {e}\n") print(f"Failed to download {url}: {e}") # 使用多线程下载视频 with concurrent.futures.ThreadPoolExecutor(max_workers=len(urls)) as executor: futures = [executor.submit(download_video, url) for url in urls] for future in concurrent.futures.as_completed(futures): try: future.result() except Exception as e: print(f"Error occurred: {e}")
在python中简单的使用you-get多线程批量下载视频
于 2024-07-19 09:36:25 首次发布