无法通过pafy获得完整的播放列表

时间:2017-11-27 11:26:09

标签: python pafy

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

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

播放列表是否有pafy的大小限制?

3 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:0)

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

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

答案 2 :(得分:-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)