mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Update
This commit is contained in:
@@ -17,6 +17,33 @@ pub struct FanboxItemList {
|
||||
}
|
||||
|
||||
impl FanboxItemList {
|
||||
/// Get next page.
|
||||
/// # Note
|
||||
/// If no next page presented, will return a error.
|
||||
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."))
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
Err(FanboxAPIError::from("No next url, can not get next page."))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if next page is presented.
|
||||
pub fn has_next_page(&self) -> bool {
|
||||
self.next_url.is_some()
|
||||
}
|
||||
|
||||
/// Create a new instance
|
||||
pub fn new(
|
||||
value: &JsonValue,
|
||||
client: Arc<FanboxClientInternal>,
|
||||
|
||||
@@ -105,7 +105,17 @@ fanbox_api_test!(test_paginate_creator_posts, {
|
||||
if pages.len() > 0 {
|
||||
match pages.get_page(0).await {
|
||||
Some(data) => {
|
||||
println!("{:?}", data)
|
||||
println!("{:?}", data);
|
||||
if data.has_next_page() {
|
||||
match data.get_next_page().await {
|
||||
Ok(data) => {
|
||||
println!("{:?}", data);
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user