url_grabber 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/env python3
  2. # Uruk Video Downloader (UVD)
  3. #
  4. # Copyright 2020 hayder majid <hayder@riseup.net>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 2 of the License, or
  9. # (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19. # MA 02110-1301, USA.
  20. #
  21. #
  22. from tkinter import *
  23. from tkinter import filedialog
  24. from tkinter import messagebox
  25. import subprocess
  26. import os
  27. gui=Tk()
  28. gui.resizable(False, False)
  29. gui.configure(background='#f5f6fa')
  30. gui.title("Uruk Video Downloader")
  31. gui.iconphoto(True, PhotoImage(file='/usr/share/pixmaps/uvd.png'))
  32. def sMenu(e):
  33. w = e.widget
  34. menu.entryconfigure("Cut", command=lambda: w.event_generate("<<Cut>>"))
  35. menu.entryconfigure("Copy", command=lambda: w.event_generate("<<Copy>>"))
  36. menu.entryconfigure("Paste", command=lambda: w.event_generate("<<Paste>>"))
  37. menu.tk.call("tk_popup", menu, e.x_root, e.y_root)
  38. def cMenu(w):
  39. global menu
  40. menu = Menu(w, tearoff=0)
  41. menu.add_command(label="Cut")
  42. menu.add_command(label="Copy")
  43. menu.add_command(label="Paste")
  44. def fileRead():
  45. global outPath
  46. folderPath = os.environ['HOME']+'/.uvd'
  47. outDir = open(folderPath+'/outPath.txt', "r")
  48. outPath = str(outDir.readline())
  49. outDir.close()
  50. def url_input():
  51. inputValue=textBox.get("1.0","end-1c")
  52. fileRead()
  53. os.system("xterm -e aria2c -c -x 2 -d "+(outPath)+" "+(inputValue))
  54. messagebox.showinfo(title="Download Complete", message="Your download is complete!")
  55. def eClear():
  56. textBox.delete('1.0', END)
  57. textBox.update()
  58. labelWindow = Label(gui,text = "Uruk URL Grabber \n -------------------------------------------", fg = "#636e72", bg='#f5f6fa', font=('broadway', 14))
  59. labelWindow.grid(column=1, row=0, padx=10, pady=10)
  60. labelPlist = Label(gui,text = "Past Your\n URL Here -->", fg = "#636e72", bg='#f5f6fa')
  61. labelPlist.grid(column=0, row=1, padx=1)
  62. textBox=Text(gui, height=1, width=55, borderwidth=0, bg='#c8d6e5')
  63. textBox.grid(column=1, row=1, padx=1)
  64. buttonDls=Button(gui, height=2, width=13, text="Clear Entry", fg='white', bg='#5599ff', borderwidth=0, command=lambda: eClear())
  65. buttonDls.grid(column=2, row=1, padx=2)
  66. buttonD=Button(gui, height=2, width=13, text="Download", fg='white', bg='#5599ff', borderwidth=0, command=lambda: url_input())
  67. buttonD.grid(column=1, row=2, padx=2)
  68. cMenu(gui)
  69. textBox.bind_class("Text", "<Button-3><ButtonRelease-3>", sMenu)
  70. menubar = Menu(gui)
  71. gui.geometry("690x230")
  72. mainloop()