Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to get all the videos link in a playlist #6945

Closed
niltsh opened this issue Sep 24, 2015 · 3 comments
Closed

[Question] How to get all the videos link in a playlist #6945

niltsh opened this issue Sep 24, 2015 · 3 comments

Comments

@niltsh
Copy link

@niltsh niltsh commented Sep 24, 2015

If it is a duplication, please let me know.

I am now trying to integrate this great SW into my multimedia player.
I could now successfully get the URL and title of the video, by using -g and -e.

Now I am trying to add the playlist support into the player.
And I want to confirm how to achieve following

  1. How to understand whether a link is a playlist or single video?
  2. How to list all the links of the videos contained in the playlist? Don't have to decode all the links, but need the list quickly.

Currently, just using -g could list all the decoded URLs, but it takes a long time to finish, looks like youtube-dl is extracting each video's link one by one.

I wonder if there is any quick way to get all the links, even not to extract the real URL but the encoded ones.

Thank you.

BRs,
Zongyao Qu

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Sep 24, 2015

  1. Playlist has _type field that equals playlist in dictionary.
  2. Use --flat-playlist --dump-single-json or --flat-playlist --dump-json. There is a url field in each video's dictionary. Note that it may not be a real URL but a youtube-dl shortcut (e.g. nrk:203298) or smuggled URL.
@dstftw dstftw closed this Sep 24, 2015
@niltsh
Copy link
Author

@niltsh niltsh commented Sep 25, 2015

Hi Sergey

_type

​What do you mean the "_type"? How I could find this entry, in what
dictionary?

Best Regards,
Zongyao QU

2015-09-24 23:15 GMT+09:00 Sergey M. notifications@github.com:

Closed #6945 #6945.


Reply to this email directly or view it on GitHub
#6945 (comment).

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Sep 25, 2015

For example:

$ youtube-dl 'https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re' --flat-playlist --dump-single-json  | jq .
{
  "extractor": "youtube:playlist",
  "entries": [
    {
      "id": "bV9L5Ht9LgY",
      "url": "bV9L5Ht9LgY",
      "_type": "url",
      "ie_key": "Youtube"
    },
    {
      "id": "FXxLjLQi3Fg",
      "url": "FXxLjLQi3Fg",
      "_type": "url",
      "ie_key": "Youtube"
    },
    {
      "id": "tU3Bgo5qJZE",
      "url": "tU3Bgo5qJZE",
      "_type": "url",
      "ie_key": "Youtube"
    }
  ],
  "_type": "playlist",
  "webpage_url_basename": "playlist",
  "webpage_url": "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re",
  "id": "PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re",
  "extractor_key": "YoutubePlaylist",
  "title": "ytdl test PL"
}

It returns a single json object with the playlist info. The entries field contains the urls of the videos that can be used with youtube-dl to get the full info (if you remove --flat-playlist you get the info, but the final urls may have expired when you try to play them).

You may want to have a look at how mpv calls youtube-dl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.