fix missing image
Some checks failed
MediaManager Scraper Boxnovel CI / Build Scraper Boxnovel Docker images (push) Waiting to run
MediaManager API CI / Build api Docker images (push) Successful in 2m17s
MediaManager Frontend CI / Build frontend Docker images (push) Has been cancelled

This commit is contained in:
2025-01-04 21:23:01 +00:00
parent 09dd1a49c6
commit 7b309a1e52

View File

@@ -8,9 +8,7 @@ use scraper::{Html, Selector};
fn main() {
let api_rpc_url = get_env("SERVICE_API_RPC_URL").unwrap();
let api = lib_scraper::api::RpcApi::new(
api_rpc_url.parse().unwrap(),
);
let api = lib_scraper::api::RpcApi::new(api_rpc_url.parse().unwrap());
let source_name = get_env("SERVICE_SOURCE_NAME").unwrap();
let source_url = get_env("SERVICE_SOURCE_URL").unwrap();
@@ -178,14 +176,16 @@ impl BoxnovelSource {
url: url.clone(),
})
.map(|e| {
e.attr("src").ok_or(Error::InvalidElement {
e.attr("data-src").ok_or(Error::InvalidElement {
msg: "src in img missing".to_string(),
url: url.clone(),
})
})
.ok()
.and_then(|i| i.ok())
.map(|s| self.get_cover(s.to_string()))
.map(|s| {
self.get_cover(s.to_string())
})
.transpose()
{
Ok(c) => c,
@@ -244,8 +244,9 @@ impl BoxnovelSource {
})?;
let res = self.client.get(url.clone()).send()?;
let bytes = res.bytes()?;
let cover_b64 = lib_utils::b64::b64_encode(res.bytes()?);
let cover_b64 = lib_utils::b64::b64_encode(bytes);
let d_url = format!("data:image/{};base64,{}", image_ending, cover_b64);
@@ -319,7 +320,8 @@ impl BoxnovelSource {
.as_str()
.to_string();
let after_patter = r"^\s*(?:(?:Chapter\s?\d+)(?::?|\s?-)?\s*)?(?P<title>.*)$";
let after_patter =
r"^\s*(?:(?:Chapter\s?\d+)(?::?|\s?-)?\s*)?(?P<title>.*)$";
let re = regex::Regex::new(after_patter).unwrap();
let re_res = re.captures(&pre_title).ok_or(Error::InvalidChapterTitle {
msg: "chapter title not in expected format".to_string(),