pytube / pytube

A lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos.
https://pytube.io
The Unlicense
10.59k stars 2.34k forks source link

Pull all Playlists from playlist_url #1941

Open rebelfish opened 3 weeks ago

rebelfish commented 3 weeks ago

Is your feature request related to a problem? Please describe. I have a feature request to easily capture a list of all playlists titles and URLs on a playlist page

Describe the solution you'd like Just as we can use Playlist to point to a specific playlist url and capture a list of the URLs in the Playlist, I would like to capture a list of Playlists from the channel.playlists_url as an object. from that object, I could cycle through each of the Playlist URLs to capture all metadata associated with the Playlist object. i.e. get the title of the playlist, author, description and list of URLs in the playlist.

The Channel object can find the playlists_url but I can't find a way to cycle through the playlists/videos on that page.

github-actions[bot] commented 3 weeks ago

Thank you for contributing to PyTube. Please remember to reference Contributing.md

wyattZarkLab commented 3 weeks ago

I've done something like this, at least getting the Playlist IDs (name and other metadata can then be recovered with a playlist object)... this was my approach, starting with the playlists_html attribute of the playlist's parent channel object:

PLAYLISTS_RE = re.compile(r'playlist\?list=([^\s\"]+)"')

def getPlaylistsFromChannel(channelObj):
    return PLAYLISTS_RE.findall(channelObj.playlists_html)