sites in tags
This commit is contained in:
@@ -251,7 +251,7 @@ impl OmgxxxProvider {
|
||||
id: "sites".to_string(),
|
||||
title: "Sites".to_string(),
|
||||
description: "Filter for different Sites".to_string(),
|
||||
systemImage: "list.bullet.indent".to_string(),
|
||||
systemImage: "rectangle.stack".to_string(),
|
||||
colorName: "green".to_string(),
|
||||
options: sites,
|
||||
multiSelect: false,
|
||||
@@ -350,18 +350,18 @@ impl OmgxxxProvider {
|
||||
options: ServerOptions,
|
||||
) -> Result<Vec<VideoItem>> {
|
||||
let mut search_type = "search";
|
||||
if query.starts_with("@models:") {
|
||||
search_type = "models";
|
||||
if query.starts_with("@") {
|
||||
search_type = query.split(":").collect::<Vec<&str>>()[0].trim_start_matches("@");
|
||||
}
|
||||
let video_url = format!(
|
||||
"{}/{}/{}/{}/",
|
||||
self.url,
|
||||
search_type,
|
||||
query
|
||||
.split(":").collect::<Vec<&str>>()[1]
|
||||
.to_lowercase()
|
||||
.trim()
|
||||
.replace(" ", "-")
|
||||
.replace("@models:", ""),
|
||||
.replace(" ", "-"),
|
||||
page
|
||||
);
|
||||
// Check our Video Cache. If the result is younger than 1 hour, we return it.
|
||||
@@ -392,6 +392,18 @@ impl OmgxxxProvider {
|
||||
Ok(video_items)
|
||||
}
|
||||
|
||||
fn get_site_id_from_name(&self, site_name: &str) -> Option<String> {
|
||||
// site_name.to_lowercase().replace(" ", "")
|
||||
for site in self.sites.read().unwrap().iter() {
|
||||
if site.title.to_lowercase().replace(" ", "") == site_name.to_lowercase().replace(" ", "") {
|
||||
return Some(site.id.clone());
|
||||
}
|
||||
}
|
||||
println!("Site not found for name: {}", site_name);
|
||||
println!("All Sites: {:?}", self.sites.read().unwrap());
|
||||
return None;
|
||||
}
|
||||
|
||||
fn get_video_items_from_html(&self, html: String) -> Vec<VideoItem> {
|
||||
if html.is_empty() {
|
||||
println!("HTML is empty");
|
||||
@@ -467,8 +479,10 @@ impl OmgxxxProvider {
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.to_string();
|
||||
|
||||
let tags = match video_segment.contains("class=\"models\">") {
|
||||
let site_name = title.split("]").collect::<Vec<&str>>().first().unwrap_or(&"").trim_start_matches("[");
|
||||
let site_id = self.get_site_id_from_name(site_name).unwrap_or("".to_string());
|
||||
println!("Site: {}\nTitle: {}", site_id, title);
|
||||
let mut tags = match video_segment.contains("class=\"models\">") {
|
||||
true => video_segment
|
||||
.split("class=\"models\">")
|
||||
.collect::<Vec<&str>>()[1]
|
||||
@@ -487,6 +501,9 @@ impl OmgxxxProvider {
|
||||
.to_vec(),
|
||||
false => vec![],
|
||||
};
|
||||
if !site_id.is_empty() {
|
||||
tags.push(format!("@sites:{}", site_id));
|
||||
}
|
||||
|
||||
let video_item = VideoItem::new(
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user