mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Update
This commit is contained in:
@@ -6,27 +6,31 @@ use crate::exif::ExifTypeID;
|
||||
use crate::exif::ExifValue;
|
||||
use crate::ext::try_err::TryErr;
|
||||
use crate::parser::description::parse_description;
|
||||
use proc_macros::call_parent_data_source_fun;
|
||||
use proc_macros::define_exif_data_source;
|
||||
use std::convert::TryFrom;
|
||||
use std::ffi::OsStr;
|
||||
use utf16string::LittleEndian;
|
||||
use utf16string::WString;
|
||||
|
||||
pub trait ExifDataSource {
|
||||
fn image_author(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
define_exif_data_source!("src/data/exif_data_source.json");
|
||||
}
|
||||
|
||||
fn image_comment(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
impl<T: ExifDataSource> ExifDataSource for std::sync::Arc<T> {
|
||||
call_parent_data_source_fun!("src/data/exif_data_source.json", *self,);
|
||||
}
|
||||
|
||||
fn image_id(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
fn image_title(&self) -> Option<String> {
|
||||
None
|
||||
}
|
||||
impl<T: ExifDataSource> ExifDataSource for Option<T> {
|
||||
call_parent_data_source_fun!(
|
||||
"src/data/exif_data_source.json",
|
||||
match self {
|
||||
Some(data) => data,
|
||||
None => {
|
||||
return None;
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn add_image_id<D: ExifDataSource>(data: &mut ExifData, d: &D) -> Result<(), ()> {
|
||||
|
||||
6
src/data/exif_data_source.json
Normal file
6
src/data/exif_data_source.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"image_author": { "return": "String", "description": "The author of the image." },
|
||||
"image_comment": { "return": "String", "description": "The comment of the image." },
|
||||
"image_id": { "return": "String", "description": "The image id." },
|
||||
"image_title": { "return": "String", "description": "The title of the image." }
|
||||
}
|
||||
@@ -1,12 +1,18 @@
|
||||
#[cfg(feature = "exif")]
|
||||
use super::exif::ExifDataSource;
|
||||
use crate::fanbox::post::FanboxPost;
|
||||
use crate::pixiv_link::PixivID;
|
||||
use crate::pixiv_link::ToPixivID;
|
||||
use json::JsonValue;
|
||||
#[cfg(feature = "exif")]
|
||||
use proc_macros::call_parent_data_source_fun;
|
||||
|
||||
pub struct FanboxData {
|
||||
pub id: PixivID,
|
||||
/// Raw data
|
||||
pub raw: JsonValue,
|
||||
#[cfg(feature = "exif")]
|
||||
pub exif_data: Option<Box<dyn ExifDataSource>>,
|
||||
}
|
||||
|
||||
impl FanboxData {
|
||||
@@ -15,8 +21,28 @@ impl FanboxData {
|
||||
Some(id) => Some(Self {
|
||||
id,
|
||||
raw: post.get_json().clone(),
|
||||
#[cfg(feature = "exif")]
|
||||
exif_data: None,
|
||||
}),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "exif")]
|
||||
impl ExifDataSource for FanboxData {
|
||||
call_parent_data_source_fun!(
|
||||
"src/data/exif_data_source.json",
|
||||
match &self.exif_data {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
return None;
|
||||
}
|
||||
},
|
||||
image_id,
|
||||
);
|
||||
|
||||
fn image_id(&self) -> Option<String> {
|
||||
Some(self.id.to_link())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user