gpt4 book ai didi

python-2.7 - Pytube 正则表达式匹配错误

转载 作者:行者123 更新时间:2023-12-03 05:22:55 24 4
gpt4 key购买 nike

我正在尝试在 python 中编写脚本,提示用户在命令行上输入 youtube 链接。然后应该下载此链接

from pytube import YouTube

downloadFile = raw_input("Enter your Youtube link: ")
YouTube(downloadFile).streams.first().download()

但是,当在命令行上输入链接时,我得到以下信息:
File "dl.py", line 10, in <module>
YouTube(downloadFile).streams.first().download()
File "build/bdist.linux-x86_64/egg/pytube/__main__.py", line 69, in __init__
File "build/bdist.linux-x86_64/egg/pytube/extract.py", line 43, in video_id
File "build/bdist.linux-x86_64/egg/pytube/helpers.py", line 39, in regex_search
pytube.exceptions.RegexMatchError: regex pattern ((?:v=|\/)([0-9A-Za-z_-]{11}).*) had zero matches

我可以通过 python interpeter 让它工作。

欢迎任何建议!

最佳答案

好的,经过一番 Root 之后,这似乎可以解决问题

import sys # import sys 
import pytube

link = raw_input('Please enter a url link\n')
yt = pytube.YouTube(link)
stream = yt.streams.first()
finished = stream.download()
print 'Download is complete'

sys.exit()

关于python-2.7 - Pytube 正则表达式匹配错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52190699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com