Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 30b74713af | |||
| 4f823557bc |
+77
-27
@@ -4,12 +4,12 @@ from tkinter import filedialog
|
|||||||
from pytube import YouTube
|
from pytube import YouTube
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
# Speicherort für MP3- und MP4-Dateien
|
# Output directories for MP3 and MP4 files
|
||||||
mp3_output_directory = ""
|
mp3_output_directory = ""
|
||||||
mp4_output_directory = ""
|
mp4_output_directory = ""
|
||||||
|
|
||||||
# Dateinamen für die Speicherung der Verzeichnisse
|
# File name for storing the directories
|
||||||
config_file = "directories.pickle"
|
config_file = "config/directories.pickle"
|
||||||
|
|
||||||
|
|
||||||
def create_directory(directory):
|
def create_directory(directory):
|
||||||
@@ -42,7 +42,7 @@ def load_directories():
|
|||||||
def select_directory(format_type):
|
def select_directory(format_type):
|
||||||
global mp3_output_directory, mp4_output_directory
|
global mp3_output_directory, mp4_output_directory
|
||||||
|
|
||||||
# Dialogfenster für die Auswahl des Ordners öffnen
|
# Open directory selection dialog
|
||||||
directory = filedialog.askdirectory()
|
directory = filedialog.askdirectory()
|
||||||
|
|
||||||
if format_type == "mp3":
|
if format_type == "mp3":
|
||||||
@@ -51,6 +51,56 @@ def select_directory(format_type):
|
|||||||
mp4_output_directory = directory
|
mp4_output_directory = directory
|
||||||
|
|
||||||
|
|
||||||
|
def open_settings():
|
||||||
|
settings_window = tk.Toplevel(window)
|
||||||
|
settings_window.title("Settings")
|
||||||
|
settings_window.geometry("300x200")
|
||||||
|
|
||||||
|
# MP3 output directory selection
|
||||||
|
mp3_label = tk.Label(settings_window, text="MP3 Output Directory:")
|
||||||
|
mp3_label.pack()
|
||||||
|
|
||||||
|
mp3_directory_entry = tk.Entry(settings_window, width=50)
|
||||||
|
mp3_directory_entry.insert(tk.END, mp3_output_directory)
|
||||||
|
mp3_directory_entry.pack()
|
||||||
|
|
||||||
|
def select_mp3_directory():
|
||||||
|
directory = filedialog.askdirectory()
|
||||||
|
mp3_directory_entry.delete(0, tk.END)
|
||||||
|
mp3_directory_entry.insert(tk.END, directory)
|
||||||
|
|
||||||
|
mp3_directory_button = tk.Button(settings_window, text="Select Directory", command=select_mp3_directory)
|
||||||
|
mp3_directory_button.pack()
|
||||||
|
|
||||||
|
# MP4 output directory selection
|
||||||
|
mp4_label = tk.Label(settings_window, text="MP4 Output Directory:")
|
||||||
|
mp4_label.pack()
|
||||||
|
|
||||||
|
mp4_directory_entry = tk.Entry(settings_window, width=50)
|
||||||
|
mp4_directory_entry.insert(tk.END, mp4_output_directory)
|
||||||
|
mp4_directory_entry.pack()
|
||||||
|
|
||||||
|
def select_mp4_directory():
|
||||||
|
directory = filedialog.askdirectory()
|
||||||
|
mp4_directory_entry.delete(0, tk.END)
|
||||||
|
mp4_directory_entry.insert(tk.END, directory)
|
||||||
|
|
||||||
|
mp4_directory_button = tk.Button(settings_window, text="Select Directory", command=select_mp4_directory)
|
||||||
|
mp4_directory_button.pack()
|
||||||
|
|
||||||
|
def save_settings():
|
||||||
|
global mp3_output_directory, mp4_output_directory
|
||||||
|
|
||||||
|
mp3_output_directory = mp3_directory_entry.get()
|
||||||
|
mp4_output_directory = mp4_directory_entry.get()
|
||||||
|
save_directories()
|
||||||
|
settings_window.destroy()
|
||||||
|
|
||||||
|
# Save button
|
||||||
|
save_button = tk.Button(settings_window, text="Save", command=save_settings)
|
||||||
|
save_button.pack()
|
||||||
|
|
||||||
|
|
||||||
def download_video():
|
def download_video():
|
||||||
url = url_entry.get()
|
url = url_entry.get()
|
||||||
save_as_mp3 = mp3_var.get()
|
save_as_mp3 = mp3_var.get()
|
||||||
@@ -91,53 +141,53 @@ def download_video():
|
|||||||
window = tk.Tk()
|
window = tk.Tk()
|
||||||
window.title("YouTube Downloader")
|
window.title("YouTube Downloader")
|
||||||
|
|
||||||
|
# Set background color
|
||||||
|
window.configure(bg="#f0f0f0")
|
||||||
|
|
||||||
# URL entry field
|
# URL entry field
|
||||||
url_label = tk.Label(window, text="YouTube URL:")
|
url_label = tk.Label(window, text="YouTube URL:", bg="#f0f0f0")
|
||||||
url_label.pack()
|
url_label.pack()
|
||||||
url_entry = tk.Entry(window, width=50)
|
url_entry = tk.Entry(window, width=50)
|
||||||
url_entry.pack()
|
url_entry.pack()
|
||||||
|
|
||||||
# Format selection checkboxes
|
# Format selection checkboxes
|
||||||
format_label = tk.Label(window, text="Format:")
|
format_label = tk.Label(window, text="Format:", bg="#f0f0f0")
|
||||||
format_label.pack()
|
format_label.pack()
|
||||||
|
|
||||||
|
format_frame = tk.Frame(window, bg="#f0f0f0")
|
||||||
|
format_frame.pack()
|
||||||
|
|
||||||
mp3_var = tk.IntVar()
|
mp3_var = tk.IntVar()
|
||||||
mp3_checkbox = tk.Checkbutton(window, text=".mp3", variable=mp3_var)
|
mp3_checkbox = tk.Checkbutton(format_frame, text=".mp3", variable=mp3_var, bg="#f0f0f0")
|
||||||
mp3_checkbox.pack()
|
mp3_checkbox.pack(side=tk.LEFT)
|
||||||
|
|
||||||
mp4_var = tk.IntVar()
|
mp4_var = tk.IntVar()
|
||||||
mp4_checkbox = tk.Checkbutton(window, text=".mp4", variable=mp4_var)
|
mp4_checkbox = tk.Checkbutton(format_frame, text=".mp4", variable=mp4_var, bg="#f0f0f0")
|
||||||
mp4_checkbox.pack()
|
mp4_checkbox.pack(side=tk.LEFT)
|
||||||
|
|
||||||
# Video quality selection dropdown
|
# Video quality selection dropdown
|
||||||
quality_label = tk.Label(window, text="Video Quality:")
|
quality_label = tk.Label(window, text="Video Quality:", bg="#f0f0f0")
|
||||||
quality_label.pack()
|
quality_label.pack()
|
||||||
quality_var = tk.StringVar()
|
quality_var = tk.StringVar()
|
||||||
quality_var.set("720p") # Default quality
|
quality_var.set("720p") # Default quality
|
||||||
quality_dropdown = tk.OptionMenu(window, quality_var, "144p", "240p", "360p", "480p", "720p")
|
quality_dropdown = tk.OptionMenu(window, quality_var, "144p", "240p", "360p", "480p", "720p")
|
||||||
|
quality_dropdown.config(bg="#f0f0f0")
|
||||||
quality_dropdown.pack()
|
quality_dropdown.pack()
|
||||||
|
|
||||||
# MP3 output directory selection button
|
|
||||||
mp3_directory_button = tk.Button(window, text="Select MP3 Output Directory",
|
|
||||||
command=lambda: select_directory("mp3"))
|
|
||||||
mp3_directory_button.pack()
|
|
||||||
|
|
||||||
# MP4 output directory selection button
|
|
||||||
mp4_directory_button = tk.Button(window, text="Select MP4 Output Directory",
|
|
||||||
command=lambda: select_directory("mp4"))
|
|
||||||
mp4_directory_button.pack()
|
|
||||||
|
|
||||||
# Download button
|
# Download button
|
||||||
download_button = tk.Button(window, text="Download", command=download_video)
|
download_button = tk.Button(window, text="Download", command=download_video, bg="#4CAF50", fg="white")
|
||||||
download_button.pack()
|
download_button.pack()
|
||||||
|
|
||||||
|
# Settings button
|
||||||
|
settings_button = tk.Button(window, text="⚙️", width=2, command=open_settings, bg="#f0f0f0")
|
||||||
|
settings_button.pack(side=tk.RIGHT, padx=10, pady=10)
|
||||||
|
|
||||||
# Status label
|
# Status label
|
||||||
status_label = tk.Label(window, text="")
|
status_label = tk.Label(window, text="", bg="#f0f0f0")
|
||||||
status_label.pack()
|
status_label.pack()
|
||||||
|
|
||||||
# Load directories
|
# Load directories from config
|
||||||
load_directories()
|
load_directories()
|
||||||
|
|
||||||
# Save directories before closing the window
|
|
||||||
window.protocol("WM_DELETE_WINDOW", lambda: [save_directories(), window.destroy()])
|
|
||||||
|
|
||||||
# Start GUI
|
# Start GUI
|
||||||
window.mainloop()
|
window.mainloop()
|
||||||
|
|||||||
Reference in New Issue
Block a user