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