Selaa lähdekoodia

opds: улучшено скачивание для не-fb2 форматов файлов (djvu, pdf и пр.)

Book Pauk 2 vuotta sitten
vanhempi
commit
a2423fb704
1 muutettua tiedostoa jossa 11 lisäystä ja 8 poistoa
  1. 11 8
      server/core/opds/BookPage.js

+ 11 - 8
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')