I is not displayed in real-time Progress of the dvd. Progress bar move to fast.
What I need it do is rip the dvd the Eject it win done and wait dvd the rip. use all dvd drive in the pc.
What I need it do is rip the dvd the Eject it win done and wait dvd the rip. use all dvd drive in the pc.
import os import time import subprocess import threading import tkinter as tk from tkinter import ttk import win32api import win32com.client # Paths OUTPUT_FOLDER = r"C:\Users\crock\Videos" MAKEMKV_PATH = r"C:\Program Files (x86)\MakeMKV\makemkvcon64.exe" HANDBRAKE_PATH = r"C:\Program Files\HandBrake\HandBrakeCLI.exe" HANDBRAKE_PRESET = "Fast 1080p30" CHECK_INTERVAL = 10 # Ensure output folder exists os.makedirs(OUTPUT_FOLDER, exist_ok=True) # GUI Setup root = tk.Tk() root.title("Auto DVD/Blu-ray Ripper") root.geometry("650x500") root.config(bg="#F2F2F2") font = ("Segoe UI", 10) # Button frame button_frame = tk.Frame(root, bg="#F2F2F2") button_frame.pack(pady=10) def start_auto_rip(): global auto_rip auto_rip = True log_message("Auto Rip Started") threading.Thread(target=process_disc, daemon=True).start() def stop_auto_rip(): global auto_rip auto_rip = False log_message("Auto Rip Stopped") # Buttons start_button = tk.Button(button_frame, text="Start Auto Rip", command=start_auto_rip, bg="#4CAF50", fg="white", font=font, relief="flat", padx=15, pady=5) start_button.pack(side=tk.LEFT, padx=10) stop_button = tk.Button(button_frame, text="Stop Auto Rip", command=stop_auto_rip, bg="#F44336", fg="white", font=font, relief="flat", padx=15, pady=5) stop_button.pack(side=tk.LEFT, padx=10) exit_button = tk.Button(button_frame, text="Exit", command=root.quit, bg="#9E9E9E", fg="white", font=font, relief="flat", padx=15, pady=5) exit_button.pack(side=tk.LEFT, padx=10) # Status label & Progress bar progress_var = tk.IntVar() progress_bar = ttk.Progressbar(root, length=400, mode="determinate", variable=progress_var) progress_bar.pack(pady=10) progress_label = tk.Label(root, text="0%", font=("Segoe UI", 12, "bold"), bg="#F2F2F2") progress_label.pack() # Output window log_window = tk.Text(root, height=15, width=80, wrap=tk.WORD, state=tk.DISABLED, font=("Segoe UI", 9)) log_window.pack(pady=10) auto_rip = False def log_message(msg): log_window.config(state=tk.NORMAL) log_window.insert(tk.END, msg + "\n") log_window.see(tk.END) log_window.config(state=tk.DISABLED) root.update() def find_disc_drive(): drives = ["D:\\", "E:\\", "F:\\", "G:\\"] for drive in drives: try: volume_info = win32api.GetVolumeInformation(drive) if volume_info[0]: return drive, volume_info[0] except Exception: pass return None, None def rip_disc(drive, label): log_message(f"Ripping {label} from {drive}...") output_folder = os.path.join(OUTPUT_FOLDER, label) os.makedirs(output_folder, exist_ok=True) command = f'"{MAKEMKV_PATH}" mkv disc:0 all "{output_folder}"' process = subprocess.Popen(command, shell=True) while process.poll() is None: progress_var.set(min(progress_var.get() + 2, 50)) progress_label.config(text=f"{progress_var.get()}%") root.update() time.sleep(5) log_message("Rip Complete!") def convert_to_mp4(label): log_message(f"Converting {label} to MP4...") files = [f for f in os.listdir(OUTPUT_FOLDER) if f.startswith(label) and f.endswith(".mkv")] total_files = len(files) if total_files == 0: log_message("No MKV files found.") return for i, file in enumerate(files): mkv_path = os.path.join(OUTPUT_FOLDER, file) mp4_path = mkv_path.replace(".mkv", ".mp4") command = f'"{HANDBRAKE_PATH}" -i "{mkv_path}" -o "{mp4_path}" --preset "{HANDBRAKE_PRESET}"' subprocess.run(command, shell=True) os.remove(mkv_path) progress_var.set(50 + int(((i + 1) / total_files) * 50)) progress_label.config(text=f"{progress_var.get()}%") log_message(f"Converting {file} to MP4 ({i + 1}/{total_files})") root.update() log_message("Conversion Complete!") progress_var.set(100) progress_label.config(text="100%") def eject_disc(drive): log_message(f"Ejecting {drive}...") shell = win32com.client.Dispatch("Shell.Application") drives = shell.Namespace(17) drive_obj = drives.ParseName(drive) drive_obj.InvokeVerb("Eject") log_message("Eject Complete!") def process_disc(): global auto_rip while auto_rip: drive, label = find_disc_drive() if drive: log_message(f"Detected: {label} in {drive}") rip_disc(drive, label) convert_to_mp4(label) eject_disc(drive) else: log_message("No disc detected. Checking again in 10 seconds...") time.sleep(CHECK_INTERVAL) root.mainloop()