/* spcat — pure C ScorpioPlayer catalogue browse client (read-only). * * SCORPIO PLAYER 2027 fleet, row 19b. Sibling of scorpiox-scorpioplayer-spimdb-movie-client: * same error taxonomy, same conventions. Four GET endpoints on gcp.scorpioplayer.com: * GetHomePage (zlib body, MD5HomePage/ContentHash int-ETag protocol) * GetCollectionPopular (camelCase array, server-shuffled) * GetPeopleDetail (PascalCase fresh / camelCase warm — case-insensitive parse, SPEC D15) * GetPeoplePopular (1-based pages; two wire dialects, SPEC D17) * * Transport: the fleet HTTP transport (vendor/scorpiox-http-transport). The engine * requires a scorpiox_http behind the installed scorpiox_io (request headers for * MD5HomePage, response headers for ContentHash, binary-safe bodies for zlib). * * Read-only: no export mutates backend state. */ #ifndef SPCAT_H #define SPCAT_H #include #include "scorpiox-io.h" /* frozen v1 face (vendor/scorpiox-http-transport/include) */ #if defined(_WIN32) # if defined(SPCAT_BUILD) # define SPCAT_API __declspec(dllexport) # else # define SPCAT_API # endif #else # define SPCAT_API __attribute__((visibility("default"))) #endif #ifdef __cplusplus extern "C" { #endif /* ---- error taxonomy: identical codes to the spimdb movie client (SPEC 0.3) ---- */ enum { SPCAT_OK = 0, SPCAT_ERR_TRANSPORT = 1, SPCAT_ERR_HTTP = 2, SPCAT_ERR_PARSE = 3, SPCAT_ERR_EMPTY = 4, SPCAT_ERR_NOT_FOUND = 5, SPCAT_ERR_INVALID_ARG= 6, SPCAT_ERR_NO_IO = 7, SPCAT_ERR_OOM = 8, /* informational, not an error: the server said "you already have it" (1-byte 0xFF) */ SPCAT_UNCHANGED = 9 }; /* spcat_get_homepage opts (append-only) */ enum { SPCAT_HOME_UPDATE = 1u << 0, /* add update=true&read=true (force server rebuild) */ SPCAT_HOME_VERSION1 = 1u << 1 /* send version=1 (default is version=2, call-site parity) */ }; /* ---- core ---- */ SPCAT_API const char *spcat_version(void); /* io must carry a fleet transport: scorpiox_http_of(io) != NULL (SPEC D1). 0/1. */ SPCAT_API int spcat_set_io(const scorpiox_io *io); /* Install the built-in real backend: libcurl, falling back to WinHTTP on Windows. */ SPCAT_API int spcat_use_curl(void); /* Install the built-in in-process fake (corpus replay + error injection, SPEC 0.2). */ SPCAT_API int spcat_use_fake(void); SPCAT_API const char *spcat_last_error(void); SPCAT_API long spcat_last_http_code(void); /* ContentHash response header of the last homepage fetch (-1 if absent). SPEC D4. */ SPCAT_API long long spcat_last_content_hash(void); /* Host override (tests). NULL resets to https://gcp.scorpioplayer.com. */ SPCAT_API void spcat_set_host(const char *host); /* Free all retained docs, cache and state. Call at process teardown. */ SPCAT_API void spcat_shutdown(void); /* ---- cache config (SPEC 3) ---- */ /* seconds; 0 = keep current/default (home 900, person 21600, popular 1560, collections 1560) */ SPCAT_API void spcat_cache_set_ttl(int home_s, int person_s, int popular_s, int collections_s); /* ---- homepage ---- */ /* userId NULL/"" = anonymous (profileId forced 0 server-side, SPEC D5). * Returns SPCAT_OK or SPCAT_UNCHANGED (both leave the previous homepage valid). */ SPCAT_API int spcat_get_homepage(const char *userId, int profileId, const char *language, unsigned opts); /* stable-hash (djb2-utf16, media-hash algorithm) of the last fetched homepage JSON. */ SPCAT_API long long spcat_homepage_hash(void); /* Send as the MD5HomePage request header on the next fetch; 0 = don't send. */ SPCAT_API void spcat_set_homepage_hash(long long h); /* The last fetched inflated JSON, NUL-terminated, valid until the next homepage fetch. */ SPCAT_API const char *spcat_home_json(void); /* Parse a homepage JSON document directly (the shell's disk cache, tests, fuzzers). * Same retain/swap semantics as a fetch: SPCAT_OK leaves the new doc live. */ SPCAT_API int spcat_parse_homepage_json(const char *json, size_t len); SPCAT_API int spcat_home_list_count(void); SPCAT_API const char *spcat_home_list_id(int i); SPCAT_API const char *spcat_home_list_value(int i); SPCAT_API int spcat_home_continues_count(void); SPCAT_API const char *spcat_home_continue_imdb(int i); SPCAT_API int spcat_home_continue_season(int i); SPCAT_API int spcat_home_continue_episode(int i); SPCAT_API double spcat_home_continue_value(int i); SPCAT_API long long spcat_home_continue_size(int i); SPCAT_API const char *spcat_home_continue_duration(int i); SPCAT_API const char *spcat_home_continue_size_str(int i); SPCAT_API int spcat_home_continue_is_duration(int i); SPCAT_API const char *spcat_home_continue_updated(int i); SPCAT_API int spcat_home_level30_count(void); SPCAT_API const char *spcat_home_level30_imdb(int i); SPCAT_API long long spcat_home_level30_size(int i); SPCAT_API const char *spcat_home_level30_filename(int i); SPCAT_API int spcat_home_spotlight_count(void); SPCAT_API const char *spcat_home_spotlight_logo(int i); SPCAT_API const char *spcat_home_spotlight_items(int i); /* comma-joined IMDb ids, raw */ SPCAT_API const char *spcat_home_spotlight_title(int i); SPCAT_API int spcat_home_spotlight_order(int i); SPCAT_API int spcat_home_extent_count(void); SPCAT_API const char *spcat_home_extent_id(int i); SPCAT_API const char *spcat_home_extent_value(int i); SPCAT_API int spcat_home_basics_count(void); SPCAT_API const char *spcat_home_basic_imdb(int i); SPCAT_API const char *spcat_home_basic_title(int i); SPCAT_API int spcat_home_basic_id(int i); /* -1 absent */ SPCAT_API int spcat_home_basic_year(int i); /* -1 absent */ SPCAT_API int spcat_home_basic_duration(int i); /* -1 absent */ SPCAT_API int spcat_home_basic_is_tv(int i); /* -1 unknown, 0/1 */ SPCAT_API const char *spcat_home_basic_tagline(int i); SPCAT_API const char *spcat_home_basic_plot(int i); SPCAT_API const char *spcat_home_basic_poster(int i); SPCAT_API const char *spcat_home_basic_picture(int i); SPCAT_API int spcat_home_basic_genres_count(int i); SPCAT_API const char *spcat_home_basic_genre(int i, int g); SPCAT_API int spcat_home_basic_directors_count(int i); SPCAT_API const char *spcat_home_basic_director(int i, int d); SPCAT_API int spcat_home_basic_ratings_count(int i); SPCAT_API const char *spcat_home_basic_rating_source(int i, int r); SPCAT_API double spcat_home_basic_rating_value(int i, int r); /* generic string field: title|tagline|plot|pictureurl|posterurl|imdbid (case-insensitive) */ SPCAT_API const char *spcat_home_basic_field(int i, const char *field); SPCAT_API int spcat_home_has_userinfo(void); /* 0/1 */ SPCAT_API const char *spcat_home_user_id(void); SPCAT_API const char *spcat_home_user_email(void); SPCAT_API int spcat_home_user_memberships_count(void); SPCAT_API int spcat_home_user_membership_type(int i); SPCAT_API const char *spcat_home_user_membership_name(int i); SPCAT_API int spcat_home_user_membership_active(int i); SPCAT_API const char *spcat_home_user_membership_expiration(int i); SPCAT_API int spcat_home_user_profiles_count(void); SPCAT_API int spcat_home_user_profile_id(int i); SPCAT_API const char *spcat_home_user_profile_name(int i); SPCAT_API const char *spcat_home_user_profile_poster(int i); SPCAT_API int spcat_home_user_profile_deleted(int i); SPCAT_API int spcat_home_user_profile_enabled(int i); SPCAT_API int spcat_home_user_profile_empty(int i); SPCAT_API int spcat_home_peoples_count(void); /* null/absent => 0 (SPEC D8) */ SPCAT_API int spcat_home_people_id(int i); SPCAT_API const char *spcat_home_people_name(int i); SPCAT_API const char *spcat_home_people_knowsfor(int i); SPCAT_API const char *spcat_home_people_profileurl(int i); SPCAT_API int spcat_home_collections_count(void); SPCAT_API int spcat_home_collection_id(int i); SPCAT_API const char *spcat_home_collection_name(int i); SPCAT_API int spcat_home_collection_playlists_count(int i); SPCAT_API const char *spcat_home_collection_playlist_name(int i, int p); SPCAT_API int spcat_home_collection_playlist_imdb_count(int i, int p); SPCAT_API const char *spcat_home_collection_playlist_imdb(int i, int p, int k); /* ---- collections endpoint ---- */ SPCAT_API int spcat_get_collections(const char *language); SPCAT_API int spcat_collection_count(void); SPCAT_API int spcat_collection_id(int i); SPCAT_API const char *spcat_collection_name(int i); SPCAT_API const char *spcat_collection_backdrop(int i); SPCAT_API const char *spcat_collection_cover(int i); SPCAT_API const char *spcat_collection_logo(int i); SPCAT_API int spcat_collection_is_auto(int i); /* -1 absent, 0/1 */ SPCAT_API int spcat_collection_playlists_count(int i); SPCAT_API const char *spcat_collection_playlist_name(int i, int p); SPCAT_API const char *spcat_collection_playlist_origin(int i, int p); SPCAT_API const char *spcat_collection_playlist_logo(int i, int p); SPCAT_API int spcat_collection_playlist_imdb_count(int i, int p); SPCAT_API const char *spcat_collection_playlist_imdb(int i, int p, int k); /* ---- people detail ---- */ /* id: nmID or TMDb numeric person id (SPEC D14). 404 => SPCAT_ERR_NOT_FOUND. */ SPCAT_API int spcat_get_people_detail(const char *id, const char *language); SPCAT_API int spcat_people_id(void); /* -1 absent */ SPCAT_API const char *spcat_people_name(void); SPCAT_API const char *spcat_people_knowsfor(void); SPCAT_API const char *spcat_people_profileurl(void); SPCAT_API const char *spcat_people_imdbid(void); SPCAT_API const char *spcat_people_biography(void); SPCAT_API const char *spcat_people_birthday(void); SPCAT_API const char *spcat_people_deathday(void); SPCAT_API const char *spcat_people_homepage(void); SPCAT_API const char *spcat_people_placeofbirth(void); SPCAT_API const char *spcat_people_knownfor_department(void); SPCAT_API const char *spcat_people_knowncredits(void); SPCAT_API int spcat_people_gender(void); /* -1 absent */ SPCAT_API int spcat_people_popularity_permille(void); /* per-mille; -1 absent */ SPCAT_API int spcat_people_names_translate_count(void); SPCAT_API const char *spcat_people_names_translate(int i); SPCAT_API int spcat_people_pictures_count(void); SPCAT_API const char *spcat_people_picture_url(int i); SPCAT_API const char *spcat_people_picture_lang(int i); SPCAT_API int spcat_people_picture_w(int i); SPCAT_API int spcat_people_picture_h(int i); SPCAT_API int spcat_people_related_count(void); SPCAT_API const char *spcat_people_related(int i); /* ---- people popular ---- */ /* pageIndex MUST be >= 1 (0 => SPCAT_ERR_INVALID_ARG; the server 404s it — SPEC D17). * pageSize is the C# shape-parity parameter the URL never carries (unused, validated). */ SPCAT_API int spcat_get_people_popular(int pageIndex, int pageSize, int pageNumbers, const char *language); SPCAT_API int spcat_people_pop_count(void); SPCAT_API int spcat_people_pop_id(int i); SPCAT_API const char *spcat_people_pop_name(int i); SPCAT_API const char *spcat_people_pop_knowsfor(int i); SPCAT_API const char *spcat_people_pop_profileurl(int i); SPCAT_API const char *spcat_people_pop_imdbid(int i); /* ---- cache introspection (SPEC 3) ---- */ /* what: "home" | "collections" | "person" | "popular" | "*" ; key: "" = any */ SPCAT_API void spcat_cache_clear(void); SPCAT_API void spcat_cache_invalidate(const char *what, const char *key); SPCAT_API int spcat_cache_has(const char *what, const char *key, int *out_has); SPCAT_API int spcat_cache_entries(void); /* ---- fake backend (tests / .console --test; in-process, zero sockets) ---- */ /* Point the fake at a corpus dir (files named per PROVENANCE.md) and install it. */ SPCAT_API int spcat_fake_corpus(const char *dir); /* 0=replay 1=transport-fail 2=http-500 3=http-404 4=malformed 5=empty 6=json-null 7=byte-ff */ SPCAT_API int spcat_fake_mode(int mode); SPCAT_API long long spcat_fake_url_count(void); SPCAT_API long long spcat_fake_fail_count(void); SPCAT_API long long spcat_fake_calls(void); SPCAT_API const char *spcat_fake_last_url(void); SPCAT_API void spcat_fake_reset(void); #ifdef __cplusplus } #endif #endif /* SPCAT_H */