question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to download youtube playlist info using youtube-dl in a python program?

See original GitHub issue

Checklist

  • [x ] I’m asking a question
  • [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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
silverbacknetcommented, Jun 24, 2019

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.

1reaction
dstftwcommented, Jun 23, 2019

Arguments are bools not strings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Download Youtube Video(s) or whole Playlist with Python
Download Selected Video From YouTube Playlist · First, we will fetch all video link from the YouTube playlist using the pyyoutube module. ·...
Read more >
youtube-dl only extract playlist info - Stack Overflow
You can import youtube_dl ,invoke youtube_dl as ydl and set download=False, here is an example download = False ydl_opts = { 'outtmpl': ...
Read more >
YouTube download using youtube-dl embedded with Python
Downloading YouTube, Vimeo etc Videos using youtube-dl, Using youtube-dl embedded with Python. ... In this tutorial, we'll call it from our Python code....
Read more >
Download a whole YouTube Playlist at one go
For detailed information, you can go through the Docs. Youtube-dl. "Program to download videos from YouTube.com and other video sites" - Pypi.
Read more >
Python script to download youtube videos/playlists/channels
Set the default path to where ever you want to store your videos. · Set the rate limit to your prefered limit (Usefull...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found