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

Get number of videos in a Playlist? #4238

Open
edumj opened this issue Nov 19, 2014 · 3 comments
Open

Get number of videos in a Playlist? #4238

edumj opened this issue Nov 19, 2014 · 3 comments

Comments

@edumj
Copy link

@edumj edumj commented Nov 19, 2014

Hi,

I'm writing a batch file to auto download videos just copying url to clipborad, but I need to know how many videos are in one playlist to make a loop (i'm making a loop to get video %(height)s for each video and save to a file to compare with the real height).

I've seen in the json file, that it's stored in the "n_entries" var.

Could you add a "--playlist-n_entries" option, or a "%(playlist_n_entries)s" output?

Thanks!

@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented Nov 19, 2014

I don't know if this is what you want, but you can use jq for that:
youtube-dl "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re" -J --flat-playlist | jq ".entries | length" will print 3.

If that's now what you want, could you explain how do you want to get the length?

@edumj
Copy link
Author

@edumj edumj commented Nov 21, 2014

Thanks, it Works!

But, because I don't know how to save the resolution of a video into a variable, I do ths:
youtube-dl.exe "%var_link%" -o "%%(height)s" --get-filename>%ruta_altura%
And I get a text file with the height in it, and then I load this into the var.
If there were an option to get directly the num of entries, I wolud get the num of videos the same way (I supose I have to do the same with jq), and It wouldn't be necessary to add another .exe to my project. Anyway, this jq program seems helpful, if I learn how it Works ;-)

Edu.

@blueray453
Copy link

@blueray453 blueray453 commented Apr 9, 2019

youtube-dl "https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re" --flat-playlist --playlist-end 1

The output has the following string -

Collected N video ids

This N is the number of videos in that playlist.

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.