-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchecker.py
89 lines (79 loc) · 3.97 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
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
# MADE BY @MDEVIO ON GITHUB
from config import os, keyboard, Fore, requests, time, threading, ThreadPoolExecutor, as_completed
from update_title import update_title
from config import TiktokUsernameChecker
def checker_main():
"""
Main function for the Checker
"""
global executor
if TiktokUsernameChecker.usernames:
os.system("cls")
spacebar_thread = threading.Thread(target=monitor_spacebar) # spacebar thread
spacebar_thread.start() # start spacebar thread
with ThreadPoolExecutor(max_workers=int(TiktokUsernameChecker.threads)) as executor:
futures = [executor.submit(checker, username) for username in TiktokUsernameChecker.usernames]
spacebar_thread.join() # join
for future in as_completed(futures):
future.result()
for username in TiktokUsernameChecker.tried_usernames: # Remove all tried usernames from usernames
TiktokUsernameChecker.usernames.remove(username)
TiktokUsernameChecker.tried_usernames = set() # Reset tried_usernames variable
try:
f = TiktokUsernameChecker.WriteOrRead("available_usernames.txt", "x")
except FileExistsError:
f = TiktokUsernameChecker.WriteOrRead("available_usernames.txt", "a")
finally:
for username in TiktokUsernameChecker.available_usernames:
f.write(username + "\n")
f.close()
print(f"\nYou have checked {TiktokUsernameChecker.available+TiktokUsernameChecker.unavailable} usernames. The results are the following:\n\nAvailable/Banned: {TiktokUsernameChecker.available}\nUnavailable: {TiktokUsernameChecker.unavailable}\n\nAll of the available usernames has been saved in a file named 'available_usernames.txt' in the output folder.")
input("\nPress enter to continue.")
os.system("cls")
TiktokUsernameChecker.available = 0
TiktokUsernameChecker.unavailable = 0
TiktokUsernameChecker.lock = threading.Lock()
TiktokUsernameChecker.stop_event = threading.Event()
keyboard.read_event(suppress=True)
else:
print(Fore.RED + "The file 'usernames.txt' is empty. Please generate usernames via the menu or input usernames in the file.")
time.sleep(3)
os.system("cls")
def monitor_spacebar():
"""
Monitors the spacebar key to stop the TikTok Username Checker
"""
while not TiktokUsernameChecker.stop_event.is_set():
if keyboard.is_pressed('space'):
TiktokUsernameChecker.stop_event.set()
break
def checker(username):
"""
Checks the availability of a TikTok username
"""
try:
if TiktokUsernameChecker.stop_event.is_set():
return
TiktokUsernameChecker.tried_usernames.add(username)
if len(TiktokUsernameChecker.usernames) == len(TiktokUsernameChecker.tried_usernames):
TiktokUsernameChecker.stop_event.set()
request = requests.get(TiktokUsernameChecker.endpoint + username)
while len(request.text) < 200000:
request = requests.get(TiktokUsernameChecker.endpoint + username)
if request.status_code == 200:
if "followingcount" in request.text.lower() or username.isdigit():
with TiktokUsernameChecker.lock:
TiktokUsernameChecker.unavailable += 1
print(Fore.RED + "[Unavailable] " + request.url)
elif "followingcount" not in request.text.lower():
with TiktokUsernameChecker.lock:
TiktokUsernameChecker.available += 1
TiktokUsernameChecker.available_usernames.add(username)
print(Fore.GREEN + "[Available/Banned] " + request.url)
else:
with TiktokUsernameChecker.lock:
print("Ratelimited!")
update_title("checker")
except Exception as e:
with TiktokUsernameChecker.lock:
print(Fore.YELLOW + f"[Error] {username}: {e}")