JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
http://pytubefix.rtfd.io/
MIT License
674 stars 95 forks source link

Add oauth to Playlist class. #enhancement #139

Closed anAwesomeWave closed 3 months ago

anAwesomeWave commented 3 months ago

My problem I had a problem with Playlist class. When I tried to download the video, I got an error 'requires login to view' image My solution was to apply use_patch to all videos in the playlist

p = Playlist(input("enter yt playlist url:"))

for video in p.videos: 
    video.use_oauth=True
    video.allow_oauth_cache = True
    ...

But it is more convenient for users to have 2 additional argument in Playlists inititalizator (Just like in Youtube class) and pass them to Youtube class.

My solution Add 2 default arguments use_oauth: bool = False, allow_oauth_cache: bool = True, to Playlist initializer. Like that:

p = Playlist(input("enter yt playlist url:"), use_oauth=True)

for v in p.videos:
    print(v.title)
    ys = v.streams.get_audio_only()
    ys.download(output_path='test', mp3=True)

Example image