Mit dem Modul pytube.
from pytube import YouTube
from pytube import Playlist
# URL der YouTube-Playlist
playlist_url = 'https://www.youtube.com/playlist?list=PLYUHroQHA-xTK_PdqAtOosKlgyypcUY6Q'
# Pfad zum Speichern der heruntergeladenen Videos
download_path = 'c:\\videos'
def download_youtube_playlist(url, path):
try:
playlist = Playlist(url)
for video_url in playlist.video_urls:
yt = YouTube(video_url)
video = yt.streams.get_highest_resolution()
video.download(output_path=path)
print(f'Video {yt.title} wurde erfolgreich heruntergeladen.')
except Exception as e:
print(f'Fehler beim Herunterladen der Playlist: {e}')
if __name__ == '__main__':
download_youtube_playlist(playlist_url, download_path)