summaryrefslogtreecommitdiff
path: root/python/ytdl/download_playlist.py
diff options
context:
space:
mode:
authorpants <niklasjo2004@gmail.com>2026-09-21 14:17:03 -0700
committerpants <niklasjo2004@gmail.com>2026-09-21 14:17:03 -0700
commit7b21727285e50b0b050c4ddd70d07542229c5366 (patch)
tree5d369153c5df5b41f3750d25479a68f20169c8ff /python/ytdl/download_playlist.py
init
Diffstat (limited to 'python/ytdl/download_playlist.py')
-rw-r--r--python/ytdl/download_playlist.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/python/ytdl/download_playlist.py b/python/ytdl/download_playlist.py
new file mode 100644
index 0000000..e2a371e
--- /dev/null
+++ b/python/ytdl/download_playlist.py
@@ -0,0 +1,27 @@
+from yt_dlp import YoutubeDL
+import os
+
+def download_playlist(playlist_url, output_path):
+ ydl_opts = {
+ 'format': 'bestaudio/best',
+ 'outtmpl': os.path.join(output_path, '%(title)s.%(ext)s'),
+ 'postprocessors': [{
+ 'key': 'FFmpegExtractAudio',
+ 'preferredcodec': 'opus',
+ 'preferredquality': '128',
+ }],
+ 'quiet': True,
+ }
+
+ with YoutubeDL(ydl_opts) as ydl:
+ ydl.download([playlist_url])
+
+if __name__ == "__main__":
+ playlist_url = input("Enter the YouTube Playlist URL: ")
+ output_path = input("Enter the directory to save audio files: ")
+
+ if not os.path.exists(output_path):
+ os.makedirs(output_path)
+
+ download_playlist(playlist_url, output_path)
+ print("Download complete!")