This commit is contained in:
2022-07-14 13:24:41 +00:00
committed by GitHub
parent 6420be64af
commit 061aa56bde
5 changed files with 112 additions and 4 deletions

22
src/data/fanbox.rs Normal file
View 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,
}
}
}

View File

@@ -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! {};

View File

@@ -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;