我试图建立一个YT视频下载,但我有选择一个具体的决议问题。 到目前为止,我的代码是:
from pytube import YouTube
videoUrl = str(input("Enter videoUrl"))
print("Select 1 if you want to download video or select 2 to download audio only")
def downloadVideo():
yt = YouTube(videoUrl)
(yt.streams.filter(progressive=True).filter(res='1080p').first().download())
print(yt.streams)
def downloadAudio():
yt=YouTube(videoUrl)
(yt.streams.filter(only_audio=True).first().download())
print("Download finished successfully")
userChoice =int(input())
if userChoice == 1:
downloadVideo()
elif userChoice == 2:
downloadAudio()
else:
print("Invalid input")
运行此命令后,出现以下错误:
File xxx, line 17, in <module>
downloadVideo()
File xxx, line 8, in downloadVideo
(yt.streams.filter(progressive=True).filter(res='1080p').first().download())
AttributeError: 'NoneType' object has no attribute 'download'
这个错误有什么解决办法吗?我在谷歌上搜索,但找不到任何有用的东西,可以同时过滤和工作。提前谢谢你的帮助
尝试执行yt.streams。获得最高分辨率() 以获得该视频的最高分辨率
相关问题 更多 >
编程相关推荐