-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcode.py
48 lines (39 loc) · 1.55 KB
/
code.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
#Make sure you have installed pytube3 on your system. If not done, follow these steps:-
#Open your anaconda or python3 app and use the following command:
# pip install pytubeX
#This will install the pytubeX which will be required.
from pytube import YouTube
#Asking for all the video links
n = int(input("Enter the number of youtube videos to download: "))
# A list to store all the links
links = []
# Asking for the links one per line
print("\nEnter all the links one per line:")
for i in range(0, n):
temp = input()
links.append(temp)
#Showing all details for videos and downloading them one by one
for i in range(0, n):
link = links[i]
yt = YouTube(link)
print("\nDetails for Video", i+1, "\n")
print("Title of video: ", yt.title)
print("Number of views: ", yt.views)
print("Length of video: ", yt.length, "seconds")
# Filter to select only progressive streams
stream = str(yt.streams.filter(progressive=True))
stream = stream[1:]
stream = stream[:-1]
streamlist = stream.split(", ")
print("\nAll available options for downloads:\n")
# loop around all available streams and print them for user to decide
for i in range(0, len(streamlist)):
st = streamlist[i].split(" ")
print(i+1, ") ", st[1], " and ", st[3], sep='')
# ask user the tag forthe stream to download
tag = int(input("\nEnter the itag of your preferred stream to download: "))
ys = yt.streams.get_by_itag(tag)
print("\nDownloading...")
ys.download()
print("\nDownload completed!!")
print()