Skip to main content

StalkerClient

Struct StalkerClient 

Source
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

Source

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.
Source

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).

Source

pub fn with_backoff(self, backoff: BackoffConfig) -> Self

Set the backoff configuration for retries.

Source

pub fn with_concurrency(self, concurrency: usize) -> Self

Set the concurrency limit for parallel pagination.

Source

pub fn with_token_validity(self, secs: u64) -> Self

Set the token validity period in seconds.

Source

pub async fn authenticate(&mut self) -> Result<(), StalkerError>

Discover the portal, perform handshake, and authenticate.

Must be called before any data-fetching methods.

Source

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

Source

pub async fn get_account_info(&self) -> Result<StalkerAccountInfo, StalkerError>

Get account information.

Source

pub async fn get_profile(&self) -> Result<StalkerProfile, StalkerError>

Get profile information.

Source

pub async fn get_genres(&self) -> Result<Vec<StalkerCategory>, StalkerError>

Get channel categories / genres.

Source

pub async fn get_vod_categories( &self, ) -> Result<Vec<StalkerCategory>, StalkerError>

Get VOD categories.

Source

pub async fn get_series_categories( &self, ) -> Result<Vec<StalkerCategory>, StalkerError>

Get series categories.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source

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

Source

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].

Source

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.

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.

Source

pub async fn keepalive(&self) -> Result<(), StalkerError>

Send a keepalive / watchdog event to prevent session timeout.

Source

pub fn is_authenticated(&self) -> bool

Whether the client has an active session.

Source

pub fn portal_url(&self) -> Option<&str>

Get the discovered portal URL, if authenticated.

Source

pub fn is_token_expired(&self) -> bool

Whether the token is expired and needs refresh.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more