-
Notifications
You must be signed in to change notification settings - Fork 2
/
checker.py
51 lines (41 loc) · 1.8 KB
/
checker.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
from colorama import *
from helpers.requests import username_available
from helpers.files import create_dir, create_file, add_username
init(convert=True)
class Checker:
def __init__(self) -> None:
pass
def setup() -> bool:
if create_dir("data") == True:
create_file("data", "available")
create_file("data", "unavailable")
return True
else:
return False
def check_username(username: str) -> bool:
try:
response = username_available(username)
return response
except:
return False
def add_username(dir_name: str, file_name: str, username: str):
add_username(dir_name, file_name, username)
if __name__ == "__main__":
Checker.setup()
try:
with open("usernames.txt", "r") as f:
lines = f.readlines()
if not lines:
raise Exception(f"{Fore.RED}[ERROR]{Fore.RESET} File is empty, please add some usernames.")
else:
for line in lines:
if line.strip():
result = Checker.check_username(line.strip())
if result == True:
print(f"{Fore.GREEN} https://www.tiktok.com/@{line.strip()}")
Checker.add_username("./data", "available", line.strip())
elif result == False:
print(f"{Fore.RED} https://www.tiktok.com/@{line.strip()}")
Checker.add_username("./data", "unavailable", line.strip())
except FileNotFoundError:
print(f"{Fore.RED}[ERROR]{Fore.RESET} Please create a usernames.txt file.")