blob: e2a371e3e43352470bb94471e8e30fa89caf9ef0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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!")
|