import requests
import json

def test_api():
    print("Testing Anitabi API...\n")
    
    # 1. Test Lite Info with a known valid ID (Sound! Euphonium: 115908)
    print("--- Test 1: get_anime_lite_info (Valid ID: 115908) ---")
    url_lite = "https://api.anitabi.cn/bangumi/115908/lite"
    try:
        response = requests.get(url_lite)
        response.raise_for_status()
        data = response.json()
        print(f"Status: {response.status_code} OK")
        print(f"Title: {data.get('title')}")
        print(f"Chinese Title: {data.get('cn')}")
        print(f"Points Length: {data.get('pointsLength')}")
    except Exception as e:
        print(f"Error: {e}")
        
    print("\n")
    
    # 2. Test Detail Points with a known valid ID (Sound! Euphonium: 115908)
    print("--- Test 2: get_anime_detail_points (Valid ID: 115908) ---")
    url_detail = "https://api.anitabi.cn/bangumi/115908/points/detail"
    try:
        response = requests.get(url_detail)
        response.raise_for_status()
        data = response.json()
        print(f"Status: {response.status_code} OK")
        print(f"Fetched {len(data)} detailed points.")
        if data:
            print(f"First point name: {data[0].get('name')}")
    except Exception as e:
        print(f"Error: {e}")

    print("\n")

    # 3. Test Invalid ID (Testing 404 response as seen in the issue: 153304 / 117549)
    invalid_id = 117549
    print(f"--- Test 3: get_anime_lite_info (Invalid ID: {invalid_id}) ---")
    url_invalid = f"https://api.anitabi.cn/bangumi/{invalid_id}/lite"
    try:
        response = requests.get(url_invalid)
        response.raise_for_status()
        print("Success (Unexpected)")
    except requests.exceptions.HTTPError as e:
        print(f"Caught Expected HTTPError: {e}")
        if e.response is not None and e.response.status_code == 404:
            print("Verified: Returns 404 Not Found correctly.")
    except Exception as e:
        print(f"Caught other error: {e}")

if __name__ == "__main__":
    test_api()
