From fa5df4c16cba83e12464878acb79c64c4b6cec59 Mon Sep 17 00:00:00 2001 From: Emi Date: Sat, 5 Jul 2025 22:47:37 -0300 Subject: [PATCH] first commit to linux --- requirements.txt | 2 +- script.py | 64 +++++++++++++++++++++++++++++++----------------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/requirements.txt b/requirements.txt index f13d1cd..e4c71bf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,4 @@ opencv-python==4.11.0.86 pillow==11.3.0 PyAutoGUI==0.9.54 -keyboard==0.13.5 +pynput==0.13.5 diff --git a/script.py b/script.py index 968177a..9547613 100644 --- a/script.py +++ b/script.py @@ -1,17 +1,35 @@ import pyautogui as pgui import time -import keyboard as kb +from pynput import keyboard as kb -# colocar el nombre de tu navegador, basado en el nombre de la imagen de su respectivo icono -browser = 'brave' -browser_loc = pgui.locateCenterOnScreen(f'img/{browser}.png', confidence=0.8) +quit = False + +def on_press_to_quit(key): + """ + Quit program if 'q' is pressed + """ + global quit + try: + if key.char == 'q': + print('closing program') + quit = True + except AttributeError: + pass + +listener = kb.Listener(on_press=on_press_to_quit) +listener.start() + +# Enter the name of your browser, based on the name of its icon image. +browser_img = 'brave.png' + +browser_loc = pgui.locateCenterOnScreen(f'img/{browser_img}', confidence=0.8) pgui.moveTo(browser_loc, duration=0.2) time.sleep(0.2) pgui.click() -# cambia el tiempo dependiendo de cuanto tarde en abrir tu navegador +# Change the time depending on how long it takes to open your browser time.sleep(2) @@ -22,27 +40,29 @@ pgui.write('https://www.youtube.com/playlist?list=WL') time.sleep(0.05) pgui.press("enter") -# cambiar dependiendo de cuanto tarde en cargarte yt +# change depending on how long it takes to load yt time.sleep(5) -videos = int(input('number of videos: ')) -while videos != 0: +if __name__ == '__main__': + while not quit: - if kb.is_pressed('q'): - print(':(') - break - - opt_loc = pgui.locateCenterOnScreen('img/options.png', confidence=0.8) + opt_loc = pgui.locateCenterOnScreen('img/options.png', confidence=0.8) - pgui.moveTo(opt_loc, duration=0.2) - pgui.click() - time.sleep(0.2) + if opt_loc: + pgui.moveTo(opt_loc, duration=0.2) + pgui.click() + time.sleep(0.2) + else: + print('options button not founded') + break - del_loc = pgui.locateCenterOnScreen('img/delete.png', confidence=0.8) + del_loc = pgui.locateCenterOnScreen('img/delete.png', confidence=0.8) - pgui.moveTo(del_loc, duration=0.2) - pgui.click() - time.sleep(0.2) - - videos -= 1 + if del_loc: + pgui.moveTo(del_loc, duration=0.2) + pgui.click() + time.sleep(0.2) + else: + print('delete button not founded') + break \ No newline at end of file