import requests from requests_tor import RequestsTor def build_url(stream_url, username, password): return f"{stream_url}/player_api.php?username={username}&password={password}" def check_url(url): try: # tr = RequestsTor() tr = requests response = tr.get(url, timeout=5) response.raise_for_status() if response.json().get("user_info", {}).get("auth"): return response.json() except requests.exceptions.RequestException as e: if e.response and e.response.status_code == 403: try: response = requests.get(url, timeout=5) response.raise_for_status() if response.json().get("user_info", {}).get("auth"): return response.json() except requests.exceptions.RequestException: return None return None def single_account_check(account_data, stream_urls): for stream_url in stream_urls: url = build_url(stream_url, account_data['username'], account_data['password']) result = check_url(url) if result: return {"url": stream_url, "data": result} return None