在python中简单的使用you-get多线程批量下载视频

首先需要安装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}")
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值