mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Update
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
use super::check::CheckUnknown;
|
||||
use super::error::FanboxAPIError;
|
||||
use crate::parser::json::parse_u64;
|
||||
use json::JsonValue;
|
||||
use proc_macros::check_json_keys;
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// To represent a fanbox item
|
||||
@@ -144,6 +147,37 @@ impl FanboxItem {
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckUnknown for FanboxItem {
|
||||
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
|
||||
check_json_keys!(
|
||||
"id"+,
|
||||
"commentCount"+,
|
||||
"coverImageUrl",
|
||||
"cover": [
|
||||
"type"+,
|
||||
"url",
|
||||
],
|
||||
"creatorId"+,
|
||||
"excerpt"+,
|
||||
"feeRequired"+,
|
||||
"hasAdultContent"+,
|
||||
"isLiked"+,
|
||||
"isRestricted"+,
|
||||
"likeCount"+,
|
||||
"publishedDatetime"+,
|
||||
"tags"+,
|
||||
"title"+,
|
||||
"updatedDatetime"+,
|
||||
"user": [
|
||||
"name"+author_name,
|
||||
"iconUrl",
|
||||
"id"+,
|
||||
],
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for FanboxItem {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("FanboxItem")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use super::check::CheckUnknown;
|
||||
use super::error::FanboxAPIError;
|
||||
use super::item::FanboxItem;
|
||||
use crate::fanbox_api::FanboxClientInternal;
|
||||
@@ -24,18 +25,20 @@ impl FanboxItemList {
|
||||
pub async fn get_next_page(&self) -> Result<FanboxItemList, FanboxAPIError> {
|
||||
match &self.next_url {
|
||||
Some(url) => {
|
||||
match self.client.get_url(url, gettext("Failed to get next page of the items."), gettext("Items data:")).await {
|
||||
Some(data) => {
|
||||
Self::new(&data["body"], Arc::clone(&self.client))
|
||||
}
|
||||
None => {
|
||||
Err(FanboxAPIError::from("Failed to get next page."))
|
||||
}
|
||||
match self
|
||||
.client
|
||||
.get_url(
|
||||
url,
|
||||
gettext("Failed to get next page of the items."),
|
||||
gettext("Items data:"),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Some(data) => Self::new(&data["body"], Arc::clone(&self.client)),
|
||||
None => Err(FanboxAPIError::from("Failed to get next page.")),
|
||||
}
|
||||
}
|
||||
None => {
|
||||
Err(FanboxAPIError::from("No next url, can not get next page."))
|
||||
}
|
||||
None => Err(FanboxAPIError::from("No next url, can not get next page.")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,6 +73,15 @@ impl FanboxItemList {
|
||||
}
|
||||
}
|
||||
|
||||
impl CheckUnknown for FanboxItemList {
|
||||
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
|
||||
for i in self.items.iter() {
|
||||
i.check_unknown()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for FanboxItemList {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("FanboxItemList")
|
||||
|
||||
Reference in New Issue
Block a user