• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

D wrapper around (some) of the pixiv web API


Commit MetaInfo

Revisionc9a28e4f8521840f3919c5a38817906e6be1fdef (tree)
Time2023-09-26 18:56:48
Authorsupercell <stigma@disr...>
Commitersupercell

Log Message

Include current progress in PageAlreadyDownloaded

Change Summary

Incremental Difference

--- a/source/pixivd/client.d
+++ b/source/pixivd/client.d
@@ -44,6 +44,10 @@ struct DownloadCompleteEvent
4444 ///
4545 struct PageAlreadyDownloadedEvent
4646 {
47+ /// The current page number (1-based numbering)
48+ size_t currentPage;
49+ /// The total number of pages (1-based numbering)
50+ size_t totalPages;
4751 }
4852
4953 /**
@@ -814,7 +818,12 @@ private:
814818 throw new PixivJSONException("JSON response contains no 'body'.");
815819 }
816820
817- foreach (jsonobj; json["body"].array)
821+ const jsonBody = json["body"].array;
822+ // +1 so this matches PageAlreadyDownloaded containing the
823+ // 1-based numbering of the current page.
824+ const totalNumberOfPages = jsonBody.length + 1;
825+
826+ foreach (pageNumber, jsonobj; jsonBody)
818827 {
819828 import std.path : baseName, stripExtension;
820829
@@ -824,7 +833,7 @@ private:
824833 string mode = "w+";
825834
826835 if (true == exists(baseFileName) && false == overwrite) {
827- emit(PageAlreadyDownloadedEvent());
836+ emit(PageAlreadyDownloadedEvent(pageNumber + 1, totalNumberOfPages));
828837 continue;
829838 }
830839