Closed jhone888 closed 5 months ago
Thank you for the contribution, but I'm not really sure what to do with your code. I don't think this interfaces with any part of this project and is probably outside the scope of open-in-mpv.
I encourage you to publish it as your own project, I'm sure someone will find it very useful!
Feature Description
Basically, I just made a code.
Now the interface has a simple Gui that shows the waiting list. When "Ctrl+Shif+C" Is pressed, the GUI will open again.
Additional Context (optional)
Saving as a .py and run the code. And it worked! The YouTube link opens automatically
Code Snippet (optional)
Little new updade
import tkinter as tk from tkinter import ttk import threading import time import pyperclip import subprocess from pytube import YouTube import keyboard # Importe o módulo keyboard import signal
signal.signal(signal.SIGINT, signal.SIG_IGN)
class YoutubeVideoManager: def init(self): self.waiting_urls = [] self.executed_urls = set() self.executing_index = -1 self.mpv_process = None self.lock = threading.Lock() self.running = True self.gui_closed = False
def add_to_waiting_list(url_entry, manager): url = url_entry.get() if url and url not in manager.executed_urls and url not in [item[0] for item in manager.waiting_urls]: yt = YouTube(url) title = yt.title manager.waiting_urls.append((url, title)) update_waiting_list(manager) url_entry.delete(0, tk.END) if manager.gui_closed: # Verifica se o GUI está minimizado manager.restore_gui() # Restaura o GUI
def start_video(manager): if manager.executing_index == -1: selected_index = manager.waiting_list.curselection() if selected_index: manager.executing_index = selectedindex[0] url, = manager.waiting_urls[manager.executing_index] print("Iniciando vídeo:", url) manager.open_youtube_video(url)
def next_video(manager): if manager.mpv_process and manager.mpv_process.poll() is None: manager.mpv_process.terminate() manager.mpv_process.wait() if manager.executing_index < len(manager.waiting_urls) - 1: manager.executingindex += 1 url, = manager.waiting_urls[manager.executing_index] print("Próximo vídeo:", url) manager.open_youtube_video(url)
def previous_video(manager): if manager.mpv_process and manager.mpv_process.poll() is None: manager.mpv_process.terminate() manager.mpv_process.wait() if manager.executing_index > 0: manager.executingindex -= 1 url, = manager.waiting_urls[manager.executing_index] print("Vídeo anterior:", url) manager.open_youtube_video(url)
def delete_url(manager): selected_index = manager.waiting_list.curselection() if selected_index: index = int(selected_index[0]) manager.delete_url(index) update_waiting_list(manager)
def update_waiting_list(manager): manager.waiting_list.delete(0, tk.END) if manager.executing_index >= 0: manager.waiting_list.insert(tk.END, "Execução: " + manager.waiting_urls[manager.executing_index][1]) for i, (url, title) in enumerate(manager.waiting_urls): if i != manager.executing_index: manager.waiting_list.insert(tk.END, f"Lista de Espera: {title} - {url}")
def main():
Criar a interface gráfica
if name == "main": main()