【发布时间】:2020-11-03 20:54:10
【问题描述】:
我正在尝试使用 pytube 从 Youtube 下载,首先我遇到了一个常见问题,我认为这是模块本身的问题,所以我使用 github 对其进行了升级,然后此代码中出现了另一个错误:
#importing the module
from pytube import YouTube
#where to Save
save_path = "E:\Mohamed's sessions\pytube"
#link of the youtube video to be downloaded
link = "https://www.youtube.com/watch?v=w9TcErzdoTg"
#creating an object using YouTube which was imported beofre
yt = YouTube(link) # now this yt is an object created by the class youtube and has the attribute link
#filtering out all the files with mp4 extinsion
mp4files = yt.filter("mp4")
#setting the video name
yt.set_filename("Reiner and Bertholdt Transformation scene")
#get the video with the extension and resolution passed in the get() function
d_video = yt.get(mp4files[-1].extension,mp4files[-1].resolution)
try:
#downloading the video
d_video.download(save_path)
except:
print("Some Error!")
print('Task Completed!')
错误标题是: AttributeError:“YouTube”对象没有属性“过滤器” 我该如何解决?
【问题讨论】:
-
如果查看文档,应该是
yt.streams.filter()python-pytube.readthedocs.io/en/latest