kodik_parser/
scraper.rs

1use serde::Deserialize;
2
3#[derive(Debug, Deserialize)]
4pub struct PlayerResponse {
5    pub(crate) advert_script: String,
6    pub(crate) domain: String,
7    pub(crate) default: u32,
8    pub(crate) links: Links,
9    pub(crate) ip: String,
10}
11
12impl PlayerResponse {
13    pub fn advert_script(&self) -> &str {
14        &self.advert_script
15    }
16
17    pub fn domain(&self) -> &str {
18        &self.domain
19    }
20
21    pub const fn default(&self) -> u32 {
22        self.default
23    }
24
25    pub const fn links(&self) -> &Links {
26        &self.links
27    }
28
29    pub fn ip(&self) -> &str {
30        &self.ip
31    }
32}
33
34#[derive(Debug, Deserialize)]
35pub struct Links {
36    #[serde(rename = "360")]
37    pub(crate) quality_360: Vec<Link>,
38    #[serde(rename = "480")]
39    pub(crate) quality_480: Vec<Link>,
40    #[serde(rename = "720")]
41    pub(crate) quality_720: Vec<Link>,
42}
43
44impl Links {
45    fn quality_360(&self) -> &[Link] {
46        &self.quality_360
47    }
48
49    fn quality_480(&self) -> &[Link] {
50        &self.quality_480
51    }
52
53    fn quality_720(&self) -> &[Link] {
54        &self.quality_720
55    }
56}
57
58#[derive(Debug, Deserialize)]
59pub struct Link {
60    pub(crate) src: String,
61    #[serde(rename = "type")]
62    pub(crate) mime_type: String,
63}
64
65impl Link {
66    fn src(&self) -> &str {
67        &self.src
68    }
69
70    fn mime_type(&self) -> &str {
71        &self.mime_type
72    }
73}