#!/usr/bin/env python3
import requests, json, sys

BASE = "https://www.fansky.net"
UA = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"}
s = requests.Session()
s.headers.update(UA)
s.verify = True
TIMEOUT = 25

# Signature: for protected endpoint, baseline is 401 with body "Please register or log in first"
SIG_401 = "Please register or log in first"

def req(method, path, **kw):
    url = BASE + path
    try:
        r = s.request(method, url, timeout=TIMEOUT, allow_redirects=False, **kw)
        body = r.text[:200].replace("\n"," ")
        return r.status_code, body
    except Exception as e:
        return -1, f"ERR:{e}"

def report(label, method, path, code, body):
    flag = ""
    if code == 200:
        flag = "  <== 200!!"
    elif code == 405:
        flag = "  <== 405 (method not allowed)"
    elif code in (400,404,500,422):
        flag = "  <== non-401"
    elif code == -1:
        flag = "  <== ERROR"
    print(f"[{label}] {method} {path} -> {code} {body[:120]}{flag}")

# ---------- 1. Baseline ----------
print("========== BASELINE ==========")
report("base", "POST", "/api/v1/creator/products/61297/attachments/106/pre-signed-url", *req("POST","/api/v1/creator/products/61297/attachments/106/pre-signed-url", json={"downloadMethod":"download","regenerate":False}))
report("base", "GET", "/api/v1/admin-dashboard/users", *req("GET","/api/v1/admin-dashboard/users"))
report("base", "GET", "/api/v1/creator/products", *req("GET","/api/v1/creator/products"))
report("base", "GET", "/api/v1/creator/test-download-url", *req("GET","/api/v1/creator/test-download-url"))
