various bugfixes

This commit is contained in:
Simon
2026-01-13 18:13:51 +00:00
parent aaff7d00c6
commit 34992242b7
21 changed files with 243 additions and 289 deletions

View File

@@ -1,6 +1,7 @@
use crate::DbPool;
use crate::providers::Provider;
use crate::util::cache::VideoCache;
use crate::util::discord::format_error_chain;
use crate::util::discord::send_discord_error_report;
use crate::util::requester::Requester;
use crate::util::time::parse_time_to_seconds;
@@ -26,14 +27,6 @@ error_chain! {
}
}
// fn has_blacklisted_class(element: &ElementRef, blacklist: &[&str]) -> bool {
// element
// .value()
// .attr("class")
// .map(|classes| classes.split_whitespace().any(|c| blacklist.contains(&c)))
// .unwrap_or(false)
// }
#[derive(Debug, Clone)]
pub struct SxyprnProvider {
url: String,
@@ -97,6 +90,15 @@ impl SxyprnProvider {
Ok(items) => items,
Err(e) => {
println!("Error parsing video items: {}", e);
send_discord_error_report(
e.to_string(),
Some(format_error_chain(&e)),
Some("Sxyprn Provider"),
Some(&format!("URL: {}", url_str)),
file!(),
line!(),
module_path!(),
).await;
return Ok(old_items);
}
};
@@ -159,14 +161,16 @@ impl SxyprnProvider {
{
Ok(items) => items,
Err(e) => {
println!("Error parsing video items: {}", e);
let _ = futures::executor::block_on(send_discord_error_report(
&e,
println!("Error parsing video items: {}", e);// 1. Convert the error to a string immediately
send_discord_error_report(
e.to_string(),
Some(format_error_chain(&e)),
Some("Sxyprn Provider"),
Some(format!("Failed to query videos:\nURL: {}\nQuery: {},", url_str, query).as_str()),
Some(&format!("URL: {}", url_str)),
file!(),
line!(),
module_path!(),));
module_path!(),
).await;
return Ok(old_items);
}
};
@@ -223,7 +227,7 @@ impl SxyprnProvider {
let title_parts = video_segment
.split("post_text")
.nth(1)
.and_then(|s| s.split("style=''>").nth(1))
.and_then(|s| s.split("style=''>").nth(100000))
.and_then(|s| s.split("</div>").next())
.ok_or_else(|| ErrorKind::Parse("failed to extract title_parts".into()))?;