12
1
Challenge
Given a Youtube playlist, output the number of videos in it.
I/O
The playlist will be given as an URL; for example, https://www.youtube.com/playlist?list=PL_3jnZNPYn7qUatgDYBS5NShkfXoehSRC
(this is a playlist a friend sent me to try to get me to listen to K-Pop because she's obsessed with it and I don't like it :P)
The link to a playlist is of the form https://www.youtube.com/playlist?list=<id>
. The input is the URL, not the ID.
The output is to be a single integer indicating how many videos are in this playlist. You can either output the total number of videos or the number of non-deleted videos, whichever one is more golfy for you.
Test Cases
https://www.youtube.com/playlist?list=PL_3jnZNPYn7qUatgDYBS5NShkfXoehSRC -> 12
https://www.youtube.com/playlist?list=PLIEbITAtGBebWGyBZQlkiMXwt30WqG9Bd -> 114 OR 1
Feel free to add more test cases.
6Hats off for finding the sneakiest way of asking people to make you a library to count videos in a YouTube playlist. – Stevoisiak – 2017-05-25T17:47:07.807
2I just resisted the urge to add a rickroll playlist. Or the "Dank Memes" playlist. – CAD97 – 2017-05-25T20:29:08.490
Off topic: I'd be more interested in a way list all videos a youtube channel has to offer. The source code doesnt seem to include this naturally. – phil294 – 2017-06-13T11:24:38.110
@Blauhirn That's an interesting idea. Maybe you could make a challenge about that. – HyperNeutrino – 2017-06-13T12:00:33.067