1
+ from tkinter import *
2
+ from pytube import YouTube
3
+ from PIL import ImageTk , Image
4
+ from tkinter import filedialog
5
+ from tkinter import messagebox
6
+
7
+ app = Tk ()
8
+
9
+ app .title ("YouTube Downloader" )
10
+
11
+ app .geometry ("800x600" )
12
+
13
+ app .config (background = "white" )
14
+
15
+ app .resizable (False , False )
16
+
17
+ img = ImageTk .PhotoImage (Image .open ("Yt.png" ))
18
+ imglabel = Label (app , image = img ).grid (row = 5 , column = 1 )
19
+
20
+ def setURL ():
21
+ url = getURL .get ()
22
+ print (url )
23
+
24
+ global yt
25
+ yt = YouTube (url )
26
+ print (yt .title )
27
+
28
+ global videos
29
+ videos = yt .streams .filter (mime_type = 'video/mp4' ).all ()
30
+
31
+ count = 1
32
+ for v in videos :
33
+ listbox .insert (END , str (count )+ ". " + str (v )+ "\n \n " )
34
+ count += 1
35
+
36
+ def Download_Function ():
37
+ if (getURL .get () == "" ):
38
+ messagebox .showinfo ("ERROR" , "ENTER url " )
39
+ return
40
+ elif (getLoc .get () == "" ):
41
+ messagebox .showinfo ("ERROR" , "ENTER LOCATION " )
42
+ return
43
+
44
+ select = listbox .curselection ()
45
+ quality = videos [select [0 ]]
46
+ location = getLoc .get ()
47
+ quality .download (location )
48
+ messagebox .showinfo ("Downloading Finish" , yt .title + " has been downloaded Sucessfully!!!" )
49
+
50
+
51
+ def clickBrowse ():
52
+ location_of_download = filedialog .askdirectory ()
53
+ getLoc .set (location_of_download )
54
+
55
+ def clickReset ():
56
+ getURL .set ("" )
57
+ getLoc .set ("" )
58
+ listbox .delete (0 ,END )
59
+
60
+ headLabel = Label (app , text = "YOUTUBE VIDEO DOWNLOADER" , font = ("Comic Sans MS" ,25 )).grid (row = 0 , column = 1 , padx = 10 , pady = 10 )
61
+ urlLabel = Label (app , text = "URL" , font = ("Comic Sans MS" ,15 )).grid (row = 1 , column = 0 , padx = 10 , pady = 10 )
62
+ qualityLabel = Label (app , text = "SELECT QUALITY" , font = ("Comic Sans MS" ,15 )).grid (row = 2 , column = 0 , padx = 10 , pady = 10 )
63
+ locLabel = Label (app , text = "LOCATION" , font = ("Comic Sans MS" ,15 )).grid (row = 3 , column = 0 , padx = 10 , pady = 10 )
64
+
65
+ getURL = StringVar ()
66
+ getLoc = StringVar ()
67
+
68
+ urlEntry = Entry (app , font = ("Century Gothic" ,12 ), textvariable = getURL , width = 50 , bd = 3 , relief = SOLID , borderwidth = 1 ).grid (row = 1 ,column = 1 , padx = 10 , pady = 10 )
69
+ locEntry = Entry (app , font = ("Century Gothic" ,12 ), textvariable = getLoc , width = 50 , bd = 3 , relief = SOLID , borderwidth = 1 ).grid (row = 3 ,column = 1 , padx = 10 , pady = 10 )
70
+
71
+ listbox = Listbox (app , font = ("Century Gothic" ,11 ), width = 56 , height = 12 , bd = 3 , relief = SOLID , borderwidth = 1 )
72
+ listbox .grid (row = 2 ,column = 1 , padx = 10 , pady = 10 )
73
+
74
+ urlButton = Button (app , text = "SET URL" , font = ("Comic Sans MS" ,10 ), width = 15 , relief = SOLID , borderwidth = 1 , command = setURL ).grid (row = 1 , column = 2 , padx = 10 , pady = 10 )
75
+ browseButton = Button (app , text = "BROWSE" , font = ("Comic Sans MS" ,10 ), width = 15 , relief = SOLID , borderwidth = 1 , command = clickBrowse ).grid (row = 3 , column = 2 , padx = 10 , pady = 10 )
76
+ downloadButton = Button (app , text = "DOWNLOAD" , font = ("Comic Sans MS" ,10 ), width = 15 , relief = SOLID , borderwidth = 1 , command = Download_Function ).grid (row = 4 , column = 1 , padx = 10 , pady = 10 )
77
+ resetButton = Button (app , text = "CLEAR ALL" , font = ("Comic Sans MS" ,10 ), width = 15 , relief = SOLID , borderwidth = 1 , command = clickReset ).grid (row = 4 , column = 2 , padx = 10 , pady = 10 )
78
+
79
+
80
+ app .mainloop ()
0 commit comments