-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYoutubeDownloaderGUI.py
More file actions
45 lines (32 loc) · 1.14 KB
/
YoutubeDownloaderGUI.py
File metadata and controls
45 lines (32 loc) · 1.14 KB
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
import youtube_dl as yt
import PySimpleGUI as sg
global AudioSwitch
AudioSwitch = False
sg.theme('DarkAmber') # Keep things interesting for your users
def Download(Link):
if AudioSwitch:
ydl = yt.YoutubeDL({'format':'bestaudio', 'audio-format': 'm4a'})
print("Audio Only")
else:
ydl = yt.YoutubeDL({})
print("Audio and Video")
with ydl:
try:
result = ydl.extract_info(
Link,
download=True # We just want to extract the info
)
except:
print("Video does not exist")
layout = [[sg.Checkbox("Audio", key="Audio", enable_events=True), sg.Button("Download", key="DL"), sg.Input("", key="Input")]]
window = sg.Window('Youtube Downloader', layout)
while True: # The Event Loop
event, values = window.read()
#print(event, values)
if event == sg.WIN_CLOSED or event == 'Exit':
break
if event == "DL":
Download(values["Input"])
if event == "Audio":
AudioSwitch = values["Audio"]
window.close()