1+ import tkinter as tk
2+ from tkinter import *
3+ from PIL import ImageTk , Image
4+ from tkinter import messagebox
5+ import pytube
6+ import time
7+
8+ root = tk .Tk ()
9+ root .title ("Youtube Downloader" )
10+ root .iconbitmap ("Youtube.ico" )
11+ root .geometry ("700x300" )
12+ #root.maxsize(700,250)
13+ root .minsize (700 ,300 )
14+
15+
16+ def download ():
17+ link = text .get ("1.0" ,"end-1c" )
18+
19+ if link == '' :
20+ messagebox .showerror ("YouTube Downloader" , "Please paste a link here" )
21+ else :
22+ yt = pytube .YouTube (link )
23+ stream = yt .streams .first ()
24+ time .sleep (2 )
25+ text .delete (1.0 ,'end' )
26+ text .insert ('end' ,'Wait Downloading ......' )
27+ time .sleep (5 )
28+ stream .download ()
29+ messagebox .showinfo ("YouTube Downloader" ,'Video has been download successfully' )
30+
31+
32+
33+
34+
35+ header = Label (root ,bg = "black" ,width = "300" ,height = "2" )
36+ header .place (x = 0 ,y = 0 )
37+
38+ yt_logo = ImageTk .PhotoImage (Image .open ('youtube.png' ))
39+ logo = Label (root , image = yt_logo ,borderwidth = 0 )
40+ logo .place (x = 10 ,y = 10 )
41+
42+ caption = Label (root ,text = "YouTube Downloader" ,font = ('verdana' ,10 ,'bold' ))
43+ caption .place (x = 50 ,y = 10 )
44+
45+
46+
47+ yt1_logo = ImageTk .PhotoImage (Image .open ('yt.png' ))
48+ logo1 = Label (root , image = yt1_logo ,borderwidth = 0 )
49+ logo1 .place (x = 300 ,y = 60 )
50+
51+
52+ text = Text (root ,width = 60 ,height = 2 ,font = ('verdana' ,10 ,'bold' ))
53+ text .place (x = 90 ,y = 180 )
54+ text .insert ('end' ,'Paste your video link here' )
55+
56+ button = Button (root ,text = "Download" ,relief = RIDGE ,font = ('verdana' ,10 ,'bold' ),bg = "red" ,fg = "white" ,command = download )
57+ button .place (x = 330 ,y = 220 )
58+ root .mainloop ()
0 commit comments