Closed mohammadnaushad closed 4 years ago
@mohammadnaushad what exactly do you mean by "playlist support"?
It means .. if someone passes a url which belongs to a playlist like https://youtu.be/HdGp3-R6LEc?list=PLFRPNUj0az6RFv9HH7UgLIAGmXSfQXHxH He should be able to download the video or should be able to fetch all the video details in the playlist. Like all the video links in that playlist so that one can then send the link to download the video
@naushad3210 I don't have spare time to implement this feature, probably for next few weeks. But PRs are welcomed
Hello,
I found 2 options, both use the window["ytInitialData"]
JSON section.
(Document and JSON sizes from an actual test suggested by @naushad3210)
Use the watch page
https://www.youtube.com/watch?v=<video_id>&list=<playlist_id>
contents.twoColumnWatchNextResults.playlist.playlist.contents[]
Use the playlist page
https://www.youtube.com/playlist?list=<playlist_id>
contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].playlistVideoListRenderer.contents[]
Once the final "contents" elements are available, each video data can be retrieved via playlistPanelVideoRenderer
:
videoId
title.simpleText
lengthSeconds
I think 2. is the best approach for a getPlaylist(String id)
method that returns a basic video list and let the user choose.
Let me know if it's OK, I'll try to get back with a PR.
@Grodou Great, thank you for your research. I believe second approach is more suitable (as it is parsed from playlist page) despite its deep hierarchy. This implementation could be usefull, have a look. Will be glad to see your PR.
Thanks for the suggestion, I actually made a first version based on this implementation. It works fine (get playlist details, get all videos), but does not have any "download" functionality yet. I'll make a PR (so you can tell if everything's fine or not), and complete it later.
Do you have any plans for playlist support?