Skip to content

Commit e21c923

Browse files
authored
Merge pull request sanscript-tech#241 from kuldip11/branch1
GUI YouTue Downloader Created
2 parents 5f249c0 + 0c4dd20 commit e21c923

File tree

6 files changed

+170
-0
lines changed

6 files changed

+170
-0
lines changed

Python/GUI_YouTbe_Downloader/GUI.py

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
from tkinter.ttk import *
2+
from pytube import *
3+
from tkinter import *
4+
from tkinter.filedialog import *
5+
from tkinter.messagebox import *
6+
from threading import *
7+
global itaglist
8+
itaglist=[]
9+
10+
def progress(stream=None,chunk=None,remaining=None):
11+
file_downloaded=(file_size - remaining)
12+
per=(file_downloaded / file_size) * 100
13+
downloadButton.config(text="{:00.0f} % downloaded".format(per))
14+
progressBar['value']=per
15+
main.update_idletasks()
16+
17+
def startDownloading():
18+
global file_size
19+
try:
20+
myList.delete(0,END)
21+
#configring Button
22+
searchButton.config(text="Search")
23+
searchButton.config(state=NORMAL)
24+
#featching the urlField
25+
url=urlField.get()
26+
if url=="":
27+
return
28+
#featching the resField
29+
res=resField.get()
30+
if ((res.isdigit())==False or res=="" or res not in itaglist):
31+
showinfo("Wrong Input!!","Please choose the valid Option")
32+
return
33+
downloadButton.config(text="Please wait...")
34+
downloadButton.config(state=DISABLED)
35+
path_to_save_video=askdirectory()
36+
if path_to_save_video is None:
37+
return
38+
39+
ob=YouTube(url, on_progress_callback=progress)
40+
41+
#progressbar
42+
global progressBar
43+
progressBar = Progressbar(main, orient = HORIZONTAL,length = 100, mode = 'determinate')
44+
progressBar.pack(pady = 10)
45+
46+
#resolution selection
47+
strm=ob.streams.get_by_itag(int(res))
48+
49+
#store the size of the file
50+
file_size=strm.filesize
51+
52+
# show the Title
53+
vTitle.config(text=strm.title)
54+
vTitle.pack(side=TOP)
55+
56+
#download video
57+
strm.download(path_to_save_video)
58+
59+
#configring Button
60+
downloadButton.config(text="Download")
61+
downloadButton.config(state=NORMAL)
62+
63+
# clear urlField , resField , taglist and processBar
64+
urlField.delete(0,END)
65+
resField.delete(0,END)
66+
progressBar.pack_forget()
67+
taglist=[]
68+
69+
#remove title from main
70+
vTitle.pack_forget()
71+
showinfo("Download Fineshed","Downloaded Successfully")
72+
73+
except Exception as e:
74+
print(e)
75+
print("error!!")
76+
77+
78+
#searching for diffrent resolutions
79+
def resolution():
80+
searchButton.config(text="Please wait...")
81+
searchButton.config(state=DISABLED)
82+
youtubeLink=urlField.get()
83+
youtubeObj=YouTube(youtubeLink)
84+
global file
85+
file=youtubeObj.streams
86+
87+
#sb=Scrollbar()
88+
#sb.pack(side=RIGHT,fill=Y)
89+
myList.pack(side=BOTTOM,ipadx=100,pady=5)
90+
91+
myList.insert(END,"id res size")
92+
93+
94+
for num in file:
95+
myList.insert(END,str(num.itag)+" "+str(num.resolution)+" "+str(num.filesize/1000000)+" MB")
96+
itaglist.append(str(num.itag))
97+
98+
#sb.config(command=mylist.yview)
99+
100+
#creat new thread
101+
def startSearchingThread():
102+
thread1=Thread(target=resolution)
103+
thread1.start()
104+
def startDownloadThread():
105+
thread2=Thread(target=startDownloading)
106+
thread2.start()
107+
108+
109+
if __name__=="__main__":
110+
# GUI
111+
main=Tk()
112+
main.geometry("600x7000")
113+
114+
# Title
115+
main.title("YouTube Video Downloader")
116+
117+
# Icon
118+
main.iconbitmap("you_tube.ico")
119+
120+
file=PhotoImage(file="youtube.png")
121+
headingIcon=Label(main,image=file)
122+
headingIcon.pack(side=TOP)
123+
124+
#listbox
125+
global myList
126+
myList=Listbox(main)
127+
128+
#lable for url
129+
lab1=Label(main,text='Enter the URL of YouTube video:')
130+
lab1.pack(side=TOP)
131+
# url textfield
132+
urlField=Entry(main,font=("verdana",16),justify=CENTER)
133+
urlField.pack(side=TOP,fill=X,padx=10,pady=5)
134+
135+
# search the url
136+
searchButton=Button(main,text="Search",font=("verdana",16),relief="ridge",command=startSearchingThread)
137+
searchButton.pack(side=TOP,pady=10)
138+
139+
# Download Buttom
140+
downloadButton=Button(main,text="Download",font=("verdana",16),relief="ridge",command=startDownloadThread)
141+
downloadButton.pack(side=BOTTOM,pady=5)
142+
143+
#Resolution textfield
144+
resField=Entry(main,font=("verdana",16),justify=CENTER)
145+
resField.pack(side=BOTTOM,fill=X,padx=200,pady=5)
146+
147+
#lable for resolution
148+
lab2=Label(main,text='select the Resolution id:')
149+
lab2.pack(side=BOTTOM)
150+
151+
152+
#Video Title
153+
vTitle=Label(main,text="video Title")
154+
155+
main.mainloop()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## GUI YouTube Video Downloader
2+
- This script built in Python is an YouTube Video Downloader.
3+
- The pytube, threading and tkinter libraries are used to built the app.
4+
## Working
5+
![Image](images/Before_run.jpg)
6+
- The user interface(image is displayed above) is displayed as soon as the script execute.
7+
![image](images/Runtime_images.jpg)
8+
- The user enters :
9+
- The URL of the video which he would like to download.
10+
- press the search button.
11+
- He/She selects video resolution.
12+
- press the download button.
13+
- He/She select the storage PATH.
14+
- The script runs and the progess is reflected in the progress bar.
15+
- a Pop-up massage is displayed which shows video is downloaded succsessfully
Loading
Loading
16.6 KB
Binary file not shown.
42.8 KB
Loading

0 commit comments

Comments
 (0)