pub struct StalkerClient { /* private fields */ }Expand description
Async client for Stalker/MAG middleware portals.
The client is stateful — after calling authenticate(),
it retains the session token and cookies for subsequent API calls.
Implementations§
Source§impl StalkerClient
impl StalkerClient
Sourcepub fn new(
credentials: StalkerCredentials,
accept_invalid_certs: bool,
) -> Result<Self, StalkerError>
pub fn new( credentials: StalkerCredentials, accept_invalid_certs: bool, ) -> Result<Self, StalkerError>
Create a new client for the given portal credentials.
§Arguments
credentials— Portal base URL and MAC address.accept_invalid_certs— Whether to accept self-signed TLS certificates.
Sourcepub fn with_http_client(credentials: StalkerCredentials, http: Client) -> Self
pub fn with_http_client(credentials: StalkerCredentials, http: Client) -> Self
Create a client with a pre-built reqwest::Client (for testing or
connection pool sharing).
Sourcepub fn with_backoff(self, backoff: BackoffConfig) -> Self
pub fn with_backoff(self, backoff: BackoffConfig) -> Self
Set the backoff configuration for retries.
Sourcepub fn with_concurrency(self, concurrency: usize) -> Self
pub fn with_concurrency(self, concurrency: usize) -> Self
Set the concurrency limit for parallel pagination.
Sourcepub fn with_token_validity(self, secs: u64) -> Self
pub fn with_token_validity(self, secs: u64) -> Self
Set the token validity period in seconds.
Sourcepub async fn authenticate(&mut self) -> Result<(), StalkerError>
pub async fn authenticate(&mut self) -> Result<(), StalkerError>
Discover the portal, perform handshake, and authenticate.
Must be called before any data-fetching methods.
Sourcepub async fn ensure_token(&mut self) -> Result<(), StalkerError>
pub async fn ensure_token(&mut self) -> Result<(), StalkerError>
Ensure the token is still valid; re-authenticate if expired.
Python: ensure_token() — checks (now - timestamp) > validity_period
TypeScript: ensureToken() — with promise-based locking
Sourcepub async fn get_account_info(&self) -> Result<StalkerAccountInfo, StalkerError>
pub async fn get_account_info(&self) -> Result<StalkerAccountInfo, StalkerError>
Get account information.
Sourcepub async fn get_profile(&self) -> Result<StalkerProfile, StalkerError>
pub async fn get_profile(&self) -> Result<StalkerProfile, StalkerError>
Get profile information.
Sourcepub async fn get_genres(&self) -> Result<Vec<StalkerCategory>, StalkerError>
pub async fn get_genres(&self) -> Result<Vec<StalkerCategory>, StalkerError>
Get channel categories / genres.
Sourcepub async fn get_vod_categories(
&self,
) -> Result<Vec<StalkerCategory>, StalkerError>
pub async fn get_vod_categories( &self, ) -> Result<Vec<StalkerCategory>, StalkerError>
Get VOD categories.
Sourcepub async fn get_series_categories(
&self,
) -> Result<Vec<StalkerCategory>, StalkerError>
pub async fn get_series_categories( &self, ) -> Result<Vec<StalkerCategory>, StalkerError>
Get series categories.
Sourcepub async fn get_channels_page(
&self,
genre_id: &str,
page: u32,
) -> Result<PaginatedResult<StalkerChannel>, StalkerError>
pub async fn get_channels_page( &self, genre_id: &str, page: u32, ) -> Result<PaginatedResult<StalkerChannel>, StalkerError>
Get a single page of channels for a genre.
Sourcepub async fn get_all_channels(
&self,
genre_id: &str,
on_progress: Option<&dyn Fn(u32, u32)>,
) -> Result<Vec<StalkerChannel>, StalkerError>
pub async fn get_all_channels( &self, genre_id: &str, on_progress: Option<&dyn Fn(u32, u32)>, ) -> Result<Vec<StalkerChannel>, StalkerError>
Get all channels for a genre, auto-paginating with parallel fetching.
Python: ThreadPoolExecutor with num_threads workers
TypeScript: Promise.all with BATCH_SIZE = 4
on_progress receives (completed_pages, total_pages) after each page.
Sourcepub async fn get_vod_page(
&self,
category_id: &str,
page: u32,
) -> Result<PaginatedResult<StalkerVodItem>, StalkerError>
pub async fn get_vod_page( &self, category_id: &str, page: u32, ) -> Result<PaginatedResult<StalkerVodItem>, StalkerError>
Get a single page of VOD items for a category.
Sourcepub async fn get_all_vod(
&self,
category_id: &str,
on_progress: Option<&dyn Fn(u32, u32)>,
) -> Result<Vec<StalkerVodItem>, StalkerError>
pub async fn get_all_vod( &self, category_id: &str, on_progress: Option<&dyn Fn(u32, u32)>, ) -> Result<Vec<StalkerVodItem>, StalkerError>
Get all VOD items for a category (movies only, excluding series).
Python: get_vod_in_category() — filters by is_series != "1"
on_progress receives (completed_pages, total_pages) after each page.
Sourcepub async fn get_all_series(
&self,
category_id: &str,
on_progress: Option<&dyn Fn(u32, u32)>,
) -> Result<Vec<StalkerSeriesItem>, StalkerError>
pub async fn get_all_series( &self, category_id: &str, on_progress: Option<&dyn Fn(u32, u32)>, ) -> Result<Vec<StalkerSeriesItem>, StalkerError>
Get all series items for a category (series only, is_series = "1").
Python: get_series_in_category() — filters by is_series == "1"
on_progress receives (completed_pages, total_pages) after each page.
Sourcepub async fn get_series_page(
&self,
category_id: &str,
page: u32,
) -> Result<PaginatedResult<StalkerSeriesItem>, StalkerError>
pub async fn get_series_page( &self, category_id: &str, page: u32, ) -> Result<PaginatedResult<StalkerSeriesItem>, StalkerError>
Get a single page of series items for a category.
Sourcepub async fn get_seasons(
&self,
movie_id: &str,
) -> Result<Vec<StalkerSeason>, StalkerError>
pub async fn get_seasons( &self, movie_id: &str, ) -> Result<Vec<StalkerSeason>, StalkerError>
Get seasons for a series/movie.
Python: get_seasons(movie_id) — fetches with movie_id={id}&season_id=0&episode_id=0
TypeScript: getSeasons(movieId) — same query pattern
Sourcepub async fn get_episodes(
&self,
movie_id: &str,
season_id: &str,
) -> Result<Vec<StalkerEpisode>, StalkerError>
pub async fn get_episodes( &self, movie_id: &str, season_id: &str, ) -> Result<Vec<StalkerEpisode>, StalkerError>
Get episodes for a season.
Python: get_episodes(movie_id, season_id) — movie_id={id}&season_id={sid}&episode_id=0
Sourcepub async fn get_series_info(
&self,
series: StalkerSeriesItem,
) -> Result<StalkerSeriesDetail, StalkerError>
pub async fn get_series_info( &self, series: StalkerSeriesItem, ) -> Result<StalkerSeriesDetail, StalkerError>
Fetch full series detail: seasons + episodes for each season.
series is the pre-fetched series metadata. The method calls
get_seasons and then get_episodes for each season, returning
everything in a single [StalkerSeriesDetail].
Sourcepub async fn get_epg(
&self,
channel_id: &str,
size: u32,
) -> Result<Vec<StalkerEpgEntry>, StalkerError>
pub async fn get_epg( &self, channel_id: &str, size: u32, ) -> Result<Vec<StalkerEpgEntry>, StalkerError>
Get EPG data for a channel using dual endpoint fallback.
Python Epg.py: tries get_short_epg first, falls back to get_epg_info.
TypeScript: same pattern.
Sourcepub async fn create_link(&self, cmd: &str) -> Result<String, StalkerError>
pub async fn create_link(&self, cmd: &str) -> Result<String, StalkerError>
Resolve a channel’s stream URL via the create_link endpoint.
This calls the portal to resolve cmd into a playable URL.
For simple URLs, prefer resolve_stream_url()
which is a pure function.
Sourcepub async fn keepalive(&self) -> Result<(), StalkerError>
pub async fn keepalive(&self) -> Result<(), StalkerError>
Send a keepalive / watchdog event to prevent session timeout.
Sourcepub fn is_authenticated(&self) -> bool
pub fn is_authenticated(&self) -> bool
Whether the client has an active session.
Sourcepub fn portal_url(&self) -> Option<&str>
pub fn portal_url(&self) -> Option<&str>
Get the discovered portal URL, if authenticated.
Sourcepub fn is_token_expired(&self) -> bool
pub fn is_token_expired(&self) -> bool
Whether the token is expired and needs refresh.