fix downloads

This commit is contained in:
Daniel Bulant 2022-12-07 23:12:36 +01:00
parent dd99b774ef
commit e515381985

View file

@ -12,6 +12,7 @@
import ArtList from "$lib/components/artList.svelte"; import ArtList from "$lib/components/artList.svelte";
import SvelteMarkdown from 'svelte-markdown'; import SvelteMarkdown from 'svelte-markdown';
import ArtDialog from "$lib/components/artDialog.svelte"; import ArtDialog from "$lib/components/artDialog.svelte";
import streamSaver from "streamsaver";
export var data; export var data;
@ -98,8 +99,8 @@
id: window.location.toString() + "-" + 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,
author: "Unknown", author: relationships.find(t => t.type === "author").attributes.name || "Unknown",
chapters: [{ chapters: [{
id: chapter.id, id: chapter.id,
number: chapter.attributes.chapter, number: chapter.attributes.chapter,
@ -108,7 +109,7 @@
}); });
} }
async function downloadSingle(chapter) { async function downloadSingle(chapter) {
const file = streamSaver.createWriteStream(`${manga.title.en} ${chapter.attributes.chapter}.${format}`, { const file = streamSaver.createWriteStream(`${title} ${chapter.attributes.chapter}.${format}`, {
writableStrategy: undefined, // (optional) writableStrategy: undefined, // (optional)
readableStrategy: undefined, // (optional) readableStrategy: undefined, // (optional)
}); });
@ -144,7 +145,7 @@
selected = []; selected = [];
return; return;
} }
const file = streamSaver.createWriteStream(`${manga.title.en}.${format}`, { const file = streamSaver.createWriteStream(`${title}.${format}`, {
writableStrategy: undefined, // (optional) writableStrategy: undefined, // (optional)
readableStrategy: undefined, // (optional) readableStrategy: undefined, // (optional)
}); });
@ -153,8 +154,8 @@
id: window.location.toString(), id: window.location.toString(),
language: selected[0].attributes.translatedLanguage, language: selected[0].attributes.translatedLanguage,
updatedAt: new Date, updatedAt: new Date,
title: manga.title.en, title: title,
author: "Unknown", author: relationships.find(t => t.type === "author").attributes.name || "Unknown",
chapters: selected.map(chapter => ({ chapters: selected.map(chapter => ({
id: chapter.id, id: chapter.id,
title: chapter.attributes.title, title: chapter.attributes.title,
@ -178,7 +179,7 @@
} }
for (const chapter of selected) { for (const chapter of selected) {
const file = streamSaver.createWriteStream(`${manga.title.en} ${chapter.attributes.chapter}.${format}`, { const file = streamSaver.createWriteStream(`${title} ${chapter.attributes.chapter}.${format}`, {
writableStrategy: undefined, // (optional) writableStrategy: undefined, // (optional)
readableStrategy: undefined, // (optional) readableStrategy: undefined, // (optional)
}); });