forked from Dew3/TikTok-Username-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.py
70 lines (57 loc) · 3.15 KB
/
Main.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
#####################################################################
# #
# Dew3's TikTok Username Checker #
# v0.2 #
# Utilizes TikTokApi by David Teather to get user information #
# Open README.txt before running the program #
# #
#####################################################################
from TikTokApi import TikTokApi
import requests
import pathlib
import colorama
import os, sys
import time
from pathlib import Path
from colorama import *
api = TikTokApi()
current_path = os.path.dirname(os.path.realpath(__file__))
open(current_path +"/"+str("Available")+str("")+".txt","a") #Creates 'Available.txt'
open(current_path +"/"+str("Usernames")+str("")+".txt","a") #Creates 'Usernames.txt'
names = open('Usernames.txt', 'r')
available = open('Available.txt', 'w')
mypath = Path('Usernames.txt')
numberOfUsernames = 0
savedNames = 0
def check():
print(Fore.LIGHTBLACK_EX+"["+Fore.CYAN+"+"+Fore.LIGHTBLACK_EX+"]"+"Dew3's TikTok Username Checker")
if mypath.stat().st_size == 0: #If the Usernames files is empty it will prompt the user to enter usernames and close the program
print(Fore.WHITE+"\nPlease put your names in Usernames.txt"+ Fore.RED + "\nClosing in 5 seconds")
time.sleep(5)
sys.exit()
else:
pass
with open('Usernames.txt', 'r') as u:
for line in u:
username = line.rstrip("\n") #Gets each usernames line in 'Usernames.txt'
if len(username) < 25:
global numberOfUsernames
numberOfUsernames += 1 #Counter for the total number of usernames
try: #Use a try block since there is a potential of an account not existing
user = api.getUserObject(username) #TikTokApi returns a user as an object OR throws a TikTokNotFound exception (I forget the exact name of the exception but you get what I mean)
#If the previous line doesn't throw an exception we know the username is taken
print(Fore.WHITE+"["+Style.BRIGHT + Fore.RED + Back.BLACK+"Taken"+Fore.WHITE+"]" +Fore.WHITE +username)
except: #Catches the TikTokNotFound exception. Therefore the username isn't taken.
global savedNames
savedNames+=1
available.write(username + "\n") #The username isn't taken so we store it into 'Availables.txt'
print(Fore.WHITE+"["+Style.BRIGHT + Fore.GREEN + Back.BLACK+"Not Taken"+Fore.WHITE+"]" +Fore.WHITE +username)
tic = time.perf_counter() #Program timer start
check()
toc = time.perf_counter() #Program timer stop
available.close()
print(Fore.CYAN+"\nChecker finished " + str(numberOfUsernames) + f" usernames in {toc - tic:0.4f} seconds")
print("Saved " + str(savedNames) + " username(s) saved!")
print(Fore.RED +"Closing in 5 seconds")
time.sleep(5)
sys.exit()