-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshortner.py
102 lines (94 loc) · 2 KB
/
shortner.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
import itertools
import threading
import time
import sys
import os
import pyshorteners
import random
import validators
done = False
count = 0
colors=['\033[1;31m','\033[1;32m','\033[1;33m','\033[1;34m','\033[1;35m','\033[1;36m']
def inp():
print('\033[1;35m')
x = input('Enter URL: ')
return x
x = inp()
def animate():
for c in itertools.cycle(['|', '/', '-', '\\']):
if done:
break
sys.stdout.write('\rLoading ' + c)
sys.stdout.flush()
time.sleep(0.1)
t = threading.Thread(target=animate)
emp_list = []
def vali(x):
if(validators.url(x)):
print('\033[1;32m')
time.sleep(1.5)
print("URL is valid \n")
count = 1
validi = x
return validi
else:
print('\033[1;31m')
print("URL is not valid")
print("Enter a valid URL")
#os.system('clear')
x = inp()
if(vali(x)):
return x
count = 0
x = vali(x)
# if(count==0):
# x = input('enter url: ')
# vali(x)
t.start()
#long process here your code
s = pyshorteners.Shortener()
try:
lin = s.chilpit.short(x)
emp_list.append(lin)
except:
pass
try:
lin = s.clckru.short(x)
emp_list.append(lin)
except:
pass
try:
lin = s.isgd.short(x)
emp_list.append(lin)
except:
pass
try:
lin = s.osdb.short(x)
emp_list.append(lin)
except:
pass
try:
lin = s.qpsru.short(x)
emp_list.append(lin)
except:
pass
try:
lin = s.tinyurl.short(x)
emp_list.append(lin)
except:
pass
#to clear screen
#os.system('clear')
print(random.choice(colors))
print("====================================================")
print(" URL_shortner in progress, please wait !! ")
print(" Please keep your data connection active !! ")
print("====================================================")
time.sleep(2)
print(random.choice(colors))
print("\n","The shortned URL's are:\n")
for i in emp_list:
if(i=="Invalid link"):
continue
print(i,"\n")
done = True