mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Update
This commit is contained in:
22
src/data/fanbox.rs
Normal file
22
src/data/fanbox.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use crate::fanbox::post::FanboxPost;
|
||||
use crate::pixiv_link::PixivID;
|
||||
use crate::pixiv_link::ToPixivID;
|
||||
use json::JsonValue;
|
||||
|
||||
pub struct FanboxData {
|
||||
pub id: PixivID,
|
||||
/// Raw data
|
||||
pub raw: JsonValue,
|
||||
}
|
||||
|
||||
impl FanboxData {
|
||||
pub fn new<T: ToPixivID>(id: T, post: &FanboxPost) -> Option<Self> {
|
||||
match id.to_pixiv_id() {
|
||||
Some(id) => Some(Self {
|
||||
id,
|
||||
raw: post.get_json().clone(),
|
||||
}),
|
||||
None => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
use super::fanbox::FanboxData;
|
||||
use crate::data::data::PixivData;
|
||||
use crate::ext::json::ToJson;
|
||||
use crate::gettext;
|
||||
@@ -108,6 +109,17 @@ impl From<&PixivData> for JSONDataFile {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<FanboxData> for JSONDataFile {
|
||||
fn from(d: FanboxData) -> Self {
|
||||
let mut f = Self {
|
||||
id: d.id.clone(),
|
||||
maps: HashMap::new(),
|
||||
};
|
||||
f.add("raw", d.raw).unwrap();
|
||||
f
|
||||
}
|
||||
}
|
||||
|
||||
impl ToJson for JSONDataFile {
|
||||
fn to_json(&self) -> Option<JsonValue> {
|
||||
let mut value = json::object! {};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod data;
|
||||
#[cfg(feature = "exif")]
|
||||
pub mod exif;
|
||||
pub mod fanbox;
|
||||
pub mod json;
|
||||
#[cfg(feature = "avdict")]
|
||||
pub mod video;
|
||||
|
||||
Reference in New Issue
Block a user