@ashdev/codex-plugin-metadata-openlibrary 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,190 @@
1
+ # Open Library Metadata Plugin
2
+
3
+ A Codex metadata plugin that fetches book metadata from [Open Library](https://openlibrary.org), a free and open book database with extensive ISBN coverage.
4
+
5
+ ## Features
6
+
7
+ - **ISBN Lookup**: Direct, accurate book matching by ISBN-10 or ISBN-13
8
+ - **Title Search**: Fuzzy search by title and/or author
9
+ - **Cover Images**: Fetches cover images in multiple sizes (small, medium, large)
10
+ - **Author Resolution**: Resolves author references to full names
11
+ - **Subject Extraction**: Extracts subjects/topics from Open Library data
12
+ - **Ratings**: Includes Open Library community ratings when available
13
+
14
+ ## Installation
15
+
16
+ ### From npm
17
+
18
+ ```bash
19
+ npm install @ashdev/codex-plugin-metadata-openlibrary
20
+ ```
21
+
22
+ ### From source
23
+
24
+ ```bash
25
+ cd plugins/metadata-openlibrary
26
+ npm install
27
+ npm run build
28
+ ```
29
+
30
+ ## Configuration
31
+
32
+ Register the plugin in Codex with optional configuration:
33
+
34
+ | Option | Type | Default | Description |
35
+ |--------|------|---------|-------------|
36
+ | `maxResults` | number | 10 | Maximum search results to return (1-50) |
37
+
38
+ ### Example Configuration
39
+
40
+ ```yaml
41
+ plugins:
42
+ - name: metadata-openlibrary
43
+ config:
44
+ maxResults: 20
45
+ ```
46
+
47
+ ## API Endpoints Used
48
+
49
+ The plugin uses the following Open Library API endpoints:
50
+
51
+ | Endpoint | Usage |
52
+ |----------|-------|
53
+ | `/isbn/{isbn}.json` | Direct ISBN lookup (edition data) |
54
+ | `/works/{id}.json` | Work details (description, subjects) |
55
+ | `/authors/{id}.json` | Author name resolution |
56
+ | `/search.json` | Title/author search |
57
+
58
+ ### Cover Image URLs
59
+
60
+ Cover images are fetched from:
61
+
62
+ ```
63
+ https://covers.openlibrary.org/b/isbn/{isbn}-{S|M|L}.jpg
64
+ https://covers.openlibrary.org/b/id/{cover_id}-{S|M|L}.jpg
65
+ ```
66
+
67
+ ## Field Mapping
68
+
69
+ | Open Library | Codex Field | Notes |
70
+ |--------------|-------------|-------|
71
+ | `title` | `title` | |
72
+ | `subtitle` | `subtitle` | |
73
+ | `authors[].name` | `authors` | Resolved to full names with role="author" |
74
+ | `publishers[0]` | `publisher` | First publisher |
75
+ | `publish_date` | `year` | Parsed to extract year |
76
+ | `isbn_13` / `isbn_10` | `isbns` | All ISBNs, preferring ISBN-13 |
77
+ | `subjects` | `subjects` | Combined from edition and work |
78
+ | `description` | `summary` | From edition or work |
79
+ | `first_publish_date` | `originalYear` | From work data |
80
+ | `languages[0]` | `language` | Converted to BCP47 format |
81
+ | `key` | `externalId` | Work or edition key |
82
+ | `covers[0]` | `covers` | S/M/L URLs generated |
83
+ | `ratings_average` | `rating` | Normalized 0-100 scale |
84
+
85
+ ## Supported Content Types
86
+
87
+ This plugin only provides **book** metadata (not series). It's designed for:
88
+
89
+ - EPUBs with ISBN metadata
90
+ - PDFs with ISBN information
91
+ - Novels and non-fiction books
92
+ - Graphic novels (limited support)
93
+
94
+ For manga and comics, consider using a dedicated manga/comic metadata plugin.
95
+
96
+ ## Search Behavior
97
+
98
+ ### ISBN Search
99
+
100
+ When an ISBN is provided:
101
+ 1. Direct lookup via `/isbn/{isbn}.json`
102
+ 2. Returns single result with 100% confidence
103
+ 3. Falls back to title search if ISBN not found
104
+
105
+ ### Title Search
106
+
107
+ When searching by title/author:
108
+ 1. Searches via `/search.json`
109
+ 2. Returns multiple results ranked by relevance
110
+ 3. Relevance score based on: author data, ISBN availability, cover, year, subjects, ratings
111
+
112
+ ### Match Behavior
113
+
114
+ The `match` method tries to automatically identify a book:
115
+ 1. **ISBN match** (if available): Highest confidence (99%)
116
+ 2. **Title match**: Lower confidence (max 85%), boosted by title similarity and year match
117
+
118
+ ## Rate Limiting
119
+
120
+ Open Library recommends limiting requests to 100 per 5 minutes. The plugin includes:
121
+
122
+ - 15-minute response caching
123
+ - Respectful request headers
124
+ - Single concurrent request pattern
125
+
126
+ ## Examples
127
+
128
+ ### Search by ISBN
129
+
130
+ ```typescript
131
+ // Plugin will fetch: https://openlibrary.org/isbn/9780553418026.json
132
+ const results = await plugin.searchBooks({
133
+ isbn: "978-0-553-41802-6"
134
+ });
135
+ ```
136
+
137
+ ### Search by Title
138
+
139
+ ```typescript
140
+ // Plugin will search: https://openlibrary.org/search.json?q=The+Martian&author=Andy+Weir
141
+ const results = await plugin.searchBooks({
142
+ query: "The Martian",
143
+ author: "Andy Weir"
144
+ });
145
+ ```
146
+
147
+ ### Get Full Metadata
148
+
149
+ ```typescript
150
+ // Fetches edition, work, and author data
151
+ const metadata = await plugin.getBook({
152
+ externalId: "/works/OL17091769W"
153
+ });
154
+ ```
155
+
156
+ ## Development
157
+
158
+ ### Build
159
+
160
+ ```bash
161
+ npm run build
162
+ ```
163
+
164
+ ### Test
165
+
166
+ ```bash
167
+ npm test
168
+ ```
169
+
170
+ ### Lint
171
+
172
+ ```bash
173
+ npm run lint
174
+ ```
175
+
176
+ ### Type Check
177
+
178
+ ```bash
179
+ npm run typecheck
180
+ ```
181
+
182
+ ## API Documentation
183
+
184
+ For detailed API documentation, see:
185
+ - [Open Library API](https://openlibrary.org/developers/api)
186
+ - [Open Library Covers API](https://openlibrary.org/dev/docs/api/covers)
187
+
188
+ ## License
189
+
190
+ MIT