fix missing image
This commit is contained in:
@@ -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(),
|
||||
|
||||
Reference in New Issue
Block a user