2

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

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

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

4

3 回答 3

3

根据他们 github 页面上的这个问题,您可以使用get_playlist2()

于 2017-12-31T00:50:23.347 回答
1

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

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
于 2020-01-21T10:52:58.373 回答
-3
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)
于 2019-08-06T15:11:57.590 回答