Skip to main content

parse

Function parse 

Source
pub async fn parse(client: &Client, url: &str) -> Result<Response, Error>
Expand description

Parses a Kodik player page asynchronously and returns structured video stream information.

This function performs the complete sequence of operations required to fetch, extract, and decode player data from a given Kodik URL:

  1. Domain extraction – Determines the Kodik domain from the provided URL.
  2. HTML retrieval – Downloads the initial page HTML.
  3. Video info extraction – Parses the embedded video information payload.
  4. API endpoint resolution – If not cached, discovers the video info API endpoint.
  5. Player data request – Sends a POST request to retrieve player data.
  6. Link decoding – Decrypts and normalizes streaming URLs.

The function uses a cached VIDEO_INFO_ENDPOINT to avoid repeated endpoint lookups.

§Arguments

  • client – An reqwest::Client used for making HTTP requests.
  • url – A full Kodik player page URL.

§Returns

A [KodikResponse] containing structured player metadata and stream URLs.

§Errors

Returns an error if:

  • The domain cannot be extracted from the URL.
  • Network requests fail.
  • HTML parsing fails due to unexpected format changes.
  • The API endpoint cannot be found.
  • Link decoding fails.

§Example

use kodik_parser::reqwest::Client;

let client = Client::new();
let url = "https://kodikplayer.com/some-type/some-id/some-hash/some-quality";
let kodik_response = kodik_parser::parse(&client, url).await.unwrap();

let link_720 = &kodik_response.links.quality_720.first().unwrap().src;
println!("Link with 720p quality is: {link_720}");