mirror of
https://github.com/danbulant/Mangades
synced 2026-06-18 05:41:05 +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
|
||||
}
|
||||
|
||||
async function downloadSingle(chapter) {
|
||||
const file = streamSaver.createWriteStream(`${manga.title.en} ${chapter.attributes.chapter}.${format}`, {
|
||||
writableStrategy: undefined, // (optional)
|
||||
readableStrategy: undefined, // (optional)
|
||||
});
|
||||
|
||||
const generator = new generators[format]({
|
||||
function createGenerator(chapter, file) {
|
||||
return new generators[format]({
|
||||
file,
|
||||
id: chapter.id,
|
||||
id: window.location.toString() + "-" + chapter.id,
|
||||
language: chapter.attributes.translatedLanguage,
|
||||
updatedAt: chapter.attributes.updatedAt,
|
||||
title: manga.title.en,
|
||||
|
|
@ -102,6 +97,14 @@
|
|||
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);
|
||||
queue.push(generator);
|
||||
|
|
@ -154,6 +157,30 @@
|
|||
selected = [];
|
||||
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
|
||||
|
|
@ -230,6 +257,7 @@
|
|||
<option value="epub"><b>.epub</b> Electronic publication</option>
|
||||
</select>
|
||||
<button disabled={!selected.length} on:click={downloadMulti}>Download</button>
|
||||
<button disabled={!selected.length} on:click={downloadSeparate}>Download Separate</button>
|
||||
</div>
|
||||
|
||||
<div class="flex">
|
||||
|
|
|
|||
Loading…
Reference in a new issue