-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.py
47 lines (38 loc) · 1.3 KB
/
common.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
from download3 import *
def printnames(url_names):
for name in url_names:
print(name)
def auto_down(tempfn,url_names,link):
print("Trying First link! ")
for i in range(0,len(link)):
uri=link[0]
uri=uri.replace(" ","%20")#as all space are replaced by %20 while requesting!no whitepace!
j=interact(uri,tempfn)
if j=='404':
print("Link "+str(i+1)+" Failed! Trying Next")
continue
print("DOWNLOADED!")
break
if i==len(link):
print("COULD'NT DOWNLOAD! SORRY! :/")
return "404"
return "400"
def manual_down(tempfn,url_names,link):
printnames(url_names)
choice=input("\n Which one to Download (to exit type exit)? ")
while True:
if choice=="exit":
print("Exiting!")
exit()
choice=int(choice)
print("Trying To download Link ->",url_names[choice-1])
uri=link[choice-1]
uri=uri.replace(" ","%20")
j=interact(uri,tempfn)
if j=="404":
print("Link ",choice , " could not be downladed! Try some other link")
printnames(url_names)
choice=input("\n Which one to try next ? ")
continue
print("Downloaded!")
choice="exit"