{"id":13941568,"url":"https://github.com/julien-c/epub","last_synced_at":"2025-04-13T06:15:19.937Z","repository":{"id":1547543,"uuid":"1885556","full_name":"julien-c/epub","owner":"julien-c","description":"node.js epub reader","archived":false,"fork":false,"pushed_at":"2025-01-17T22:07:13.000Z","size":1144,"stargazers_count":348,"open_issues_count":21,"forks_count":307,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-13T06:15:18.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/epub","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/julien-c.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-06-12T18:47:20.000Z","updated_at":"2025-04-05T09:19:10.000Z","dependencies_parsed_at":"2024-06-11T21:46:35.567Z","dependency_job_id":"70a2e104-dacf-46ce-bbe6-6bd6a20ecbae","html_url":"https://github.com/julien-c/epub","commit_stats":{"total_commits":72,"total_committers":17,"mean_commits":4.235294117647059,"dds":0.625,"last_synced_commit":"e5ee7956e1afd5fcc097bc487deb5f8ab86cd087"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julien-c%2Fepub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julien-c%2Fepub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julien-c%2Fepub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julien-c%2Fepub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/julien-c","download_url":"https://codeload.github.com/julien-c/epub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670434,"owners_count":21142904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-08T02:01:21.498Z","updated_at":"2025-04-13T06:15:19.917Z","avatar_url":"https://github.com/julien-c.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# epub [![Build Status](https://travis-ci.org/julien-c/epub.svg?branch=master)](https://travis-ci.org/julien-c/epub)\n\n**epub** is a node.js module to parse EPUB electronic book files.\n\n**NB!** Only ebooks in UTF-8 are currently supported!.\n\n## Installation\n\n    npm install epub\n\nOr, if you want a pure-JS version (useful if used in a Node-Webkit app for example):\n\n    npm install epub --no-optional\n\n\n## Usage\n\n```js\nimport EPub from 'epub'\nconst epub = new EPub(pathToFile, imageWebRoot, chapterWebRoot)\n```\n\nWhere\n\n  * **pathToFile** is the file path to an EPUB file\n  * **imageWebRoot** is the prefix for image URL's. If it's */images/* then the actual URL (inside chapter HTML `\u003cimg\u003e` blocks) is going to be */images/IMG_ID/IMG_FILENAME*, `IMG_ID` can be used to fetch the image form the ebook with `getImage`. Default: `/images/`\n  * **chapterWebRoot** is the prefix for chapter URL's. If it's */chapter/* then the actual URL (inside chapter HTML `\u003ca\u003e` links) is going to be */chapters/CHAPTER_ID/CHAPTER_FILENAME*, `CHAPTER_ID` can be used to fetch the image form the ebook with `getChapter`. Default: `/links/`\n \nBefore the contents of the ebook can be read, it must be opened (`EPub` is an `EventEmitter`).\n\n```js\nepub.on('end', function() {\n  // epub is initialized now\n  console.log(epub.metadata.title)\n\n  epub.getChapter('chapter_id', (err, text) =\u003e {})\n})\n\nepub.parse()\n```\n\n## metadata\n\nProperty of the *epub* object that holds several metadata fields about the book.\n\n```js\nepub.metadata\n```\n\nAvailable fields:\n\n  * **creator** Author of the book (if multiple authors, then the first on the list) (*Lewis Carroll*)\n  * **creatorFileAs** Author name on file (*Carroll, Lewis*)\n  * **title** Title of the book (*Alice's Adventures in Wonderland*)\n  * **language** Language code (*en* or *en-us* etc.)\n  * **subject** Topic of the book (*Fantasy*)\n  * **date** creation of the file (*2006-08-12*)\n  * **description**\n\n## flow\n\n*flow* is a property of the *epub* object and holds the actual list of chapters (TOC is just an indication and can link to a # url inside a chapter file)\n\n```js\nepub.flow.forEach(chapter =\u003e {\n    console.log(chapter.id)\n})\n```\n\nChapter `id` is needed to load the chapters `getChapter`\n\n## toc\n*toc* is a property of the *epub* object and indicates a list of titles/urls for the TOC. Actual chapter and it's ID needs to be detected with the `href` property\n\n\n## getChapter(chapter_id, callback)\n\nLoad chapter text from the ebook.\n\n```js\nepub.getChapter('chapter1', (error, text) =\u003e {})\n```\n\n## getChapterRaw(chapter_id, callback)\n\nLoad raw chapter text from the ebook.\n\n## getImage(image_id, callback)\n\nLoad image (as a Buffer value) from the ebook.\n\n```js\nepub.getImage('image1', (error, img, mimeType) =\u003e {})\n```\n\n## getFile(file_id, callback)\n\nLoad any file (as a Buffer value) from the ebook.\n\n```js\nepub.getFile('css1', (error, data, mimeType) =\u003e {})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulien-c%2Fepub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulien-c%2Fepub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulien-c%2Fepub/lists"}