You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[x ] I've looked through the README and FAQ for similar questions
[x ] I've searched the bugtracker for similar questions including closed ones
Question
I'm trying to download info about all items in a youtube playlist. I've figured out the command to execute on the terminal but I'm unable to figure out its equivalent code when embedded in a python program.
Here's the terminal command I use : youtube-dl --dump-single-json --flat-playlist PLFftu4DSZBSwrGiOlZXKHRSoKArsKSuz9 > /Users/abhimanyu/Desktop/list.json
Here's how far I got in embedded python :
import youtube_dl
ydl = youtube_dl.YoutubeDL({'dump_single_json': 'True',
'extract_flat' : 'True'})
with ydl:
result = ydl.download([
'https://www.youtube.com/playlist?list=PLFftu4DSZBSwrGiOlZXKHRSoKArsKSuz9'])
print(len(result))
I also tried ydl.extract_info but that starts fetching info about each video individually which I don't need.
The text was updated successfully, but these errors were encountered:
kuwapa
changed the title
How to download youtube playlist using youtube-dl in a python program?
How to download youtube playlist info using youtube-dl in a python program?
Jun 23, 2019
Hey @dstftw, I'm stuck again. I'm unable to capture the json output into a variable. In the current code, result only has a value of 0 and not the json which I was expecting. How do I do that?
When downloading, 0 means success. Anything else means an error. (Classic C behavior.)
You were on the right track, result = ydl.extract_info(url, False) should give what you want. Default is to download everything, which you don't want, thus download=False.
Checklist
Question
I'm trying to download info about all items in a youtube playlist. I've figured out the command to execute on the terminal but I'm unable to figure out its equivalent code when embedded in a python program.
Here's the terminal command I use :
youtube-dl --dump-single-json --flat-playlist PLFftu4DSZBSwrGiOlZXKHRSoKArsKSuz9 > /Users/abhimanyu/Desktop/list.json
Here's how far I got in embedded python :
I also tried
ydl.extract_info
but that starts fetching info about each video individually which I don't need.The text was updated successfully, but these errors were encountered: