mirror of
https://github.com/danbulant/Mangades
synced 2026-07-05 02:50:34 +00:00
allow downloading selected chapters in separate files
This commit is contained in:
parent
b772eda4d1
commit
7c46ff0f13
1 changed files with 36 additions and 8 deletions
|
|
@ -83,15 +83,10 @@
|
||||||
cbz: CBZGenerator
|
cbz: CBZGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
async function downloadSingle(chapter) {
|
function createGenerator(chapter, file) {
|
||||||
const file = streamSaver.createWriteStream(`${manga.title.en} ${chapter.attributes.chapter}.${format}`, {
|
return new generators[format]({
|
||||||
writableStrategy: undefined, // (optional)
|
|
||||||
readableStrategy: undefined, // (optional)
|
|
||||||
});
|
|
||||||
|
|
||||||
const generator = new generators[format]({
|
|
||||||
file,
|
file,
|
||||||
id: chapter.id,
|
id: window.location.toString() + "-" + chapter.id,
|
||||||
language: chapter.attributes.translatedLanguage,
|
language: chapter.attributes.translatedLanguage,
|
||||||
updatedAt: chapter.attributes.updatedAt,
|
updatedAt: chapter.attributes.updatedAt,
|
||||||
title: manga.title.en,
|
title: manga.title.en,
|
||||||
|
|
@ -102,6 +97,14 @@
|
||||||
volume: chapter.attributes.volume
|
volume: chapter.attributes.volume
|
||||||
}]
|
}]
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
async function downloadSingle(chapter) {
|
||||||
|
const file = streamSaver.createWriteStream(`${manga.title.en} ${chapter.attributes.chapter}.${format}`, {
|
||||||
|
writableStrategy: undefined, // (optional)
|
||||||
|
readableStrategy: undefined, // (optional)
|
||||||
|
});
|
||||||
|
|
||||||
|
const generator = createGenerator(chapter, file)
|
||||||
|
|
||||||
console.log(generator);
|
console.log(generator);
|
||||||
queue.push(generator);
|
queue.push(generator);
|
||||||
|
|
@ -154,6 +157,30 @@
|
||||||
selected = [];
|
selected = [];
|
||||||
processQueue();
|
processQueue();
|
||||||
}
|
}
|
||||||
|
function downloadSeparate() {
|
||||||
|
selected.sort((a, b) => a.attributes.chapter - b.attributes.chapter);
|
||||||
|
if(!selected.length) return;
|
||||||
|
if(selected.length === 1) {
|
||||||
|
downloadSingle(selected.shift());
|
||||||
|
selected = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const chapter of selected) {
|
||||||
|
const file = streamSaver.createWriteStream(`${manga.title.en} ${chapter.attributes.chapter}.${format}`, {
|
||||||
|
writableStrategy: undefined, // (optional)
|
||||||
|
readableStrategy: undefined, // (optional)
|
||||||
|
});
|
||||||
|
|
||||||
|
const generator = createGenerator(chapter, file)
|
||||||
|
|
||||||
|
console.log(generator);
|
||||||
|
queue.push(generator);
|
||||||
|
}
|
||||||
|
|
||||||
|
selected = [];
|
||||||
|
processQueue();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {BeforeUnloadEvent} e
|
* @param {BeforeUnloadEvent} e
|
||||||
|
|
@ -230,6 +257,7 @@
|
||||||
<option value="epub"><b>.epub</b> Electronic publication</option>
|
<option value="epub"><b>.epub</b> Electronic publication</option>
|
||||||
</select>
|
</select>
|
||||||
<button disabled={!selected.length} on:click={downloadMulti}>Download</button>
|
<button disabled={!selected.length} on:click={downloadMulti}>Download</button>
|
||||||
|
<button disabled={!selected.length} on:click={downloadSeparate}>Download Separate</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue