Metadata
use MejiroEPUB\DocumentInfo;
new DocumentInfo(
title: '目白の旅',
language: 'ja',
author: '目白 太郎',
identifier: 'https://novels.example.com/works/42',
publisher: 'Example Novels',
description: "全126話、完結。\n小さな鳥が、山を越えて海を見に行く話。",
source: 'https://novels.example.com/works/42',
published: new DateTimeImmutable('2024-04-01'),
);
| Argument | Written as | Notes |
|---|---|---|
title | dc:title | Required. Marked as the main title. |
language | dc:language, xml:lang | Required. A BCP 47 tag: ja, en, en-US. |
author | dc:creator with the role author | |
identifier | dc:identifier | See below. |
publisher | dc:publisher | For a web novel, the site. |
description | dc:description | The synopsis. Line breaks are kept. |
source | dc:source | Where the text comes from, such as the work's page. |
published | dc:date | When the work was published, written as a day. |
The time the file was made is separate: it is modified: on the Document
and defaults to now.
Optional values are null when absent. An empty or blank string is an error
(ME-VAL-1001) rather than an empty element — pass null.
All of it is cleaned like body text: control characters removed, broken UTF-8 repaired, markup escaped.
The identifier
Reading systems use the identifier to tell books apart. Give the same book the same identifier every time you generate it, and a reader that already has it can treat the new file as an update rather than a second copy.
Any stable string works. A work's URL is a natural choice; so is
urn:uuid:… derived from your own record. If you pass none, a random UUID is
generated and an INFO line is logged suggesting you pass one — which means every
download looks like a different book.
Shelf titles and file names
Some reading systems show the file name on their shelf instead of the title
in the metadata, even though they read the metadata — Kinokuniya's Kinoppy, for
one, shows the author and publisher from the file but lists an imported book as
work_42.epub. Nothing inside the EPUB changes that.
So name the downloaded file after the work: 目白の旅.epub, not
work_42.epub. Serving downloads shows how to send a
Japanese file name safely.