Skip to content

Commit de5faa8

Browse files
committed
fix issue
1 parent d6f6615 commit de5faa8

File tree

3 files changed

+51
-48
lines changed

3 files changed

+51
-48
lines changed

src/options_page/components/options/PixivComicOptions.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<v-list-tile-sub-title>{{ tl('_page_number_start_with_1_otherwise_start_with_0') }}</v-list-tile-sub-title>
3434
</v-list-tile-content>
3535
<v-list-tile-action>
36-
<v-switch v-model="pixivComicNumberStartWithOne"></v-switch>
36+
<v-switch v-model="pixivComicPageNumberStartWithOne"></v-switch>
3737
</v-list-tile-action>
3838
</v-list-tile>
3939

@@ -152,13 +152,13 @@ export default {
152152
});
153153
},
154154
155-
pageNumberStartWithOne(val) {
155+
pixivComicPageNumberStartWithOne(val) {
156156
browser.storage.local.set({
157157
pixivComicPageNumberStartWithOne: val
158158
});
159159
},
160160
161-
pageNumberLength(val) {
161+
pixivComicPageNumberLength(val) {
162162
browser.storage.local.set({
163163
pixivComicPageNumberLength: val
164164
});

src/pixiv_comic/content_scripts/App.vue

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:panelPosition="browserItems.downloadPanelPosition"
55
>
66
<ptk-button class="download-btn download-btn--min-70"
7+
:class="downloaded ? 'button--success' : ''"
78
@click="downloadImages"
89
>{{ downloadText }}</ptk-button>
910
</control-panel>
@@ -37,7 +38,8 @@ export default {
3738
successCount: 0,
3839
failCount: 0,
3940
downloading: false,
40-
unsupportedPostType: false
41+
unsupportedPostType: false,
42+
downloaded: false
4143
}
4244
},
4345
@@ -96,6 +98,7 @@ export default {
9698
this.totalCount = 0;
9799
this.successCount = 0;
98100
this.failCount = 0;
101+
this.downloaded = false;
99102
100103
this.injectPage();
101104
}
@@ -139,8 +142,8 @@ export default {
139142
*/
140143
let episode = new Episode(this.context);
141144
142-
let savePath = this.browserItems.illustrationRelativeLocation ?
143-
this.getSubfolder(this.browserItems.illustrationRelativeLocation, episode.context) :
145+
let savePath = this.browserItems.pixivComicRelativeLocation ?
146+
this.getSubfolder(this.browserItems.pixivComicRelativeLocation, episode.context) :
144147
this.browserItems.downloadRelativeLocation;
145148
146149
if (this.lastData) {
@@ -155,11 +158,10 @@ export default {
155158
this.totalCount = episode.pagesNumber();
156159
157160
episode.initOptions({
158-
splitSize: 99,
159-
illustrationRenameFormat: vm.getItem('illustrationRenameFormat'),
160-
illustrationImageRenameFormat: vm.getItem('illustrationImageRenameFormat'),
161-
pageNumberStartWithOne: vm.getItem('illustrationPageNumberStartWithOne'),
162-
illustrationPageNumberLength: 0,
161+
renameFormat: vm.getItem('pixivComicRenameFormat'),
162+
imageRenameFormat: vm.getItem('pixivComicImageRenameFormat'),
163+
pageNumberStartWithOne: vm.getItem('pixivComicPageNumberStartWithOne'),
164+
pageNumberLength: vm.getItem('pixivComicPageNumberLength'),
163165
}).init();
164166
165167
episode.addListener('download-progress', progress => {
@@ -176,16 +178,21 @@ export default {
176178
}
177179
178180
episode.downloadFiles({ indexes }, episode).then(files => {
179-
episode.getPackedFile({ files }).then(result => {
180-
this.lastData = result.data;
181-
this.lastFilename = result.filename;
182-
183-
this.downloadFile({
184-
src: result.data,
185-
filename: result.filename,
186-
folder: savePath,
181+
if (vm.getItem('downloadPackFiles') == false) {
182+
this.downloadMultipleFiles(files, { savePath })
183+
.then(() => this.downloaded = true);
184+
} else {
185+
episode.getPackedFile({ files }).then(result => {
186+
this.lastData = result.data;
187+
this.lastFilename = result.filename;
188+
189+
this.downloadFile({
190+
src: result.data,
191+
filename: result.filename,
192+
folder: savePath,
193+
}).then(() => this.downloaded = true);
187194
});
188-
});
195+
}
189196
}).finally(() => {
190197
this.downloading = false;
191198
});

src/pixiv_comic/modules/Episode.js

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ class Episode extends FilesDownloader {
2929
}
3030

3131
initOptions({
32-
splitSize,
33-
illustrationRenameFormat,
34-
illustrationImageRenameFormat,
32+
splitSize = 1000,
33+
renameFormat,
34+
imageRenameFormat,
3535
pageNumberStartWithOne = false,
36-
illustrationPageNumberLength,
36+
pageNumberLength,
3737
processors = 2,
3838
pack = true
3939
}) {
4040
this.splitSize = splitSize;
41-
this.illustrationRenameFormat = illustrationRenameFormat
42-
this.illustrationImageRenameFormat = illustrationImageRenameFormat;
41+
this.renameFormat = renameFormat
42+
this.imageRenameFormat = imageRenameFormat;
4343
this.pageNumberStartWithOne = pageNumberStartWithOne;
44-
this.illustrationPageNumberLength = illustrationPageNumberLength;
44+
this.pageNumberLength = pageNumberLength;
4545
this.processors = processors;
4646
this.pack = pack;
4747
this.relativePath = '';
@@ -53,7 +53,7 @@ class Episode extends FilesDownloader {
5353
}
5454

5555
init() {
56-
this.relativePath = formatName(this.illustrationRenameFormat, this.context, this.context.illustId);
56+
this.relativePath = formatName(this.renameFormat, this.context, this.getId());
5757
this.chunks = [];
5858
this.filename = null;
5959
this.zips = null;
@@ -78,10 +78,10 @@ class Episode extends FilesDownloader {
7878
startIndex = chunk.end + 1;
7979
}
8080

81-
if (!self.illustrationImageRenameFormat ||
82-
self.illustrationImageRenameFormat.indexOf('{pageNum}') < 0
81+
if (!self.imageRenameFormat ||
82+
self.imageRenameFormat.indexOf('{pageNum}') < 0
8383
) {
84-
self.illustrationImageRenameFormat += '{pageNum}';
84+
self.imageRenameFormat += '{pageNum}';
8585
}
8686
}
8787

@@ -94,32 +94,28 @@ class Episode extends FilesDownloader {
9494
this.context[key] = value;
9595
}
9696

97-
getUserId() {
98-
return this.context.userId
99-
}
100-
101-
getUserName() {
102-
return this.context.userName
97+
getId() {
98+
return this.context.id
10399
}
104100

105-
getId() {
106-
return this.context.illustId
101+
getUniqueId() {
102+
return `pixiv-comic-episode:${this.getId()}`;
107103
}
108104

109105
getImages() {
110-
return this.context.urls
106+
return this.context.pages
111107
}
112108

113109
getThumb() {
114-
return this.getImages().thumb;
110+
return this.getImages()[0];
115111
}
116112

117113
getTitle() {
118-
return this.context.illustTitle
114+
return this.context.title;
119115
}
120116

121117
isR() {
122-
return !!this.context.r
118+
return false;
123119
}
124120

125121
/**
@@ -128,7 +124,7 @@ class Episode extends FilesDownloader {
128124
* @returns {Boolean}
129125
*/
130126
isSingle() {
131-
return this.pagesNumber() === 1
127+
return false;
132128
}
133129

134130
/**
@@ -168,11 +164,11 @@ class Episode extends FilesDownloader {
168164
let pageNum = index + (this.pageNumberStartWithOne ? 1 : 0);
169165

170166
this.context.pageNum = this.getPageNumberString(
171-
pageNum, this.context.pages.length, this.illustrationPageNumberLength
167+
pageNum, this.context.pages.length, this.pageNumberLength
172168
);
173169

174170
return formatName(
175-
this.illustrationImageRenameFormat.replace(this.isSingle() ? /#.*#/g: /#/g, ''),
171+
this.imageRenameFormat.replace(this.isSingle() ? /#.*#/g: /#/g, ''),
176172
this.context,
177173
pageNum
178174
);
@@ -183,7 +179,7 @@ class Episode extends FilesDownloader {
183179
* @returns {string}
184180
*/
185181
getPackedFilename() {
186-
return formatName(this.illustrationRenameFormat, this.context, this.context.illustId);
182+
return formatName(this.renameFormat, this.context, this.getId());
187183
}
188184

189185
/**
@@ -214,7 +210,7 @@ class Episode extends FilesDownloader {
214210

215211
this.context.pageNum = pageNum;
216212

217-
let format = this.illustrationImageRenameFormat.replace(/#.*#/g, '');
213+
let format = this.imageRenameFormat.replace(/#.*#/g, '');
218214

219215
let filename = formatName(format, this.context, pageNum) + '.' + MimeType.getExtenstion(download.getResponseHeader('Content-Type'));
220216

0 commit comments

Comments
 (0)