D wrapper around (some) of the pixiv web API
Revisão | 869a0746613c11612782b50a319907737443b5e2 (tree) |
---|---|
Hora | 2023-08-13 16:32:54 |
Autor | supercell <stigma@disr...> |
Commiter | supercell |
Add PageAlreadyDownloadedEvent signal
This indicates that a page in a multi-paged Illustration has already
been downloaded.
@@ -25,8 +25,25 @@ struct DownloadProgressEvent | ||
25 | 25 | size_t current; |
26 | 26 | } |
27 | 27 | |
28 | +/// | |
29 | +/// Signals that a download has finished. This is used for | |
30 | +/// Illustrations, Manga, and Ugoira. | |
31 | +/// | |
32 | +/// The `forPage` member indicates that this signal is for | |
33 | +/// an individual page of the Illustration or Manga only. | |
34 | +/// | |
28 | 35 | struct DownloadCompleteEvent |
29 | 36 | { |
37 | + /// Is the download for an individual page? | |
38 | + const bool forPage = false; | |
39 | +} | |
40 | + | |
41 | +/// | |
42 | +/// Signals that a page in the Illustration has already | |
43 | +/// been downloaded and will not be downloaded again. | |
44 | +/// | |
45 | +struct PageAlreadyDownloadedEvent | |
46 | +{ | |
30 | 47 | } |
31 | 48 | |
32 | 49 | /** |
@@ -109,6 +126,7 @@ public: | ||
109 | 126 | /* Signals */ |
110 | 127 | mixin Signal!(DownloadProgressEvent); |
111 | 128 | mixin Signal!(DownloadCompleteEvent); |
129 | + mixin Signal!(PageAlreadyDownloadedEvent); | |
112 | 130 | |
113 | 131 | /** |
114 | 132 | * Fetch an illustration |
@@ -805,6 +823,11 @@ private: | ||
805 | 823 | const partFileName = baseFileName ~ ".part"; |
806 | 824 | string mode = "w+"; |
807 | 825 | |
826 | + if (true == exists(baseFileName) && false == overwrite) { | |
827 | + emit(PageAlreadyDownloadedEvent()); | |
828 | + continue; | |
829 | + } | |
830 | + | |
808 | 831 | if (true == exists(partFileName)) { |
809 | 832 | this._setupPartialDownload(jsonobj["urls"]["original"].str, partFileName); |
810 | 833 | mode = "a+"; |
@@ -827,8 +850,9 @@ private: | ||
827 | 850 | m_client.perform(); |
828 | 851 | img.close(); |
829 | 852 | rename(partFileName, baseFileName); |
830 | - emit(DownloadCompleteEvent()); | |
853 | + emit(DownloadCompleteEvent(true)); | |
831 | 854 | } |
855 | + emit(DownloadCompleteEvent()); | |
832 | 856 | } |
833 | 857 | |
834 | 858 | void _downloadManga(Illustration illust, string directory, bool overwrite) |