-
Notifications
You must be signed in to change notification settings - Fork 0
/
tpdne.py
44 lines (36 loc) · 1.19 KB
/
tpdne.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
import requests, random, sys
from tqdm import tqdm, trange
def random_name():
return "".join(random.choices("abcdef0ghi9jklmn8op7qrst6u5v4wx3y2z1", k=10))
def this_persion_does_not_exist(Len=1):
"""
Get image from ThisPersonDoesNotExist.com
"""
downloaded = []
print("\r\033[1;32m[Info]:\033[1;31m Downloading %s images\033[m" % Len)
for i in tqdm(
[x for x in range(Len)],
unit="pic",
ascii=" ▮",
smoothing=0.9,
colour="red",
dynamic_ncols=True,
):
image = requests.get("https://thispersondoesnotexist.com/image", stream=True)
file_name = random_name()
with open(f"images/{file_name}.jpg", "wb") as data:
for chunk in image:
data.write(chunk)
downloaded.append(file_name)
if Len > 1:
print()
print("\r\033[1;32m[Info]:\033[1;31m Got all data:\n\033[m")
print(*downloaded, sep=" ; ")
else:
print()
print(
"\r\033[1;32m[Info]:\033[1;31m File saved in image/%s.jpg\n\033[m"
% downloaded[0]
)
length = int(sys.argv[1]) if len(sys.argv) > 1 else 1
this_persion_does_not_exist(Len=length)