{"id":17027596,"url":"https://github.com/mathieu-keller/epub-parser","last_synced_at":"2026-01-11T21:59:52.433Z","repository":{"id":153512425,"uuid":"629635498","full_name":"mathieu-keller/epub-parser","owner":"mathieu-keller","description":"library that parse an ePub to an struct","archived":false,"fork":false,"pushed_at":"2025-12-03T09:50:52.000Z","size":74,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-06T12:27:37.614Z","etag":null,"topics":["epub","opf","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathieu-keller.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-18T18:01:25.000Z","updated_at":"2025-12-03T09:50:00.000Z","dependencies_parsed_at":"2024-11-29T08:47:56.024Z","dependency_job_id":"b4b94b49-33fb-44fb-9488-9dc7887df6ac","html_url":"https://github.com/mathieu-keller/epub-parser","commit_stats":null,"previous_names":["mathieu-keller/opf","mathieu-keller/opf-parser","mathieu-keller/opfparser"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/mathieu-keller/epub-parser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieu-keller%2Fepub-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieu-keller%2Fepub-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieu-keller%2Fepub-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieu-keller%2Fepub-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathieu-keller","download_url":"https://codeload.github.com/mathieu-keller/epub-parser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieu-keller%2Fepub-parser/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28324793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T18:42:50.174Z","status":"ssl_error","status_checked_at":"2026-01-11T18:39:13.842Z","response_time":60,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["epub","opf","parser"],"created_at":"2024-10-14T07:49:08.293Z","updated_at":"2026-01-11T21:59:52.423Z","avatar_url":"https://github.com/mathieu-keller.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# epub-parser\n\n`epub-parser` is a Go library for parsing EPUB files, specifically versions 2.0 and 3.0. It extracts and interprets metadata from the EPUB's `OPF` (Open Packaging Format) files, enabling developers to programmatically access information such as titles, authors, publishers, and more.\n\nThis library is particularly useful for applications requiring detailed metadata extraction from EPUB files, such as e-book management tools, cataloging systems, or digital libraries.\n\n---\n\n## Features\n\n- **Supports EPUB 2.0 and 3.0**: Parses both versions seamlessly.\n- **Metadata Extraction**:\n    - Titles\n    - Identifiers (e.g., ISBN, UUID)\n    - Languages\n    - Creators (Authors)\n    - Contributors\n    - Publishers\n    - Subjects\n    - Descriptions\n    - Dates\n- **ZIP-based EPUB Parsing**: Reads EPUB files directly from ZIP archives.\n\n---\n\n## Installation\n\nAdd the library to your project using `go get`:\n\n```sh\ngo get github.com/mathieu-keller/epub-parser/v2\n```\n\n---\n\n## Usage\n\nHere’s an example test demonstrating how to use the library:\n\n```go\npackage epub\n\nimport (\n\t\"archive/zip\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"os\"\n)\n\nfunc ParseEPUB() {\n\t// Load the EPUB file\n\tbinaryFile, err := os.ReadFile(\"./test_epub_v3.0.epub\")\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to read EPUB file: %v\", err)\n\t\tos.Exit(1)\n\t}\n\n\t// Create a ZIP reader for the EPUB\n\tzipReader, err := zip.NewReader(bytes.NewReader(binaryFile), int64(len(binaryFile)))\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to create ZIP reader: %v\", err)\n\t\tos.Exit(1)\n\t}\n\n\t// Parse the book\n\tbook, err := OpenBook(zipReader)\n\tif err != nil {\n\t\tfmt.Printf(\"Failed to parse EPUB book: %v\", err)\n\t\tos.Exit(1)\n\t}\n\tfmt.Println(book.Metadata.MainId.Id)\n}\n```\n\n---\n\n## Model: Metadata\n\nThe core of the library is the `Metadata` struct, which encapsulates the detailed metadata of an EPUB file. Here’s the structure and its key components:\n\n\n```go\ntype Metadata struct {\nMainId       Identifier           // Main identifier of the EPUB (e.g., UUID)\nTitles       *[]Title             // List of titles\nIdentifiers  *[]Identifier        // List of identifiers (e.g., UUID, ISBN, etc.)\nLanguages    *[]string            // List of languages\nCreators     *[]Creator           // List of creators (e.g., authors)\nContributors *[]Creator           // List of contributors (e.g., editors, producers)\nPublishers   *[]DefaultAttributes // List of publishers\nSubjects     *[]DefaultAttributes // List of subjects (categories, genres)\nDescriptions *[]DefaultAttributes // List of descriptions\nDates        *[]string            // List of publication dates\n}\n```\n\n### Supporting Types\n\n- **`Title`**: Represents a title in the EPUB.\n  ```go\n  type Title struct {\n      Title    string\n      Language string\n      Type     string\n      FileAs   string\n  }\n  ```\n\n- **`Identifier`**: Represents an identifier like UUID or ISBN.\n  ```go\n  type Identifier struct {\n      Id     string\n      Scheme string\n  }\n  ```\n\n- **`Creator`**: Represents an author or contributor.\n  ```go\n  type Creator struct {\n      Name     string\n      Language string\n      FileAs   string\n      Role     string\n      RawRole  string\n  }\n  ```\n\n- **`DefaultAttributes`**: Generic type for attributes like publishers, subjects, and descriptions.\n  ```go\n  type DefaultAttributes struct {\n      Text     string\n      Language string\n  }\n  ```\n\n### Example Metadata Output:\n\n- **Title**: Test epub\n- **Language**: en\n- **Creators**:\n    - Name: John Doe\n    - Role: Author\n- **Publisher**: Test Publisher\n- **Subjects**: Novel, Comic Science Fiction\n- **Description**: A captivating space adventure...\n\n---\n\n## Contributing\n\n1. Fork the repository.\n2. Create a feature branch (`git checkout -b feature-name`).\n3. Commit your changes (`git commit -m \"Add feature\"`).\n4. Push the branch (`git push origin feature-name`).\n5. Open a pull request.\n\n---\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\nHappy parsing! 🚀\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieu-keller%2Fepub-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathieu-keller%2Fepub-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieu-keller%2Fepub-parser/lists"}