属性错误:属性对象没有属性'对象'

发布于 2025-01-23 18:47:21 字数 1180 浏览 3 评论 0原文

关于代码:使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文