属性错误:属性对象没有属性'对象'
关于代码:使用Pytube
下载YouTube视频。
代码:
from pytube import YouTube
import pytube
SAVE_PATH = "c:users\pavit\Desktop" #to_do
link=input("enter the link")
try:
# object creation using YouTube
# which was imported in the beginning
yt = YouTube(link)
except:
print("Connection Error") #to handle exception
mp4files = YouTube.streams.filter()
yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution')[-1].download()
d_video = yt.get(mp4files[-1].extension,mp4files[-1].resolution)
try:
d_video.download(SAVE_PATH)
except:
print("Some Error!")
print('Task Completed!')
错误:
Traceback (most recent call last):
File "C:\Users\pavit\AppData\Local\Programs\Python\Python310\python programs\collegepro.py", line 18, in <module>
mp4files = YouTube.streams.filter()
AttributeError: 'property' object has no attribute 'filter'
更新:我使用yt.streams.filter()
。在这种情况下,我有另一个错误说:
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
About the code: download youtube video using pytube
.
Code:
from pytube import YouTube
import pytube
SAVE_PATH = "c:users\pavit\Desktop" #to_do
link=input("enter the link")
try:
# object creation using YouTube
# which was imported in the beginning
yt = YouTube(link)
except:
print("Connection Error") #to handle exception
mp4files = YouTube.streams.filter()
yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution')[-1].download()
d_video = yt.get(mp4files[-1].extension,mp4files[-1].resolution)
try:
d_video.download(SAVE_PATH)
except:
print("Some Error!")
print('Task Completed!')
Error:
Traceback (most recent call last):
File "C:\Users\pavit\AppData\Local\Programs\Python\Python310\python programs\collegepro.py", line 18, in <module>
mp4files = YouTube.streams.filter()
AttributeError: 'property' object has no attribute 'filter'
Update: I used yt.streams.filter()
. In this case I got another error saying:
pytube.exceptions.RegexMatchError: get_throttling_function_name: could not find match for multiple
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论