-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDown.py
146 lines (137 loc) · 6.3 KB
/
Down.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
from pytube import YouTube, Playlist
import os
from os import system, name
def playlistSongs (url, destination):
try:
yt = YouTube(url)
contentA = yt.streams.filter(only_audio=True)
stream = yt.streams.get_by_itag(contentA[4].itag)
ogdes = stream.download(output_path=destination)
base, ext = os.path.splitext(ogdes)
newdes = base + '.mp3'
os.rename(ogdes, newdes)
except Exception as e:
print(e)
while True:
try:
print("""
███╗ ███╗███████╗████████╗██╗ ██╗██████╗ ███████╗ ██╗ ██╗ ██████╗ ██╗
████╗ ████║██╔════╝╚══██╔══╝██║ ██║██╔══██╗██╔════╝ ██║ ██║██╔═████╗ ███║
██╔████╔██║█████╗ ██║ ██║ ██║██████╔╝█████╗ ██║ ██║██║██╔██║ ╚██║
██║╚██╔╝██║██╔══╝ ██║ ██║ ██║██╔══██╗██╔══╝ ╚██╗ ██╔╝████╔╝██║ ██║
██║ ╚═╝ ██║███████╗ ██║ ╚██████╔╝██████╔╝███████╗ ╚████╔╝ ╚██████╔╝██╗██║
╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝
Dev : D O R T R O 乂\n\n""")
link = input('Paste youtube video video link:\n')
if "playlist?list=" in link:
try:
print("Found Playlist\n")
destination = input("Enter a name for the playlist : ")
print("Downloading your Playlist for you be patient\n")
cwd = os.getcwd()
target_dir = cwd +'/' + destination;
os.mkdir(target_dir)
p = Playlist(link)
for url in p.video_urls:
playlistSongs(url, './' + destination)
print("Download Complete!")
except Exception as e:
print(e)
else:
yt = YouTube(link)
while True:
try:
video_audio = int(input("\nPress 1 for Video\nPress 2 for audio\n"))
if video_audio <= 2 and video_audio > 0:
break
print("Invalid input.")
except Exception as e:
print(e)
while video_audio == 1:
contentV = yt.streams.filter(progressive=True)
i = 0
for avail in contentV:
i+=1
print(f"Press {i} for {avail.resolution}")
destination = "./Video Downloads"
try:
quality = int(input("Enter No.: "))
if i == 2:
if quality <= i and quality > 0:
if quality == 1:
tag = contentV[0].itag
break
elif quality == 2:
tag = contentV[1].itag
break
print("Invalid")
else:
if quality <= i and quality > 0:
if quality == 1:
tag = contentV[0].itag
break
elif quality == 2:
tag = contentV[1].itag
break
elif quality == 3:
tag = contentV[2].itag
break
print("Invalid")
except Exception as e:
print(e)
while video_audio == 2:
contentA = yt.streams.filter(only_audio=True)
i = 0
for avail in contentA:
i+=1
print(f"Press {i} for {avail.abr}")
destination = "./Audio Downloads"
try:
quality = int(input("Enter No.: "))
if quality <= i and quality > 0:
if quality == 1:
tag = contentA[0].itag
break
elif quality == 2:
tag = contentA[1].itag
break
elif quality == 3:
tag = contentA[2].itag
break
elif quality == 4:
tag = contentA[3].itag
break
elif quality == 5:
tag = contentA[4].itag
break
print("Invalid input.")
except Exception as e:
print(e)
# while video_audio == 3:
# contentP = input("Enter the Playlist URL here")
print(f"Downloading : {yt.title}\nwill be added shortly...")
stream = yt.streams.get_by_itag(tag)
ogdes = stream.download(output_path=destination)
if video_audio == 2:
base, ext = os.path.splitext(ogdes)
newdes = base + '.mp3'
os.rename(ogdes, newdes)
else:
pass
print("Successfully downloaded")
while True:
try:
loop = input("Want to download next Video/Audio?\n[y/n]: ").lower()
if loop == "n" or loop == "y":
break
print("Invalid input!")
except Exception as e:
print(e)
if loop == "n":
break
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
except Exception as e:
print(e)