sites in tags
This commit is contained in:
@@ -31,11 +31,3 @@ async-trait = "0.1"
|
|||||||
unexpected_cfgs = "allow"
|
unexpected_cfgs = "allow"
|
||||||
# Or keep it as a warning but whitelist the cfg:
|
# Or keep it as a warning but whitelist the cfg:
|
||||||
# unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_error_description_deprecated)'] }
|
# unexpected_cfgs = { level = "warn", check-cfg = ['cfg(has_error_description_deprecated)'] }
|
||||||
|
|
||||||
# Enable a small amount of optimization in the dev profile.
|
|
||||||
[profile.dev]
|
|
||||||
opt-level = 1
|
|
||||||
|
|
||||||
# Enable a large amount of optimization in the dev profile for dependencies.
|
|
||||||
[profile.dev.package."*"]
|
|
||||||
opt-level = 3
|
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ impl OmgxxxProvider {
|
|||||||
id: "sites".to_string(),
|
id: "sites".to_string(),
|
||||||
title: "Sites".to_string(),
|
title: "Sites".to_string(),
|
||||||
description: "Filter for different 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(),
|
colorName: "green".to_string(),
|
||||||
options: sites,
|
options: sites,
|
||||||
multiSelect: false,
|
multiSelect: false,
|
||||||
@@ -350,18 +350,18 @@ impl OmgxxxProvider {
|
|||||||
options: ServerOptions,
|
options: ServerOptions,
|
||||||
) -> Result<Vec<VideoItem>> {
|
) -> Result<Vec<VideoItem>> {
|
||||||
let mut search_type = "search";
|
let mut search_type = "search";
|
||||||
if query.starts_with("@models:") {
|
if query.starts_with("@") {
|
||||||
search_type = "models";
|
search_type = query.split(":").collect::<Vec<&str>>()[0].trim_start_matches("@");
|
||||||
}
|
}
|
||||||
let video_url = format!(
|
let video_url = format!(
|
||||||
"{}/{}/{}/{}/",
|
"{}/{}/{}/{}/",
|
||||||
self.url,
|
self.url,
|
||||||
search_type,
|
search_type,
|
||||||
query
|
query
|
||||||
|
.split(":").collect::<Vec<&str>>()[1]
|
||||||
.to_lowercase()
|
.to_lowercase()
|
||||||
.trim()
|
.trim()
|
||||||
.replace(" ", "-")
|
.replace(" ", "-"),
|
||||||
.replace("@models:", ""),
|
|
||||||
page
|
page
|
||||||
);
|
);
|
||||||
// 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.
|
||||||
@@ -392,6 +392,18 @@ impl OmgxxxProvider {
|
|||||||
Ok(video_items)
|
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> {
|
fn get_video_items_from_html(&self, html: String) -> Vec<VideoItem> {
|
||||||
if html.is_empty() {
|
if html.is_empty() {
|
||||||
println!("HTML is empty");
|
println!("HTML is empty");
|
||||||
@@ -467,8 +479,10 @@ impl OmgxxxProvider {
|
|||||||
.split("\"")
|
.split("\"")
|
||||||
.collect::<Vec<&str>>()[0]
|
.collect::<Vec<&str>>()[0]
|
||||||
.to_string();
|
.to_string();
|
||||||
|
let site_name = title.split("]").collect::<Vec<&str>>().first().unwrap_or(&"").trim_start_matches("[");
|
||||||
let tags = match video_segment.contains("class=\"models\">") {
|
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
|
true => video_segment
|
||||||
.split("class=\"models\">")
|
.split("class=\"models\">")
|
||||||
.collect::<Vec<&str>>()[1]
|
.collect::<Vec<&str>>()[1]
|
||||||
@@ -487,6 +501,9 @@ impl OmgxxxProvider {
|
|||||||
.to_vec(),
|
.to_vec(),
|
||||||
false => vec![],
|
false => vec![],
|
||||||
};
|
};
|
||||||
|
if !site_id.is_empty() {
|
||||||
|
tags.push(format!("@sites:{}", site_id));
|
||||||
|
}
|
||||||
|
|
||||||
let video_item = VideoItem::new(
|
let video_item = VideoItem::new(
|
||||||
id,
|
id,
|
||||||
|
|||||||
Reference in New Issue
Block a user