-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathperseusqr.py
88 lines (65 loc) · 2.13 KB
/
perseusqr.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
import requests
import shutil
import pyshorteners
import time
import itertools
import threading
import sys
COLORS = {
"black": "\u001b[30;1m",
"red": "\u001b[31;1m",
"green": "\u001b[32m",
"yellow": "\u001b[33;1m",
"blue": "\u001b[34;1m",
"Bright Yellow": "\u001b[33;1m",
"magenta": "\u001b[35m",
"cyan": "\u001b[36m",
"white": "\u001b[37m",
"yellow-background": "\u001b[43m",
"black-background": "\u001b[40m",
"cyan-background": "\u001b[46;1m",
}
def colorText(text):
for color in COLORS:
text = text.replace("[[" + color + "]]", COLORS[color])
return text
code = "[[blue]]Your[[red]] QrCode[[white]]"
qr = colorText(code)
su = "[[blue]]The Shortened[[red]] URL[[white]] is: "
shorturltxt = colorText(su)
re = "[[green]] (Recommended)"
Recommended = colorText(re)
baner = """"
____ ___
| _ \ ___ _ __ ___ ___ _ _ ___ [[Bright Yellow]] / _ \ _ __
| |_) / _ | '__/ __|/ _ | | | / __|[[Bright Yellow]] | | | | '__|
| __| __| | \__ | __| |_| \__ \[[Bright Yellow]] | |_| | |
|_| \___|_| |___/\___|\__,_|___/[[Bright Yellow]] \__\_|_|
"""
banner = colorText(baner)
print(banner)
x = input("Url: ")
normalurl = "https://api.qrserver.com/v1/create-qr-code/?size450x450&data="+str(x)
shorturl = "https://api.qrserver.com/v1/create-qr-code/?size450x450&data="+str(x)
print(f"{qr} https://api.qrserver.com/v1/create-qr-code/?size450x450&data="+str(x))
urlshort = shorturl
long_url = urlshort
type_tiny = pyshorteners.Shortener()
short_url = type_tiny.tinyurl.short(long_url)
print(shorturltxt + short_url + Recommended)
url = normalurl
file_name = "qrocde.png"
res = requests.get(url, stream = True)
if res.status_code == 200:
with open(file_name,'wb') as f:
shutil.copyfileobj(res.raw, f)
else:
print('Image Couldn\'t be retrieved')
url1 = shorturl
file_name = "qrocde(shorturl).png"
res = requests.get(url, stream = True)
if res.status_code == 200:
with open(file_name,'wb') as f:
shutil.copyfileobj(res.raw, f)
else:
print('Image Couldn\'t be retrieved')