vaporbook / epub-parser Goto Github PK
View Code? Open in Web Editor NEWA web-friendly epub file parser. Useful in browser-based reading systems, command-line ebook production toolsets, and more.
A web-friendly epub file parser. Useful in browser-based reading systems, command-line ebook production toolsets, and more.
I've encountered an error while parsing, here's the console output including a stack trace:
opsRoot is: (derived from content.opf)
parsing OPF data
events.js:72
throw er; // Unhandled 'error' event
^
TypeError: Cannot read property 'length' of undefined
at /Users/steveridout/code/readlang/node_modules/epub-parser/lib/epub-parser.js:234:36
at Parser. (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/lib/xml2js.js:384:20)
at Parser.emit (events.js:95:17)
at Object.onclosetag (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/lib/xml2js.js:348:26)
at emit (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/node_modules/sax/lib/sax.js:615:33)
at emitNode (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/node_modules/sax/lib/sax.js:620:3)
at closeTag (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/node_modules/sax/lib/sax.js:861:5)
at Object.write (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/node_modules/sax/lib/sax.js:1294:29)
at Parser.exports.Parser.Parser.parseString (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/lib/xml2js.js:403:31)
at Parser.parseString (/Users/steveridout/code/readlang/node_modules/epub-parser/node_modules/xml2js/lib/xml2js.js:6:61)
If you want I can privately share the offending .epub file to help reproduce the issue, I don't want to share it publicly since I don't own the copyright.
PS: thanks very much for this module!
Is their no license to this repository? I can't seem to find one, it could just be me not looking hard enough though. I'm not sure that I'd be able to use this module without a license explicitly granting the permissions.
This line in package.json seems to suggest that the license is BSD.
Your project page says "Please report bugs to vaporbook on github", but there is no way for one user on GitHub to contact another user on GitHub.
I don't have a bug; I just want to know what epub-parser does. I want to extract the book text (not the metadata) from epubs, but it doesn't seem to do that.
if you select simpleMeta, it returns an array... why? wouldn't it be more useful to be just an object?
Although the test ePub works fine, I get this same error trying to open any ePub from Project Gutenberg:
[TypeError: Cannot read property '0' of undefined] metadata element error: Cannot read property '0' of undefined manifest element error: Cannot read property '0' of undefined must throw this
Here's an example book:
https://dl.dropboxusercontent.com/u/382588/ocean2.0/development/gutenberg-710.epub
Seems this is where the error is thrown:
function parsePackageElements() { // operates on global vars try { metadata = opf[opfPrefix+"metadata"][0]; } catch(e) { console.log('metadata element error: '+e.message); } try { manifest = opf[opfPrefix+"manifest"][0]; } catch (e) { console.log('manifest element error: '+e.message); console.log('must throw this'); throw (e); } try { spine = opf[opfPrefix+"spine"][0]; } catch(e) { console.log('spine element error: '+e.message); console.log('must throw this'); throw (e); } try { guide = opf[opfPrefix+"guide"][0]; } catch (e) { ; } }
It looks like the manifest, spine and guide keys are expected to be prefixed with 'opf:' but they are not so in the object:
{ '$': { 'xmlns:opf': 'http://www.idpf.org/2007/opf', 'xmlns:dcterms': 'http://purl.org/dc/terms/', 'xmlns:dc': 'http://purl.org/dc/elements/1.1/', 'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', xmlns: 'http://www.idpf.org/2007/opf', version: '2.0', 'unique-identifier': 'id' }, metadata: [ { 'dc:rights': [Object], 'dc:identifier': [Object], 'dc:creator': [Object], 'dc:title': [Object], 'dc:language': [Object], 'dc:subject': [Object], 'dc:date': [Object], 'dc:source': [Object], meta: [Object] } ], manifest: [ { item: [Object] } ], spine: [ { '$': [Object], itemref: [Object] } ], guide: [ { reference: [Object] } ] }
Hi, thanks for this amazing tech. Right now I can access to the epub's metadata, my question is, it's posible to access all the contents?.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.