All MicroEvals
read the full code. list every of any type error! just list ...
Create MicroEval

read the full code. list every of any type error! just list ...

Prompt

read the full code. list every of any type error! just list the results, nothing else. import hashlib import json import os import time from curl_cffi import requests import ofsign HERE = os.path.dirname(os.path.abspath(__file__)) STATE = os.path.join(HERE, "session.json") UA = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 " "(KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36") APP_TOKEN = "33d57ade8c02dbc5a333db99ff9ae26a" BASE = "https://onlyfans.com" HASH_URL = "https://cdn2.onlyfans.com/hash/" class ApiError(RuntimeError): def __init__(self, status, body, path): super().__init__("%s -> HTTP %s %s" % (path, status, body[:200])) self.status = status self.body = body self.path = path class Session: def __init__(self, state_path=STATE, verify_tls=True): with open(state_path, "r", encoding="utf-8") as fh: raw = json.load(fh) self.state_path = state_path self.ua = raw.get("ua") or UA self.user_id = str(raw.get("user_id") or "") self.cookies = dict(raw.get("cookies") or {}) self.x_bc = raw.get("x_bc") or "" self.x_of_rev = raw.get("x_of_rev") or "" self.app_token = raw.get("app_token") or APP_TOKEN self.identity = int(self.user_id) if raw.get("logged_in") and self.user_id else 0 self.verify = verify_tls self._http = requests.Session(impersonate="chrome") for name, value in self.cookies.items(): self._http.cookies.set(name, value, domain=".onlyfans.com") self._hash_cache = (0.0, "") def save(self): payload = { "ua": self.ua, "user_id": self.user_id, "cookies": self.cookies, "x_bc": self.x_bc, "x_of_rev": self.x_of_rev, "app_token": self.app_token, "logged_in": bool(self.identity), } with open(self.state_path, "w", encoding="utf-8") as fh: json.dump(payload, fh, indent=1) def set_cookie(self, name, value): self.cookies[name] = value self._http.cookies.set(name, value, domain=".onlyfans.com") def fresh_hash(self, ttl=8.0): stamp, value = self._hash_cache now = time.time() if value and now - stamp < ttl: return value response = requests.get( HASH_URL + "?u=%d" % self.identity, headers={"User-Agent": self.ua}, impersonate="chrome", verify=self.verify, timeout=20, ) response.raise_for_status() value = response.text.strip() if not value: raise ApiError(response.status_code, "empty hash", "/hash/") self._hash_cache = (now, value) return value def headers(self, path, identity=None, with_identity=True): ident = self.identity if identity is None else identity signature, stamp = ofsign.sign(path, ident) headers = { "User-Agent": self.ua, "Accept": "application/json, text/plain, */*", "Accept-Language": "hu-HU,hu;q=0.9,en;q=0.8", "app-token": self.app_token, "x-bc": self.x_bc, "x-of-rev": self.x_of_rev, "x-hash": self.fresh_hash(), "sign": signature, "time": stamp, "Referer": BASE + "/", "Origin": BASE, "sec-fetch-site": "same-origin", "sec-fetch-mode": "cors", "sec-fetch-dest": "empty", } if with_identity and ident: headers["user-id"] = str(ident) return headers def request(self, method, path, params=None, json_body=None, timeout=40, retries=3): url = BASE + path last = None for attempt in range(retries): try: response = self._http.request( method, url, params=params, json=json_body, headers=self.headers(path), timeout=timeout, verify=self.verify, ) except requests.RequestsError as exc: last = ApiError(0, str(exc), path) time.sleep(0.6 * (attempt + 1)) continue if response.status_code in (429, 502, 503, 504) and attempt + 1 < retries: last = ApiError(response.status_code, response.text, path) time.sleep(1.2 * (attempt + 1)) continue rev = response.headers.get("x-of-rev") if rev: self.x_of_rev = rev body = response.text if response.status_code >= 400: raise ApiError(response.status_code, body, path) try: return response.json() except ValueError: return body raise last if last else ApiError(0, "no attempt", path) def get(self, path, params=None, **kwargs): return self.request("GET", path, params=params, **kwargs) def post(self, path, json_body=None, **kwargs): return self.request("POST", path, json_body=json_body, **kwargs) def me(self, use_identity=None): ident = self.identity if use_identity is None else use_identity return self.get("/api2/v2/users/me", **{"identity": ident} if ident else {}) def probe(self): guest = None auth = None try: guest = self.me(0) except ApiError as exc: guest = {"error": exc.status, "body": exc.body} if self.identity: try: auth = self.me(self.identity) except ApiError as exc: auth = {"error": exc.status, "body": exc.body} return {"guest": guest, "auth": auth}

Response not available

Drag to resize
Drag to resize
Drag to resize
Drag to resize
Drag to resize