mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-06-06 05:49:01 +08:00
Update push
This commit is contained in:
@@ -128,6 +128,10 @@ pub struct PushDeerConfig {
|
||||
#[serde(default = "default_true")]
|
||||
/// Whether to add translated tag
|
||||
pub add_translated_tag: bool,
|
||||
#[serde(default = "default_true")]
|
||||
/// Whether to add image link
|
||||
/// Supported when type is `Text`.
|
||||
pub add_image_link: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::parser::description::DescriptionParser;
|
||||
use crate::pixivapp::illust::PixivAppIllust;
|
||||
use crate::push::every_push::{EveryPushClient, EveryPushTextType};
|
||||
use crate::push::pushdeer::PushdeerClient;
|
||||
use crate::utils::get_file_name_from_url;
|
||||
use crate::{get_helper, gettext};
|
||||
use json::JsonValue;
|
||||
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
|
||||
@@ -392,6 +393,16 @@ impl<'a> RunContext<'a> {
|
||||
text.push_str(&format!("[{}]({}) \n", link, link));
|
||||
}
|
||||
}
|
||||
if cfg.add_image_link {
|
||||
let len = self.len().unwrap_or(1);
|
||||
for i in 0..len {
|
||||
if let Some(url) = self.get_image_url(i).await? {
|
||||
let name =
|
||||
get_file_name_from_url(&url).unwrap_or_else(|| format!("{}", i));
|
||||
text.push_str(&format!("[{}]({}) \n", name, url));
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(desc) = self.desc() {
|
||||
let mut p = DescriptionParser::builder(true).ensure_link_ascii().build();
|
||||
p.parse(desc)?;
|
||||
|
||||
Reference in New Issue
Block a user