你如何使用 pytube 从 youtube 下载播放列表?

How do you download a playlist from youtube using pytube?

我使用不同的代码成功下载了单个视频,但是当我尝试使用其他代码从 youtube 下载整个播放列表时,出现错误。

这是我使用的代码:

from pytube import Playlist
playlist = Playlist('https://www.youtube.com/playlist?list=UUd6MoB9NC6uYN2grvUNT-Zg')
print('Number of videos in playlist: %s' % len(playlist.video_urls))
playlist.download_all()

这是我得到的错误:

Traceback (most recent call last):
  File "/Users/thelostprogrammer/PycharmProjects/youtube/tests.py", line 5, in <module>
    playlist.download_all("/Users/thelostprogrammer/downloads")
AttributeError: 'Playlist' object has no attribute 'download_all'
Number of videos in playlist: 12216

有人可以帮我吗?

download_all 方法已弃用,执行此操作:

from pytube import Playlist
play_list = Playlist('PAYLIST LINK')
for video in play_list.videos:
    video.streams.first().download()

请检查此 link ->

from pytube import Playlist

playlist = Playlist(Playlist link goes here)
playlist.download_all()

from pytube import Playlist

playlist = Playlist(Playlist link goes here)
for video in playlist.videos:
    video.streams.first().download()