diff --git a/google_drive_direct_link_tkinter.py b/google_drive_direct_link_tkinter.py new file mode 100644 index 0000000..2685d5c --- /dev/null +++ b/google_drive_direct_link_tkinter.py @@ -0,0 +1,36 @@ +import tkinter as tk +import re + +window = tk.Tk() +window.geometry("900x600") +window.title("Genera Direct Link Google Drive") +window.grid_columnconfigure(0,weight=1) + +def gdrive(): + GDRIVE_DOMAIN = "drive.google.com" + if GDRIVE_DOMAIN in text_input.get(): + domain = "GD" + text_response = text_input.get() + file_id = re.search('/d/(.+?)/view',text_response) + if file_id: + file_gdrive = file_id.group(1) + else: + direct_url = "Errore" + DLINK = "https://drive.google.com/uc?export=view&id=" + direct_url = DLINK + file_gdrive + else: + direct_url = "Il link inserito non sembra essere un link Google Drive!" + textwidget = tk.Text() + textwidget.insert(tk.END,direct_url) + textwidget.grid(row=3,column=0,sticky="WE",padx=20) + + +welcome_label = tk.Label(window,text="Aggiungi un Link Google Drive") +welcome_label.grid(row=0,column=0,sticky="N",pady=20) +text_input = tk.Entry() +text_input.grid(row=1,column=0,sticky="WE",padx=10) +generate_gdrive_link = tk.Button(text="Genera Direct Link Google Drive",command=gdrive) +generate_gdrive_link.grid(row=2,column=0,sticky="WE",pady=20,padx=10) + +if __name__ == "__main__": + window.mainloop() \ No newline at end of file