使用 pytube python 列出 YouTube 播放列表 URL
List YouTube playlist URLs using pytube python
我已经搜索了该主题,并且正在尝试找到一种方法来列出特定播放器的 URL 或链接。
这是我得到的但对我不起作用
import re
from pytube import Playlist
playlist = Playlist("https://www.youtube.com/playlist?list=PL6gx4Cwl9DGCkg2uj3PxUWhMDuTw3VKjM")
playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")
print('Number of videos in playlist: %s' % len(playlist.video_urls))
for url in playlist.video_urls:
print(url)
我得到了0个视频。
知道如何使此代码工作吗?
这是另一个应该从播放列表下载所有链接的代码
from pytube import Playlist
try:
playlist = Playlist('https://www.youtube.com/playlist?list=PLcow8_btriE11hzMbT3-B1sBg4YIc-9g_')
playlist.download_all(download_path='./Videos')
except Exception as e:
print(e)
但是我得到了这个'Playlist' object has no attribute 'download_all'
这很适合我
from pytube import Playlist
playlist = Playlist('https://www.youtube.com/watch?v=EWdNhA5prXQ&list=PLRhWUdOnZHklr5GcNBO7dDsTspk85M8eH')
print('Number Of Videos In playlist: %s' % len(playlist.video_urls))
for video in playlist.videos:
video.streams.first().download()
我已经搜索了该主题,并且正在尝试找到一种方法来列出特定播放器的 URL 或链接。 这是我得到的但对我不起作用
import re
from pytube import Playlist
playlist = Playlist("https://www.youtube.com/playlist?list=PL6gx4Cwl9DGCkg2uj3PxUWhMDuTw3VKjM")
playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")
print('Number of videos in playlist: %s' % len(playlist.video_urls))
for url in playlist.video_urls:
print(url)
我得到了0个视频。 知道如何使此代码工作吗?
这是另一个应该从播放列表下载所有链接的代码
from pytube import Playlist
try:
playlist = Playlist('https://www.youtube.com/playlist?list=PLcow8_btriE11hzMbT3-B1sBg4YIc-9g_')
playlist.download_all(download_path='./Videos')
except Exception as e:
print(e)
但是我得到了这个'Playlist' object has no attribute 'download_all'
这很适合我
from pytube import Playlist
playlist = Playlist('https://www.youtube.com/watch?v=EWdNhA5prXQ&list=PLRhWUdOnZHklr5GcNBO7dDsTspk85M8eH')
print('Number Of Videos In playlist: %s' % len(playlist.video_urls))
for video in playlist.videos:
video.streams.first().download()