From ec20f38c826d1e4d8f63e1bf9fb37c8e2ebb2003 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Sat, 3 Dec 2022 19:22:44 +0000 Subject: [PATCH] Handle nested playlists --- youtube-channel-list.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/youtube-channel-list.py b/youtube-channel-list.py index 8761d9f..a7dbfae 100644 --- a/youtube-channel-list.py +++ b/youtube-channel-list.py @@ -1,3 +1,4 @@ +import collections import sys import yt_dlp @@ -5,5 +6,11 @@ import yt_dlp with yt_dlp.YoutubeDL({'quiet': True}) as ydl: ie = ydl.get_info_extractor('YoutubeTab') for url in sys.argv[1:]: - for entry in ie.extract(url)['entries']: - print(entry['id']) + q = collections.deque() + q.append(ie.extract(url)) + while q: + e = q.popleft() + if 'entries' in e: + q.extend(e['entries']) + elif 'id' in e: + print(e['id'])