Skip to content

Instantly share code, notes, and snippets.

@eioo
Last active June 26, 2019 19:24
Show Gist options
  • Save eioo/2146ef3050f4a78cf1d27eb8cc19ef1c to your computer and use it in GitHub Desktop.
Save eioo/2146ef3050f4a78cf1d27eb8cc19ef1c to your computer and use it in GitHub Desktop.
import os
import queue
import sys
import threading
import requests
from colorama import Fore, init
script_path = os.path.dirname(os.path.realpath(__file__))
accs_file = os.path.join(script_path, 'accs.txt')
thread_count = 10
lock = threading.Lock()
def ban_check_worker():
while not q.empty():
item = q.get()
username = item.split(':')[0].strip()
if username is None:
break
r = requests.get(f'https://api.twitch.tv/kraken/users/{username}?client_id=jzkbprff40iqj646a697cyrvl0zt2m6')
is_banned = r.text.startswith('{"error":"')
status = (Fore.RED if is_banned else Fore.GREEN) + ('Banned' if is_banned else 'Valid') + Fore.RESET
out_file = 'invalid_accs.txt' if is_banned else 'valid_accs.txt'
with lock:
sys.stdout.write(f'{username.ljust(26, " ")}{status}\n')
open(os.path.join(script_path, out_file), 'a').write(item + '\n')
q.task_done()
if __name__ == '__main__':
init() # colors
q = queue.Queue()
threads = []
for x in open(accs_file, 'r').readlines():
x = x.strip()
if x:
q.put(x)
for i in range(thread_count):
t = threading.Thread(target=ban_check_worker)
t.start()
q.join()
print(('-' * 40) + '\nDone!')
input('Press anything to exit...')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment