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:
- Domain extraction – Determines the Kodik domain from the provided URL.
- HTML retrieval – Downloads the initial page HTML.
- Video info extraction – Parses the embedded video information payload.
- API endpoint resolution – If not cached, discovers the video info API endpoint.
- Player data request – Sends a POST request to retrieve player data.
- Link decoding – Decrypts and normalizes streaming URLs.
The function uses a cached VIDEO_INFO_ENDPOINT to avoid repeated endpoint lookups.
§Arguments
client– Anreqwest::Clientused 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}");