pytube播放列表返回空数组

时间:2020-10-03 13:43:33

标签: python-3.x playlist pytube

最近 pytube 开始返回一个空的播放列表。是什么导致此播放列表为空?

from pytube import Playlist

link = 'https://www.youtube.com/watch? 
v=2HtaIvb61Uk&list=PLu8BgVaWowIG_0omesGRkKXK2mqWqAKXU'

print(Playlist(link))

result: []

此播放列表应返回几个链接。我不知道这是更新问题还是代码错误,但是如果有人知道如何解决它,我将非常感激:)

1 个答案:

答案 0 :(得分:0)

pytube 中似乎还有另一个问题,很可能与YouTube更改其代码有关。下面的代码将输出播放列表中的项目数。

import re
from pytube import Playlist

playlist = Playlist('https://www.youtube.com/watch?v=2HtaIvb61Uk&list=PLu8BgVaWowIG_0omesGRkKXK2mqWqAKXU')
playlist._video_regex = re.compile(r"\"url\":\"(/watch\?v=[\w-]*)")
 
print(len(playlist.video_urls))
#output 14