This little script just dowanloads the music of a given youtube-url.
Maybe you have to install some stuff like:
pip install yt_dlp
pip install tkinter
import tkinter as tk
from tkinter import messagebox
import yt_dlp
def download_audio():
url = entry.get().strip()
if not url:
messagebox.showwarning("Fehler", "Bitte gib einen YouTube-Link ein.")
return
ydl_opts = {
'format': 'bestaudio/best',
'outtmpl': '%(title)s.%(ext)s',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
'noplaylist': True # Nur einzelnes Video, keine Playlists
}
try:
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
messagebox.showinfo("Erfolg", f"Audio wurde erfolgreich als MP3 heruntergeladen!")
except Exception as e:
messagebox.showerror("Fehler", f"Download fehlgeschlagen:\n{str(e)}")
# GUI erstellen
root = tk.Tk()
root.title("YouTube Audio Downloader (MP3)")
root.geometry("460x160")
root.resizable(False, False)
label = tk.Label(root, text="YouTube-Link eingeben:")
label.pack(pady=10)
entry = tk.Entry(root, width=55)
entry.pack(pady=5)
download_button = tk.Button(root, text="Audio herunterladen", command=download_audio)
download_button.pack(pady=15)
root.mainloop()