fix downloads of chapters without numbers

This commit is contained in:
Daniel Bulant 2022-09-25 15:37:24 +02:00
parent 5de3e55d43
commit a4954b6177
2 changed files with 4 additions and 1 deletions

View file

@ -21,7 +21,6 @@ export class CBZGenerator extends BaseGenerator {
};
this.hashes = this.opts.chapters.map(t => t.links).flat();
const chapterCountLength = this.opts.chapters.reduce((a, b) => Math.max(a.number, b.number), 0).toString().length;
for(const chapterI in this.opts.chapters) {
const chapter = this.opts.chapters[chapterI];
@ -31,6 +30,9 @@ export class CBZGenerator extends BaseGenerator {
chapter.hashes = data.hashes;
chapter.hash = data.hash;
}
if(typeof chapter.number == "undefined" || chapter.number == null) {
chapter.number = chapterI;
}
const imageCountLength = chapter.links.length.toString().length;
for(const i in chapter.links) {
let url = chapter.links[i];

View file

@ -48,6 +48,7 @@ export class EpubGenerator extends BaseGenerator {
for(const chapterI in this.opts.chapters) {
const chapter = this.opts.chapters[chapterI];
if(chapter.number == null || chapter.number == undefined) chapter.number = chapterI;
for(const i in chapter.links) {
let url = chapter.links[i];
let hash = chapter.hashes[i];