|
| 1 | +import httpx |
| 2 | +from user_scanner.core.result import Result |
| 3 | + |
| 4 | + |
| 5 | +async def _check(email: str) -> Result: |
| 6 | + url = "https://www.babestation.tv/user/send/username-reminder" |
| 7 | + |
| 8 | + headers = { |
| 9 | + 'User-Agent': "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Mobile Safari/537.36", |
| 10 | + 'Accept': "application/json, text/plain, */*", |
| 11 | + 'Content-Type': "application/json", |
| 12 | + 'x-requested-with': "XMLHttpRequest", |
| 13 | + 'origin': "https://www.babestation.tv", |
| 14 | + 'referer': "https://www.babestation.tv/forgot-password-or-username", |
| 15 | + 'accept-language': "en-US,en;q=0.9", |
| 16 | + } |
| 17 | + |
| 18 | + payload = { |
| 19 | + "email": email |
| 20 | + } |
| 21 | + |
| 22 | + try: |
| 23 | + async with httpx.AsyncClient(timeout=5.0) as client: |
| 24 | + response = await client.post(url, json=payload, headers=headers) |
| 25 | + |
| 26 | + if response.status_code in [200, 404]: |
| 27 | + data = response.json() |
| 28 | + success = data.get("success") |
| 29 | + |
| 30 | + if success is True: |
| 31 | + return Result.taken() |
| 32 | + |
| 33 | + if success is False: |
| 34 | + errors = data.get("errors", []) |
| 35 | + if "Email not found" in errors: |
| 36 | + return Result.available() |
| 37 | + |
| 38 | + return Result.error("Unexpected response body, report it via GitHub issues") |
| 39 | + |
| 40 | + return Result.error(f"HTTP {response.status_code}") |
| 41 | + |
| 42 | + except httpx.TimeoutException: |
| 43 | + return Result.error("Connection timed out") |
| 44 | + except Exception as e: |
| 45 | + return Result.error(f"Unexpected Exception: {e}") |
| 46 | + |
| 47 | + |
| 48 | +async def validate_babestation(email: str) -> Result: |
| 49 | + return await _check(email) |
0 commit comments