无法使用 pafy 获得完整的播放列表

Can't get a full playlist with pafy

我正在尝试获取播放列表中所有视频的网址。 播放列表包含 700 多个视频。

当我使用 pafy.get_playlist 创建播放列表时,它只会创建一个包含 194 个视频的数组,而不是全部。

那么 pafy 的播放列表有大小限制吗?

根据他们 github 页面上的 issue,您可以使用 get_playlist2()

import os
from pafy import get_playlist
import pafy
from pafy import *
from socket import *

name_pc=gethostname()
var2=name_pc.split("-")[0] # ex: ("document-PC") -> ["document","PC"]to get #name pc 

os.chdir(r"C:\Users\"+var2+"\Downloads")
vobj=get_playlist(str(input("Enter a URL :")))

down_path=str(input("Enter a Dir ?: "))


for video in range(len(vobj['items'])):
     down=vobj['items'][video]['pafy'].getbest() # to get all items for item in playlist
     if 1:
          t=r"C:\Users\"+var2+"\Downloads"
          down.download(t)
     else:
          down.download(down_path)

大家好这是我的第一个回答:)
你可以使用 get_playlist2() 作为@JalxP said
只需检查下面的代码并 运行 它。
我认为它应该可以解决问题 谢谢!

import pafy
import sys
import time
url = sys.argv[1] # takes the playlist link as argument
details = pafy.get_playlist(url)
playlist = pafy.get_playlist2(url)
# below three statements print the tilte,author and number of videos
print(details['title'])
print(details['author'])
print(len(playlist))
# path to store the videos
userpath = input("enter path to save the playlist:")
# you can modify this for loop for a particular range of videos 
# this a bare-bone
# this loop downloads all the videos in the playlist
for item in range(len(playlist)):
    url = playlist[item].getbest()
    url.download(userpath)
    time.sleep(3)# just to not make immediate download calls