获取最高分辨率函数在pytube中不起作用

2024-05-22 01:32:31 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试使用get_highest_resolution()函数在使用pytube下载时获取视频的最高分辨率时。虽然它在一周前工作正常,但现在却出现了错误

from pytube import YouTube
yt = YouTube('https://youtube.com/watch?v=2lAe1cqCOXo')
ys = yt.streams.get_highest_resolution()
ys.download()

AttributeError : 'nonetype' object has no attribute download

虽然这样做很好:

from pytube import YouTube
yt = YouTube('https://youtube.com/watch?v=2lAe1cqCOXo')
ys = yt.streams.first()
ys.download()

有人知道使用get_highest_resolution()时出错的原因吗


Tags: fromhttpsimportcomgetyoutubedownloadstreams
3条回答

我也有同样的问题,但我使用了progressive=true,它起了作用

 Label(root,text = 'Youtube Video Downloader', font ='arial 20 
 bold',bg="#336B87",pady=10).pack()

 link = StringVar()

 Label(root, text = 'Paste Link Here:', font = 'arial 15 
 bold',bg="#336B87",pady=0).place(x= 150 , y = 60)
 link_enter = Entry(root, width = 70,textvariable = link).place(x = 
 32, y = 90)

 def Downloader():     
 url =YouTube(str(link.get()))
 video = url.streams.filter(progressive=True).last()
 video.download()
 Label(root, text = 'DOWNLOADED', font = 'arial 15').place(x= 180 , y 
 = 210) 
import pytube
a = '=' * 23

print(f"{a}\n\033[0;31mBAIXAR VÍDEO DO YOUTUBE\033[0;0m\n{a}")

video = pytube.YouTube(input('Digite a URL do vídeo: '))
resolucoes = video.streams.all()

for i in resolucoes:  # mostra as resoluções disponíveis
    print(i)

video.streams.get_by_itag(137).download("D:\Downloads YouTube")  # salva na pasta

…你尝试了另一个url

同样的问题,我认识到pytubes get_highest_resolution()似乎并不适用于所有youtube url,但适用于大多数。。(60/40)[如果您的URL都不起作用,请尝试https://pypi.org/project/pytube3/]我认为只有异常处理才能“修复”这个问题

祝大家2021年快乐

相关问题 更多 >