/* scorpiox-scorpioplayer-subtitle-fetch — find and download subtitle / lyric files. * * Pure C99. Bytes + metadata out; parsing is scorpiox-scorpioplayer-subtitle-parse's job. * Transport is the scorpiox_io vtable only (scorpiox-io.h). See SPEC.md for every decision. * * Not thread-safe: one process-global engine, like every scorpiox-scorpioplayer-* sibling. */ #ifndef SPSUBFETCH_H #define SPSUBFETCH_H #include #include "scorpiox-io.h" #if defined(SPSF_STATIC) # define SPSF_API #elif defined(_WIN32) # if defined(SPSF_BUILD) # define SPSF_API __declspec(dllexport) # else # define SPSF_API __declspec(dllimport) # endif #else # define SPSF_API __attribute__((visibility("default"))) #endif #ifdef __cplusplus extern "C" { #endif /* ---- return codes (D25) — numbers match spmovie, plus RESTRICTED ---- */ #define SPSF_OK 0 #define SPSF_ERR_TRANSPORT 1 #define SPSF_ERR_HTTP 2 #define SPSF_ERR_PARSE 3 #define SPSF_ERR_EMPTY 4 #define SPSF_ERR_NOT_FOUND 5 #define SPSF_ERR_INVALID_ARG 6 #define SPSF_ERR_NO_IO 7 #define SPSF_ERR_OOM 8 #define SPSF_ERR_RESTRICTED 9 /* ---- providers: bitmask (D2) ---- */ #define SPSF_P_SHOOTER 1 #define SPSF_P_OSDB 2 #define SPSF_P_SUBHUB 4 #define SPSF_P_NETEASE 8 #define SPSF_P_SUBTITLES 7 /* SHOOTER|OSDB|SUBHUB */ /* ---- per-provider status after the last search (D26) ---- */ #define SPSF_ST_NOT_QUERIED 0 #define SPSF_ST_WORKING 1 /* >= 1 result */ #define SPSF_ST_EMPTY 2 /* reachable, valid response, zero results */ #define SPSF_ST_PARSE 3 /* reachable, 2xx, response unusable: ROT */ #define SPSF_ST_DOWN 4 /* transport failure / 5xx / unexpected 4xx */ #define SPSF_ST_RESTRICTED 5 /* answered but refuses (VIP nag, 401, 403) */ /* ---- Subhub search methods (Subhub.cs SearchMethod) ---- */ #define SPSF_SUBHUB_HASH 1 #define SPSF_SUBHUB_FULLTEXT 2 #define SPSF_SUBHUB_IMDB 4 /* ---- lifecycle / transport ---- */ SPSF_API const char *spsubfetch_version(void); SPSF_API void spsubfetch_set_io(const scorpiox_io *io); /* copied; NULL = uninstall */ SPSF_API int spsubfetch_set_fake_io(const char *canned_dir); /* offline replay backend (D27) */ SPSF_API int spsubfetch_set_host(int provider, const char *base_url); /* NULL = default (D29) */ SPSF_API const char *spsubfetch_host(int provider); SPSF_API void spsubfetch_shutdown(void); /* frees results, token, io */ SPSF_API const char *spsubfetch_last_error(void); SPSF_API long spsubfetch_last_http_code(void); SPSF_API const char *spsubfetch_error_name(int code); SPSF_API const char *spsubfetch_status_name(int status); /* ---- hashes — delegated to vendored scorpiox-scorpioplayer-media-hash (D24) ---- */ SPSF_API const char *spsubfetch_hash_shooter(const char *path); /* NULL on failure */ SPSF_API const char *spsubfetch_hash_opensubtitles(const char *path); /* NULL on failure */ SPSF_API long long spsubfetch_file_size(const char *path); /* -1 on failure */ /* ---- search ---- */ /* Any argument may be NULL/0 if unknown. providers = SPSF_P_* mask (0 = SPSF_P_SUBTITLES). */ SPSF_API int spsubfetch_search(const char *hash_shooter, const char *hash_osdb, long long file_size, const char *filename, const char *lang, int providers); /* One Subhub query with an explicit method (SubhubDialog.xaml.cs:153-170). */ SPSF_API int spsubfetch_search_subhub(int method, const char *query, long long file_size, const char *lang); /* Audio-only path: lyrics by title + artist (CaptionService.cs:69-80, D20). */ SPSF_API int spsubfetch_search_by_title(const char *title, const char *artist, const char *lang); SPSF_API int spsubfetch_provider_status(int provider); /* single SPSF_P_* bit */ SPSF_API long spsubfetch_provider_http_code(int provider); /* ---- results (engine-owned, valid until next search / shutdown) ---- */ SPSF_API int spsubfetch_result_count(void); SPSF_API int spsubfetch_result_provider(int i); /* SPSF_P_* bit, 0 if out of range */ SPSF_API const char *spsubfetch_result_filename(int i); SPSF_API const char *spsubfetch_result_language(int i); SPSF_API const char *spsubfetch_result_ext(int i); /* ".srt"; "" until known */ SPSF_API const char *spsubfetch_result_id(int i); SPSF_API int spsubfetch_download(int i); SPSF_API const unsigned char *spsubfetch_data(int i, size_t *len); /* raw bytes; caller copies */ /* ---- OSDbConfig language table (OSDbConfig.cs:36-109, D11) ---- */ SPSF_API int spsubfetch_lang_count(void); SPSF_API const char *spsubfetch_lang_iso6392(int i); SPSF_API const char *spsubfetch_lang_iso6391(int i); SPSF_API const char *spsubfetch_lang_name(int i); SPSF_API const char *spsubfetch_lang_to_osdb(const char *langs); /* "en,fr" -> "eng,fre" */ /* ---- fake backend introspection (tests / .console harness prove the request shape) ---- */ SPSF_API const char *spsubfetch_fake_last_url(void); SPSF_API const char *spsubfetch_fake_last_body(void); SPSF_API int spsubfetch_fake_request_count(void); #ifdef __cplusplus } #endif #endif