-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathYoutube-Audio-Video-Downloader.py
70 lines (54 loc) · 3.29 KB
/
Youtube-Audio-Video-Downloader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from tkinter import *
from tkinter import messagebox
import pafy
root = Tk() # creating tkinter window
root.iconphoto(False, PhotoImage(file='icon.png')) # setting window icon
root.title("Youtube Audio/Video Downloader") # setting window title
def audio():
root.geometry('500x250') # setting window size
f1 = Frame().place(x=0, y=0, width=500, height=250)
# function to download audio
def downloader():
try:
url = str(link.get())
pafy.new(url).getbestaudio(preftype='m4a').download()
Label(f1, text='Download Successful', font='roboto').place(relx=0.5, rely=0.8, anchor=CENTER)
except:
messagebox.showinfo(title='Warning', message='Enter Something!')
Label(f1, text='Youtube Audio Downloader', font=('roboto', 20)).place(relx=0.5, rely=0.1, anchor=CENTER)
link = StringVar()
Label(f1, text='Paste Link Here', font=('roboto', 15)).place(relx=0.5, rely=0.3, anchor=CENTER)
Entry(f1, width=70, textvariable=link).place(x=32, y=90)
Button(f1, text='Download', font=('roboto', 15), bg='red', fg='white', command=downloader).place(relx=0.4, rely=0.6,
anchor=CENTER)
Button(f1, text='Back', font=('roboto', 15), bg='black', fg='white', command=main_menu).place(relx=0.6, rely=0.6,
anchor=CENTER)
def video():
root.geometry('500x250') # setting window size
f1 = Frame().place(x=0, y=0, width=500, height=250)
# function to download video
def downloader():
try:
url = str(link.get())
pafy.new(url).getbestvideo(preftype='mp4').download()
Label(f1, text='Download Successful', font='roboto').place(relx=0.5, rely=0.8, anchor=CENTER)
except:
messagebox.showinfo(title='Warning', message='Enter Something!')
Label(f1, text='Youtube Video Downloader', font=('roboto', 20)).place(relx=0.5, rely=0.1, anchor=CENTER)
link = StringVar()
Label(f1, text='Paste Link Here', font=('roboto', 15)).place(relx=0.5, rely=0.3, anchor=CENTER)
Entry(f1, width=70, textvariable=link).place(x=32, y=90)
Button(f1, text='Download', font=('roboto', 15), bg='red', fg='white', command=downloader).place(relx=0.4, rely=0.6,
anchor=CENTER)
Button(f1, text='Back', font=('roboto', 15), bg='black', fg='white', command=main_menu).place(relx=0.6, rely=0.6,
anchor=CENTER)
def main_menu():
root.geometry('500x150') # setting window size
f1 = Frame().place(x=0, y=0, width=500, height=250)
Label(f1, text='Youtube Audio/Video Downloader', font=('roboto', 20)).place(relx=0.5, rely=0.2, anchor=CENTER)
audio_button = Button(f1, text='Audio Downloader', font=('roboto', 15), bg='red', fg='white', command=audio)
audio_button.place(relx=0.3, rely=0.6, anchor=CENTER)
video_button = Button(f1, text='Video Downloader', font=('roboto', 15), bg='red', fg='white', command=video)
video_button.place(relx=0.7, rely=0.6, anchor=CENTER)
main_menu()
root.mainloop()