Skip to content

Commit 261f468

Browse files
fix: #45 fetch all videos of a playlist
1 parent d69a959 commit 261f468

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

mps_youtube/commands/local_playlist.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def save_last():
104104

105105
# save using artist name in postion 1
106106
if g.model:
107-
saveas = g.pafy_pls[g.selected_pafy_pls_id][0]['info']['title']
107+
saveas = g.pafy_pls[g.selected_pafy_pls_id][0].info['info']['title']
108108
saveas = re.sub(r"[^-\w]", "-", saveas, flags=re.UNICODE)
109109

110110
# loop to find next available name
@@ -153,7 +153,7 @@ def open_save_view(action, name):
153153
g.content = content.generate_songlist_display()
154154

155155
else:
156-
g.userpl[name] = Playlist(name, [Video(i['id'], i['title'], parse_video_length(i['duration'])) for i in g.pafy_pls[g.selected_pafy_pls_id][0]['videos']])
156+
g.userpl[name] = Playlist(name, [Video(i['id'], i['title'], parse_video_length(i['duration'])) for i in g.pafy_pls[g.selected_pafy_pls_id][0].videos])
157157
g.message = util.F('pl saved') % name
158158
playlists.save()
159159
g.content = content.generate_songlist_display()

mps_youtube/commands/songlist.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ def plist(parturl):
8484
else:
8585
util.dbg("%sFetching playlist using pafy%s", c.y, c.w)
8686
ytpl = pafy.get_playlist(parturl)
87-
plitems = util.IterSlicer(ytpl['videos'])
87+
plitems = util.IterSlicer(ytpl.videos)
8888
g.pafy_pls[parturl] = (ytpl, plitems)
8989

9090
def pl_seg(s, e):
9191
return [Video(i['id'], i['title'], util.parse_video_length(i['duration'])) for i in plitems[s:e]]
9292

93-
msg = "Showing YouTube playlist %s" % (c.y + ytpl['info']['title'] + c.w)
93+
msg = "Showing YouTube playlist %s" % (c.y + ytpl.info['info']['title'] + c.w)
9494
loadmsg = "Retrieving YouTube playlist"
95-
paginatesongs(pl_seg, length=len(ytpl['videos']), msg=msg, loadmsg=loadmsg)
95+
paginatesongs(pl_seg, length=len(ytpl.videos), msg=msg, loadmsg=loadmsg)
9696

9797

9898
@command(r'(rm|add)\s*(-?\d[-,\d\s]{,250})', 'rm', 'add')

mps_youtube/pafy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ def get_playlist(playlist_id):
9090
Get all videos of a playlist identified by playlist_id
9191
'''
9292

93-
playlist = Playlist.get('https://www.youtube.com/playlist?list=%s' % playlist_id)
93+
playlist = Playlist('https://www.youtube.com/playlist?list=%s' % playlist_id)
94+
while playlist.hasMoreVideos:
95+
playlist.getNextVideos()
9496
return playlist
9597

9698
def get_video_title_suggestions(query):

0 commit comments

Comments
 (0)