From a2423fb704c6df6bd80cc357ddbb47e2741b5bca Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 2 Mar 2023 15:50:26 +0700 Subject: [PATCH] =?UTF-8?q?opds:=20=D1=83=D0=BB=D1=83=D1=87=D1=88=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=B5-fb2=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D0=B0=D1=82=D0=BE=D0=B2=20=D1=84=D0=B0=D0=B9?= =?UTF-8?q?=D0=BB=D0=BE=D0=B2=20(djvu,=20pdf=20=D0=B8=20=D0=BF=D1=80.)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/opds/BookPage.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server/core/opds/BookPage.js b/server/core/opds/BookPage.js index 7ec2b31..72ea59e 100644 --- a/server/core/opds/BookPage.js +++ b/server/core/opds/BookPage.js @@ -130,15 +130,15 @@ class BookPage extends BasePage { //format const ext = bookInfo.book.ext; - let fileFormat = `${ext}+zip`; - let downHref = bookInfo.link; + const formats = { + [`${ext}+zip`]: `${bookInfo.link}/zip`, + [ext]: bookInfo.link, + }; if (ext === 'mobi') { - fileFormat = 'x-mobipocket-ebook'; + formats['x-mobipocket-ebook'] = bookInfo.link; } else if (ext == 'epub') { - // - } else { - downHref = `${bookInfo.link}/zip`; + formats[`${ext}+zip`] = bookInfo.link; } //entry @@ -153,7 +153,7 @@ class BookPage extends BasePage { } e['dc:language'] = bookInfo.book.lang; - e['dc:format'] = fileFormat; + e['dc:format'] = ext; //genre const genre = bookInfo.book.genre.split(','); @@ -200,7 +200,10 @@ class BookPage extends BasePage { } //links - e.link = [ this.downLink({href: downHref, type: `application/${fileFormat}`}) ]; + e.link = []; + for (const [fileFormat, downHref] of Object.entries(formats)) + e.link.push(this.downLink({href: downHref, type: `application/${fileFormat}`})); + if (bookInfo.cover) { let coverType = 'image/jpeg'; if (path.extname(bookInfo.cover) == '.png')