-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoutubeDownloader.py
78 lines (60 loc) · 1.9 KB
/
youtubeDownloader.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
71
72
73
74
75
76
77
78
from pytube import YouTube, Playlist
def pVideo(tag):
URL = input("Enter playlist URL: ")
playlist_url = URL
p = Playlist(playlist_url)
for url in p.video_urls:
try:
yt = YouTube(url)
except VideoUnavailable:
try:
print(f'Video "{yt.title}" is unavaialable, skipping.')
except:
print(f'Video "{URL}" is unavaialable, skipping.')
else:
v_streams = yt.streams.get_by_itag(tag)
try:
print(f'downloading: "{video.title}"')
except:
print(f'downloading: "{URL}"')
v_streams.download()
print("download completed.")
pass
def pAudio():
pVideo(251)
pass
#
#
#
def sVideo(tag):
URL = input("Enter video URL: ")
video = YouTube(URL)
#print(video.streams)
#v_streams = video.streams.filter(progressive = False, file_extension = 'mp3').get_by_itag(22)
v_streams = video.streams.get_by_itag(tag)
try:
print(f'downloading: "{video.title}"')
print("filepath:",v_streams.download())
except:
print(f'downloading: "{URL}"')
print("download completed.")
pass
def sAudio():
sVideo(251)
pass
def downloaderThing(format, size):
if format == "1" and size == "1":
pAudio()
elif format == "1" and size == "2":
sAudio()
elif format == "2" and size == "1":
pVideo(251)
elif format == "2" and size == "2":
sVideo(22)
pass
###################################################################
downloadFormat = input("Do you want to download: \n1. only AUDIO\n2. VIDEO & AUDIO\n____________________\n")
downloadSize = input("\n\nDo you want to download: \n1. PLAYLIST\n2. ONE file\n____________________\n")
#22 = mp4 + 720p
#251 = mp3 + 160 kbps
downloaderThing(downloadFormat, downloadSize)