Работа над BookInfoDialog
This commit is contained in:
@@ -473,15 +473,14 @@ class WebWorker {
|
|||||||
const rows = await db.select({table: 'book', where: `@@id(${db.esc(bookId)})`});
|
const rows = await db.select({table: 'book', where: `@@id(${db.esc(bookId)})`});
|
||||||
const book = rows[0];
|
const book = rows[0];
|
||||||
|
|
||||||
let fb2 = false;
|
|
||||||
if (book.ext == 'fb2') {
|
|
||||||
const parsedFb2 = await this.fb2Parser.getDescAndCover(bookFile);
|
|
||||||
fb2 = parsedFb2;
|
|
||||||
}
|
|
||||||
|
|
||||||
bookInfo.book = book;
|
bookInfo.book = book;
|
||||||
bookInfo.fb2 = fb2;
|
|
||||||
bookInfo.cover = '';
|
bookInfo.cover = '';
|
||||||
|
bookInfo.fb2 = false;
|
||||||
|
|
||||||
|
if (book.ext == 'fb2') {
|
||||||
|
const {desc, cover} = await this.fb2Parser.getDescAndCover(bookFile);
|
||||||
|
bookInfo.fb2 = desc;
|
||||||
|
}
|
||||||
|
|
||||||
await fs.writeFile(bookFileInfo, JSON.stringify(bookInfo, null, 2));
|
await fs.writeFile(bookFileInfo, JSON.stringify(bookInfo, null, 2));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const fs = require('fs-extra');
|
|||||||
const iconv = require('iconv-lite');
|
const iconv = require('iconv-lite');
|
||||||
const textUtils = require('./textUtils');
|
const textUtils = require('./textUtils');
|
||||||
|
|
||||||
const xmlParser = require('./xmlParser');
|
const XmlParser = require('./XmlParser');
|
||||||
const utils = require('../utils');
|
const utils = require('../utils');
|
||||||
|
|
||||||
class Fb2Parser {
|
class Fb2Parser {
|
||||||
@@ -55,12 +55,20 @@ class Fb2Parser {
|
|||||||
data = await utils.gunzipBuffer(data);
|
data = await utils.gunzipBuffer(data);
|
||||||
//data = this.checkEncoding(data);
|
//data = this.checkEncoding(data);
|
||||||
|
|
||||||
const result = xmlParser.parseXml(data.toString(), true, (route) => {
|
const xml = new XmlParser();
|
||||||
console.log(route);
|
|
||||||
return true;
|
xml.fromString(data.toString(), {
|
||||||
|
lowerCase: true,
|
||||||
|
pickNode: route => route.indexOf('fictionbook/body') !== 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
return xmlParser.simplifyXmlParsed(result);
|
let cover = null;
|
||||||
|
//console.log(xml.toString());
|
||||||
|
//xml.each(node => console.log(node.name));
|
||||||
|
|
||||||
|
const desc = xml.$$('description').toObject();
|
||||||
|
|
||||||
|
return {desc, cover};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user