-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (26 loc) · 828 Bytes
/
main.py
File metadata and controls
30 lines (26 loc) · 828 Bytes
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
from fileinput import filename
from pytube import YouTube
link = input("Set our video link:\n")
yt = YouTube(link)
def mp3():
return yt.streams.filter(file_extension='mp3').get_highest_resolution()
def mp4():
return yt.streams.filter(file_extension='mp4').get_highest_resolution()
filename = "YTB"
while True:
format = input("What format you want: (1 - mp3) (2 - mp4)\n")
match format:
case "mp3" | "1":
downloader = mp3()
filename += "audio.mp3"
case "mp4" | "2":
downloader = mp4()
filename += "video.mp4"
case other:
print("Bad format")
continue
print("Download is starting... Please wait")
downloader.download(filename=filename)
break
print("finish")
print(f"Check the result at {filename}")