diff --git a/src/providers/perverzija.rs b/src/providers/perverzija.rs index 66abb8c..14ca541 100644 --- a/src/providers/perverzija.rs +++ b/src/providers/perverzija.rs @@ -105,9 +105,7 @@ impl PerverzijaProvider { } } async fn query(&self, cache: VideoCache, pool:DbPool, page: u8, query: &str) -> Result> { - - - + let mut query_parse = true; let search_string = query.replace(" ", "+"); let mut url = format!( "{}page/{}/?s={}", @@ -117,6 +115,17 @@ impl PerverzijaProvider { url = format!("{}?s={}", self.url, search_string); } + if query.starts_with("@studio:") { + let studio_name = query.replace("@studio:", ""); + url = format!("{}studio/{}/page/{}/", self.url, studio_name, page); + query_parse = false; + } else if query.starts_with("@stars:") { + let stars_name = query.replace("@stars:", ""); + url = format!("{}stars/{}/page/{}/", self.url, stars_name, page); + query_parse = false; + } + url = url.replace("page/1/", ""); + println!("Query URL: {}", url); // Check our Video Cache. If the result is younger than 1 hour, we return it. let old_items = match cache.get(&url) { Some((time, items)) => { @@ -139,7 +148,12 @@ impl PerverzijaProvider { let response = client.get(url.clone()).send().await?; if response.status().is_success() { let text = response.text().await?; - let video_items: Vec = self.get_video_items_from_html_query(text.clone(), pool).await; + let video_items: Vec = match query_parse{ + true => { println!("query"); + self.get_video_items_from_html_query(text.clone(), pool).await}, + false => { println!("no query"); + self.get_video_items_from_html(text.clone(), pool)} + }; if !video_items.is_empty() { cache.remove(&url); cache.insert(url.clone(), video_items.clone()); @@ -192,6 +206,9 @@ impl PerverzijaProvider { if vid.len() > 20 { continue; } + for (index, line) in vid.iter().enumerate() { + println!("Line {}: {}", index, line.to_string().trim()); + } let mut title = vid[1].split(">").collect::>()[1] .split("<") .collect::>()[0] @@ -247,6 +264,28 @@ impl PerverzijaProvider { let embed = VideoEmbed::new(embed_html, url.clone()); let mut tags: Vec = Vec::new(); // Placeholder for tags, adjust as needed + + let studios_parts = vid[7].split("a href=\"").collect::>(); + for studio in studios_parts.iter().skip(1) { + if studio.starts_with("https://tube.perverzija.com/studio/"){ + tags.push( + studio.split("/\"").collect::>()[0] + .replace("https://tube.perverzija.com/studio/", "@studio:") + .to_string(), + ); + } + } + + for tag in vid[0].split(" ").collect::>(){ + if tag.starts_with("stars-") { + let tag_name = tag.split("stars-").collect::>()[1].split("\"").collect::>()[0] + .to_string(); + if !tag_name.is_empty() { + tags.push(format!("@stars:{}", tag_name)); + } + } + } + for tag in vid[0].split(" ").collect::>(){ if tag.starts_with("tag-") { let tag_name = tag.split("tag-").collect::>()[1]