-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYoutube-Downloader.py
45 lines (31 loc) · 1 KB
/
Youtube-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
from pytube import YouTube
# def Download_video(link):
# yt = YouTube(link)
# yt = yt.streams.get_highest_resolution()
# try:
# yt.download()
# except:
# print("An error occurred")
# print("The video has been downloaded successfully")
# link = ""
# Download_video(link)
#---------------------------------------------------------
# def Download_audio(link_2):
# yt_object = YouTube(link_2)
# yt_object = yt_object.streams.get_audio_only()
# try:
# yt_object.download()
# except:
# print("an error has occurred")
# print("The audio has been downloaded successfully")
# link_2 = "https://www.youtube.com/watch?v=XDPV0d-YdU4"
# Download_audio(link_2)
yt = YouTube("https://www.youtube.com/watch?v=XDPV0d-YdU4")
vids= yt.streams.all()
for i in range(len(vids)):
print(i,'. ',vids[i])
vnum = int(input("Enter vid num: "))
vids[vnum].download(r"D:\python")
print('done')
# When using any of the functions, comment the other
# to avoid an error