feat(metadata): initial implementation of OpenLibrary source (#1764)

This commit is contained in:
James Ward
2026-09-14 08:49:38 +01:00
committed by GitHub
parent 7a9cd31074
commit 9b38a091e1
72 changed files with 1037 additions and 20 deletions
@@ -21,19 +21,21 @@ public class BookParserConfig {
RanobeDbParser ranobedbParser,
LubimyCzytacParser lubimyczytacParser,
AudibleParser audibleParser,
AppleBooksParser appleBooksParser
AppleBooksParser appleBooksParser,
OpenLibraryParser openLibraryParser
) {
return Map.of(
MetadataProvider.Amazon, amazonBookParser,
MetadataProvider.GoodReads, goodReadsParser,
MetadataProvider.Google, googleParser,
MetadataProvider.Hardcover, hardcoverParser,
MetadataProvider.Comicvine, comicvineBookParser,
MetadataProvider.Douban, doubanBookParser,
MetadataProvider.Lubimyczytac, lubimyczytacParser,
MetadataProvider.Ranobedb, ranobedbParser,
MetadataProvider.Audible, audibleParser,
MetadataProvider.AppleBooks, appleBooksParser
return Map.ofEntries(
Map.entry(MetadataProvider.OpenLibrary, openLibraryParser),
Map.entry(MetadataProvider.Amazon, amazonBookParser),
Map.entry(MetadataProvider.GoodReads, goodReadsParser),
Map.entry(MetadataProvider.Google, googleParser),
Map.entry(MetadataProvider.Hardcover, hardcoverParser),
Map.entry(MetadataProvider.Comicvine, comicvineBookParser),
Map.entry(MetadataProvider.Douban, doubanBookParser),
Map.entry(MetadataProvider.Lubimyczytac, lubimyczytacParser),
Map.entry(MetadataProvider.Ranobedb, ranobedbParser),
Map.entry(MetadataProvider.Audible, audibleParser),
Map.entry(MetadataProvider.AppleBooks, appleBooksParser)
);
}
}
@@ -15,6 +15,7 @@ public class MetadataClearFlags {
private boolean seriesTotal;
private boolean isbn13;
private boolean isbn10;
private boolean openlibraryId;
private boolean asin;
private boolean goodreadsId;
private boolean comicvineId;
@@ -35,6 +35,7 @@ public class BookMetadata {
private AudiobookMetadata audiobookMetadata;
private ComicMetadata comicMetadata;
private String openlibraryId;
private String asin;
private Double amazonRating;
private Integer amazonReviewCount;
@@ -85,6 +86,7 @@ public class BookMetadata {
private Boolean seriesTotalLocked;
private Boolean isbn13Locked;
private Boolean isbn10Locked;
private Boolean openlibraryIdLocked;
private Boolean asinLocked;
private Boolean goodreadsIdLocked;
private Boolean comicvineIdLocked;
@@ -39,6 +39,7 @@ public class EpubMetadata {
private Double hardcoverRating;
private Integer hardcoverReviewCount;
private String googleId;
private String openlibraryId;
private String ranobedbId;
private Double ranobedbRating;
private List<String> authors;
@@ -53,6 +53,7 @@ public class MetadataRefreshOptions {
private FieldProvider categories;
private FieldProvider cover;
private FieldProvider pageCount;
private FieldProvider openlibraryId;
private FieldProvider asin;
private FieldProvider goodreadsId;
private FieldProvider comicvineId;
@@ -131,6 +132,8 @@ public class MetadataRefreshOptions {
@Builder.Default @JsonSetter(nulls = Nulls.SKIP)
private boolean pageCount = true;
@Builder.Default @JsonSetter(nulls = Nulls.SKIP)
private boolean openlibraryId = true;
@Builder.Default @JsonSetter(nulls = Nulls.SKIP)
private boolean asin = true;
@Builder.Default @JsonSetter(nulls = Nulls.SKIP)
private boolean goodreadsId = true;
@@ -199,6 +202,7 @@ public class MetadataRefreshOptions {
this.categories = true;
this.cover = true;
this.pageCount = true;
this.openlibraryId = true;
this.asin = true;
this.goodreadsId = true;
this.comicvineId = true;
@@ -5,6 +5,7 @@ import lombok.Data;
@Data
public class MetadataProviderSettings {
private OpenLibrary openLibrary;
private Amazon amazon;
private Google google;
private Goodreads goodReads;
@@ -17,6 +18,11 @@ public class MetadataProviderSettings {
private Audible audible;
private AppleBooks appleBooks;
@Data
public static class OpenLibrary {
private boolean enabled;
}
@Data
public static class Amazon {
private boolean enabled;
@@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class MetadataProviderSpecificFields {
private Boolean openlibraryId;
private Boolean asin;
private Boolean amazonRating;
private Boolean amazonReviewCount;
@@ -22,4 +22,5 @@ public class SidecarIdentifiers {
private String ranobedbId;
private String audibleId;
private String applebooksId;
private String openlibraryId;
}
@@ -96,6 +96,9 @@ public class BookMetadataEntity {
@Column(name = "hardcover_review_count")
private Integer hardcoverReviewCount;
@Column(name = "openlibrary_id", length = 100)
private String openlibraryId;
@Column(name = "asin", length = 10)
private String asin;
@@ -172,6 +175,10 @@ public class BookMetadataEntity {
@Builder.Default
private Boolean isbn10Locked = Boolean.FALSE;
@Column(name = "openlibrary_id_locked")
@Builder.Default
private Boolean openlibraryIdLocked = Boolean.FALSE;
@Column(name = "asin_locked")
@Builder.Default
private Boolean asinLocked = Boolean.FALSE;
@@ -364,6 +371,7 @@ public class BookMetadataEntity {
this.language = trimOrNull(this.language);
this.isbn13 = trimOrNull(this.isbn13);
this.isbn10 = trimOrNull(this.isbn10);
this.openlibraryId = trimOrNull(this.openlibraryId);
this.asin = trimOrNull(this.asin);
this.goodreadsId = trimOrNull(this.goodreadsId);
this.hardcoverId = trimOrNull(this.hardcoverId);
@@ -447,6 +455,7 @@ public class BookMetadataEntity {
this.descriptionLocked = lock;
this.isbn13Locked = lock;
this.isbn10Locked = lock;
this.openlibraryIdLocked = lock;
this.asinLocked = lock;
this.pageCountLocked = lock;
this.languageLocked = lock;
@@ -498,6 +507,7 @@ public class BookMetadataEntity {
&& Boolean.TRUE.equals(this.descriptionLocked)
&& Boolean.TRUE.equals(this.isbn13Locked)
&& Boolean.TRUE.equals(this.isbn10Locked)
&& Boolean.TRUE.equals(this.openlibraryIdLocked)
&& Boolean.TRUE.equals(this.asinLocked)
&& Boolean.TRUE.equals(this.pageCountLocked)
&& Boolean.TRUE.equals(this.languageLocked)
@@ -1,6 +1,7 @@
package org.booklore.model.enums;
public enum MetadataProvider {
OpenLibrary,
Amazon,
GoodReads,
Google,
@@ -270,7 +270,7 @@ public class BookRuleEvaluatorService {
case "title", "subtitle", "description", "publisher", "language", "seriesName",
"isbn13", "isbn10", "asin", "contentRating", "narrator",
"goodreadsId", "hardcoverId", "googleId", "audibleId", "applebooksId",
"lubimyczytacId", "ranobedbId", "comicvineId" ->
"lubimyczytacId", "ranobedbId", "comicvineId", "openlibraryId" ->
stringPresence(cb, root.get("metadata").get(metadataField));
// Numeric/date/boolean fields on BookMetadataEntity
@@ -0,0 +1,16 @@
package org.booklore.service;
import org.springframework.stereotype.Service;
import java.time.Duration;
@Service
public class SleepService {
public void sleep(Duration duration) throws InterruptedException {
Thread.sleep(duration);
}
public void sleep(long millis) throws InterruptedException {
Thread.sleep(millis);
}
}
@@ -347,6 +347,9 @@ public class AppSettingService {
private MetadataProviderSettings getDefaultMetadataProviderSettings() {
MetadataProviderSettings defaultMetadataProviderSettings = new MetadataProviderSettings();
MetadataProviderSettings.OpenLibrary defaultOpenLibrary = new MetadataProviderSettings.OpenLibrary();
defaultOpenLibrary.setEnabled(false);
MetadataProviderSettings.Amazon defaultAmazon = new MetadataProviderSettings.Amazon();
defaultAmazon.setEnabled(true);
defaultAmazon.setCookie(null);
@@ -376,6 +379,7 @@ public class AppSettingService {
defaultAppleBooks.setEnabled(false);
defaultAppleBooks.setCountry("US");
defaultMetadataProviderSettings.setOpenLibrary(defaultOpenLibrary);
defaultMetadataProviderSettings.setAmazon(defaultAmazon);
defaultMetadataProviderSettings.setGoogle(defaultGoogle);
defaultMetadataProviderSettings.setGoodReads(defaultGoodreads);
@@ -413,6 +417,7 @@ public class AppSettingService {
.categories(goodreadsGoogleProvider)
.cover(goodreadsGoogleProvider)
.pageCount(goodreadsGoogleProvider)
.openlibraryId(nullProvider)
.asin(nullProvider)
.goodreadsId(nullProvider)
.comicvineId(nullProvider)
@@ -455,6 +460,7 @@ public class AppSettingService {
.categories(true)
.cover(true)
.pageCount(true)
.openlibraryId(true)
.asin(true)
.goodreadsId(true)
.comicvineId(true)
@@ -608,6 +614,7 @@ public class AppSettingService {
private MetadataProviderSpecificFields getDefaultMetadataProviderSpecificFields() {
MetadataProviderSpecificFields fields = new MetadataProviderSpecificFields();
fields.setOpenlibraryId(true);
fields.setAsin(true);
fields.setAmazonRating(true);
fields.setAmazonReviewCount(true);
@@ -154,6 +154,7 @@ public class BookFileDetachmentService {
copy.setRanobedbRating(source.getRanobedbRating());
copy.setAudibleRating(source.getAudibleRating());
copy.setAudibleReviewCount(source.getAudibleReviewCount());
copy.setOpenlibraryId(source.getOpenlibraryId());
copy.setAsin(source.getAsin());
copy.setGoodreadsId(source.getGoodreadsId());
copy.setHardcoverId(source.getHardcoverId());
@@ -201,6 +201,7 @@ public class BookQueryService {
m.setSeriesTotalLocked(null);
m.setIsbn13Locked(null);
m.setIsbn10Locked(null);
m.setOpenlibraryIdLocked(null);
m.setAsinLocked(null);
m.setGoodreadsIdLocked(null);
m.setComicvineIdLocked(null);
@@ -242,6 +243,7 @@ public class BookQueryService {
m.setContentRatingLocked(null);
// Strip external IDs
m.setOpenlibraryId(null);
m.setAsin(null);
m.setGoodreadsId(null);
m.setComicvineId(null);
@@ -338,7 +340,7 @@ public class BookQueryService {
m.getTitleLocked(), m.getSubtitleLocked(), m.getPublisherLocked(),
m.getPublishedDateLocked(), m.getDescriptionLocked(), m.getSeriesNameLocked(),
m.getSeriesNumberLocked(), m.getSeriesTotalLocked(), m.getIsbn13Locked(),
m.getIsbn10Locked(), m.getAsinLocked(), m.getGoodreadsIdLocked(),
m.getIsbn10Locked(), m.getOpenlibraryIdLocked(), m.getAsinLocked(), m.getGoodreadsIdLocked(),
m.getComicvineIdLocked(), m.getHardcoverIdLocked(), m.getHardcoverBookIdLocked(),
m.getDoubanIdLocked(), m.getGoogleIdLocked(), m.getPageCountLocked(),
m.getLanguageLocked(), m.getAmazonRatingLocked(), m.getAmazonReviewCountLocked(),
@@ -141,6 +141,7 @@ public class DuplicateDetectionService {
addIfPresent(ids, "audible:", meta.getAudibleId());
addIfPresent(ids, "comicvine:", meta.getComicvineId());
addIfPresent(ids, "applebooks:", meta.getApplebooksId());
addIfPresent(ids, "openlibrary:", meta.getOpenlibraryId());
return ids;
}
@@ -67,5 +67,6 @@ public class BookdropMetadataHelper {
if (source.getIsbn13() != null) target.setIsbn13(source.getIsbn13());
if (source.getAsin() != null) target.setAsin(source.getAsin());
if (source.getApplebooksId() != null) target.setApplebooksId(source.getApplebooksId());
if (source.getOpenlibraryId() != null) target.setOpenlibraryId(source.getOpenlibraryId());
}
}
@@ -121,6 +121,7 @@ public class BookdropMetadataService {
m.getIsbn13(), m.getIsbn10(), m.getAsin(),
m.getGoodreadsId(), m.getGoogleId(),
m.getHardcoverId(), m.getHardcoverBookId(),
m.getOpenlibraryId(),
m.getComicvineId(), m.getDoubanId(), m.getApplebooksId(),
m.getLubimyczytacId(), m.getRanobedbId(), m.getAudibleId()
).anyMatch(id -> id != null && !id.isBlank());
@@ -156,6 +157,7 @@ public class BookdropMetadataService {
// External IDs
.asin(truncate(extracted.getAsin(), 10))
.audibleId(truncate(extracted.getAudibleId(), 10))
.openlibraryId(truncate(extracted.getOpenlibraryId(), 100))
.goodreadsId(truncate(extracted.getGoodreadsId(), 100))
.hardcoverId(truncate(extracted.getHardcoverId(), 100))
.hardcoverBookId(truncate(extracted.getHardcoverBookId(), 100))
@@ -119,6 +119,7 @@ public class Azw3Processor extends AbstractFileProcessor implements BookFileProc
String lang = azw3Metadata.getLanguage();
metadata.setLanguage(truncate((lang == null || "UND".equalsIgnoreCase(lang)) ? "en" : lang, 10));
metadata.setOpenlibraryId(truncate(azw3Metadata.getOpenlibraryId(), 100));
metadata.setAsin(truncate(azw3Metadata.getAsin(), 10));
metadata.setAmazonRating(azw3Metadata.getAmazonRating());
metadata.setAmazonReviewCount(azw3Metadata.getAmazonReviewCount());
@@ -152,6 +152,7 @@ public class CbxProcessor extends AbstractFileProcessor implements BookFileProce
metadata.setIsbn10(truncate(extracted.getIsbn10(), 10));
// External IDs
metadata.setOpenlibraryId(truncate(extracted.getOpenlibraryId(), 100));
metadata.setAsin(truncate(extracted.getAsin(), 10));
metadata.setGoodreadsId(truncate(extracted.getGoodreadsId(), 100));
metadata.setHardcoverId(truncate(extracted.getHardcoverId(), 100));
@@ -128,6 +128,7 @@ public class EpubProcessor extends AbstractFileProcessor implements BookFileProc
String lang = epubMetadata.getLanguage();
metadata.setLanguage(truncate((lang == null || "UND".equalsIgnoreCase(lang)) ? "en" : lang, 10));
metadata.setOpenlibraryId(truncate(epubMetadata.getOpenlibraryId(), 100));
metadata.setAsin(truncate(epubMetadata.getAsin(), 10));
metadata.setAmazonRating(epubMetadata.getAmazonRating());
metadata.setAmazonReviewCount(epubMetadata.getAmazonReviewCount());
@@ -115,6 +115,7 @@ public class Fb2Processor extends AbstractFileProcessor implements BookFileProce
String lang = fb2Metadata.getLanguage();
metadata.setLanguage(truncate((lang == null || "UND".equalsIgnoreCase(lang)) ? "en" : lang, 10));
metadata.setOpenlibraryId(truncate(fb2Metadata.getOpenlibraryId(), 100));
metadata.setAsin(truncate(fb2Metadata.getAsin(), 10));
metadata.setAmazonRating(fb2Metadata.getAmazonRating());
metadata.setAmazonReviewCount(fb2Metadata.getAmazonReviewCount());
@@ -120,6 +120,7 @@ public class MobiProcessor extends AbstractFileProcessor implements BookFileProc
String lang = mobiMetadata.getLanguage();
metadata.setLanguage(truncate((lang == null || "UND".equalsIgnoreCase(lang)) ? "en" : lang, 10));
metadata.setOpenlibraryId(truncate(mobiMetadata.getOpenlibraryId(), 100));
metadata.setAsin(truncate(mobiMetadata.getAsin(), 10));
metadata.setAmazonRating(mobiMetadata.getAmazonRating());
metadata.setAmazonReviewCount(mobiMetadata.getAmazonReviewCount());
@@ -137,6 +137,9 @@ public class PdfProcessor extends AbstractFileProcessor implements BookFileProce
}
// External IDs
if (StringUtils.isNotBlank(extracted.getOpenlibraryId())) {
bookEntity.getMetadata().setOpenlibraryId(truncate(extracted.getOpenlibraryId(), 100));
}
if (StringUtils.isNotBlank(extracted.getAsin())) {
bookEntity.getMetadata().setAsin(truncate(extracted.getAsin(), 10));
}
@@ -500,6 +500,9 @@ public class CbxConversionService {
if (metadata.getAsin() != null && !metadata.getAsin().trim().isEmpty()) {
model.put("asin", metadata.getAsin());
}
if (metadata.getOpenlibraryId() != null && !metadata.getOpenlibraryId().trim().isEmpty()) {
model.put("openlibraryId", metadata.getOpenlibraryId());
}
if (metadata.getGoodreadsId() != null && !metadata.getGoodreadsId().trim().isEmpty()) {
model.put("goodreadsId", metadata.getGoodreadsId());
}
@@ -188,6 +188,7 @@ public class BookMetadataUpdater {
handleFieldUpdate(e.getSeriesTotalLocked(), clear.isSeriesTotal(), m.getSeriesTotal(), e::setSeriesTotal, e::getSeriesTotal, replaceMode);
handleFieldUpdate(e.getIsbn13Locked(), clear.isIsbn13(), m.getIsbn13(), v -> e.setIsbn13(nullIfBlank(v)), e::getIsbn13, replaceMode);
handleFieldUpdate(e.getIsbn10Locked(), clear.isIsbn10(), m.getIsbn10(), v -> e.setIsbn10(nullIfBlank(v)), e::getIsbn10, replaceMode);
handleFieldUpdate(e.getOpenlibraryIdLocked(), clear.isOpenlibraryId(), m.getOpenlibraryId(), v -> e.setOpenlibraryId(nullIfBlank(v)), e::getOpenlibraryId, replaceMode);
handleFieldUpdate(e.getAsinLocked(), clear.isAsin(), m.getAsin(), v -> e.setAsin(nullIfBlank(v)), e::getAsin, replaceMode);
handleFieldUpdate(e.getGoodreadsIdLocked(), clear.isGoodreadsId(), m.getGoodreadsId(), v -> e.setGoodreadsId(nullIfBlank(v)), e::getGoodreadsId, replaceMode);
handleFieldUpdate(e.getComicvineIdLocked(), clear.isComicvineId(), m.getComicvineId(), v -> e.setComicvineId(nullIfBlank(v)), e::getComicvineId, replaceMode);
@@ -696,6 +697,7 @@ public class BookMetadataUpdater {
Pair.of(m.getSeriesTotalLocked(), e::setSeriesTotalLocked),
Pair.of(m.getIsbn13Locked(), e::setIsbn13Locked),
Pair.of(m.getIsbn10Locked(), e::setIsbn10Locked),
Pair.of(m.getOpenlibraryIdLocked(), e::setOpenlibraryIdLocked),
Pair.of(m.getAsinLocked(), e::setAsinLocked),
Pair.of(m.getGoodreadsIdLocked(), e::setGoodreadsIdLocked),
Pair.of(m.getComicvineIdLocked(), e::setComicvineIdLocked),
@@ -350,6 +350,7 @@ public class MetadataRefreshService {
addProviderToSet(fieldOptions.getCategories(), uniqueProviders, appSettings);
addProviderToSet(fieldOptions.getCover(), uniqueProviders, appSettings);
addProviderToSet(fieldOptions.getPageCount(), uniqueProviders, appSettings);
addProviderToSet(fieldOptions.getOpenlibraryId(), uniqueProviders, appSettings);
addProviderToSet(fieldOptions.getAsin(), uniqueProviders, appSettings);
addProviderToSet(fieldOptions.getGoodreadsId(), uniqueProviders, appSettings);
addProviderToSet(fieldOptions.getComicvineId(), uniqueProviders, appSettings);
@@ -394,6 +395,7 @@ public class MetadataRefreshService {
var settings = appSettings.getMetadataProviderSettings();
return switch (provider) {
case OpenLibrary -> settings.getOpenLibrary() != null && settings.getOpenLibrary().isEnabled();
case Amazon -> settings.getAmazon() != null && settings.getAmazon().isEnabled();
case Google -> settings.getGoogle() != null && settings.getGoogle().isEnabled();
case GoodReads -> settings.getGoodReads() != null && settings.getGoodReads().isEnabled();
@@ -587,6 +589,14 @@ public class MetadataRefreshService {
metadata.setHardcoverReviewCount(existingMetadata.getHardcoverReviewCount());
}
if (enabledFields.isOpenlibraryId()) {
if (metadataMap.containsKey(OpenLibrary)) {
metadata.setOpenlibraryId(metadataMap.get(OpenLibrary).getOpenlibraryId());
}
} else if (isReplaceAll && existingMetadata != null) {
metadata.setOpenlibraryId(existingMetadata.getOpenlibraryId());
}
if (enabledFields.isAsin()) {
if (metadataMap.containsKey(Amazon)) {
metadata.setAsin(metadataMap.get(Amazon).getAsin());
@@ -764,6 +774,7 @@ public class MetadataRefreshService {
metadata.setLanguageLocked(existingMetadata.getLanguageLocked());
metadata.setCoverLocked(existingMetadata.getCoverLocked());
metadata.setAudiobookCoverLocked(existingMetadata.getAudiobookCoverLocked());
metadata.setOpenlibraryIdLocked(existingMetadata.getOpenlibraryIdLocked());
metadata.setAsinLocked(existingMetadata.getAsinLocked());
metadata.setGoodreadsIdLocked(existingMetadata.getGoodreadsIdLocked());
metadata.setComicvineIdLocked(existingMetadata.getComicvineIdLocked());
@@ -37,6 +37,7 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
private static final Pattern WEB_SPLIT_PATTERN = Pattern.compile("[,;\\s]+");
// URL Patterns
private static final Pattern OPENLIBRARY_URL_PATTERN = Pattern.compile("openlibrary\\.org(/[^/]+/[^/]+)");
private static final Pattern GOODREADS_URL_PATTERN = Pattern.compile("goodreads\\.com/book/show/(\\d+)(?:-[\\w-]+)?");
private static final Pattern AMAZON_URL_PATTERN = Pattern.compile("amazon\\.com/dp/([A-Z0-9]{10})");
private static final Pattern COMICVINE_URL_PATTERN = Pattern.compile("comicvine\\.gamespot\\.com/(?:issue|volume)/(?:[^/]+/)?(\\d+-\\d+)");
@@ -308,6 +309,12 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
if (url.isBlank()) continue;
url = url.trim();
Matcher olMatcher = OPENLIBRARY_URL_PATTERN.matcher(url);
if (olMatcher.find()) {
builder.openlibraryId(olMatcher.group(1));
continue;
}
Matcher grMatcher = GOODREADS_URL_PATTERN.matcher(url);
if (grMatcher.find()) {
builder.goodreadsId(grMatcher.group(1));
@@ -379,6 +386,7 @@ public class CbxMetadataExtractor implements FileMetadataExtractor {
case "RanobedbId" -> builder.ranobedbId(value);
case "GoogleId" -> builder.googleId(value);
case "GoodreadsId" -> builder.goodreadsId(value);
case "OpenlibraryId" -> builder.openlibraryId(value);
case "ASIN" -> builder.asin(value);
case "ComicvineId" -> builder.comicvineId(value);
case "ApplebooksId" -> builder.applebooksId(value);
@@ -50,6 +50,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
Map.entry("amazon", BookMetadata.BookMetadataBuilder::asin),
Map.entry("asin", BookMetadata.BookMetadataBuilder::asin),
Map.entry("mobi-asin", BookMetadata.BookMetadataBuilder::asin),
Map.entry("openlibrary", BookMetadata.BookMetadataBuilder::openlibraryId),
Map.entry("goodreads", BookMetadata.BookMetadataBuilder::goodreadsId),
Map.entry("google", BookMetadata.BookMetadataBuilder::googleId),
Map.entry("hardcover", BookMetadata.BookMetadataBuilder::hardcoverId),
@@ -218,6 +219,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
switch (key) {
case BookLoreMetadata.NS_PREFIX + ":asin" -> builderMeta.asin(content);
case BookLoreMetadata.NS_PREFIX + ":openlibrary_id" -> builderMeta.openlibraryId(content);
case BookLoreMetadata.NS_PREFIX + ":goodreads_id" -> builderMeta.goodreadsId(content);
case BookLoreMetadata.NS_PREFIX + ":comicvine_id" -> builderMeta.comicvineId(content);
case BookLoreMetadata.NS_PREFIX + ":ranobedb_id" -> builderMeta.ranobedbId(content);
@@ -315,6 +317,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
if (cleanValue.length() == 13) builderMeta.isbn13(value);
else if (cleanValue.length() == 10) builderMeta.isbn10(value);
}
case "OPENLIBRARY" -> builderMeta.openlibraryId(value);
case "GOODREADS" -> builderMeta.goodreadsId(value);
case "COMICVINE" -> builderMeta.comicvineId(value);
case "RANOBEDB" -> builderMeta.ranobedbId(value);
@@ -209,6 +209,7 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
findCustomField(xmp, rawXmp, "isbn10").ifPresent(val -> metadataBuilder.isbn10(cleanIsbn(val)));
findCustomField(xmp, rawXmp, "googleId").ifPresent(metadataBuilder::googleId);
findCustomField(xmp, rawXmp, "goodreadsId").ifPresent(metadataBuilder::goodreadsId);
findCustomField(xmp, rawXmp, "openlibraryId").ifPresent(metadataBuilder::openlibraryId);
findCustomField(xmp, rawXmp, "amazonId").ifPresent(metadataBuilder::asin);
findCustomField(xmp, rawXmp, "asin").ifPresent(metadataBuilder::asin);
findCustomField(xmp, rawXmp, "comicvineId").ifPresent(metadataBuilder::comicvineId);
@@ -233,6 +234,7 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
case "isbn10" -> metadataBuilder.isbn10(cleanIsbn(value));
case "google" -> metadataBuilder.googleId(value);
case "amazon", "asin", "amazonid" -> metadataBuilder.asin(value);
case "openlibrary" -> metadataBuilder.openlibraryId(value);
case "goodreads" -> metadataBuilder.goodreadsId(value);
case "comicvine" -> metadataBuilder.comicvineId(value);
case "ranobedb" -> metadataBuilder.ranobedbId(value);
@@ -0,0 +1,569 @@
package org.booklore.service.metadata.parser;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.booklore.model.dto.Book;
import org.booklore.model.dto.BookMetadata;
import org.booklore.model.dto.request.FetchMetadataRequest;
import org.booklore.model.enums.MetadataProvider;
import org.booklore.service.SleepService;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponentsBuilder;
import reactor.core.publisher.Flux;
import tools.jackson.core.JacksonException;
import tools.jackson.core.JsonParser;
import tools.jackson.databind.DatabindException;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.annotation.JsonDeserialize;
import tools.jackson.databind.deser.std.StdDeserializer;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
@Slf4j
@Service
@RequiredArgsConstructor
public class OpenLibraryParser implements BookParser {
// The OpenLibrary rate limit for their API is 180/minute.
// We set ours to 160/m to reduce the chance of hitting 429s
// https://github.com/internetarchive/openlibrary/blob/master/docker/nginx.conf#L99
private static final int REQUEST_RATE_LIMIT = 160;
private static final int RATE_LIMIT_PER = 60000;
// https://github.com/internetarchive/openlibrary/blob/master/openlibrary/plugins/openlibrary/config/edition/identifiers.yml
private static final String IDENTIFIER_GOODREADS = "goodreads";
private static final String IDENTIFIER_GOOGLE = "google";
private static final String IDENTIFIER_AMAZON = "amazon";
private static final String COVERS_BASE_URI = "https://covers.openlibrary.org/";
private static final String COVER_PATH = "/b/id/{cover_id}-{size}.jpg";
private static final String BASE_URI = "https://openlibrary.org/";
private static final String SEARCH_PATH = "/search.json";
private static final String WORKS_PATH = "/works/{work_id}.json";
private static final String SERIES_PATH = "/series/{series_id}.json";
private static final String EDITIONS_PATH = "/books/{edition_id}.json";
private static final String AUTHORS_PATH = "/authors/{author_id}.json";
private static final String SEARCH_FIELDS = "key,author_key,editions,editions.key";
private static final String USER_AGENT = "Grimmory (developers@grimmory.org)";
// Public because it has to be for Jackson to use it.
public static class OpenLibraryTypedValueDeserializer extends StdDeserializer<OpenLibraryTypedValue> {
public OpenLibraryTypedValueDeserializer() {
super(OpenLibraryTypedValue.class);
}
@Override
public OpenLibraryTypedValue deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException {
JsonNode node = p.readValueAsTree();
JsonNode typeNode = node.get("type");
JsonNode valueNode = node.get("value");
try {
if (typeNode != null && !typeNode.isNull() && valueNode != null && !valueNode.isNull()) {
return new OpenLibraryTypedValue(
typeNode.stringValue(),
valueNode.stringValue()
);
}
} catch (DatabindException e) {
// Do nothing
}
try {
String value = node.stringValue();
return new OpenLibraryTypedValue("/type/text", value);
} catch (DatabindException e) {
// Do nothing
}
return null;
}
}
@JsonDeserialize(using = OpenLibraryTypedValueDeserializer.class)
record OpenLibraryTypedValue(
String type,
String value
) {}
record OpenLibraryReference(
String key
) {}
record OpenLibrarySearchDocumentEditions(
Optional<Integer> numFound,
Optional<List<OpenLibraryReference>> docs
) {}
record OpenLibrarySearchDocument(
String key,
@JsonProperty("author_key")
Optional<List<String>> authorKey,
Optional<OpenLibrarySearchDocumentEditions> editions
) {}
record OpenLibrarySearchResult(
int numFound,
List<OpenLibrarySearchDocument> docs
) {}
record OpenLibraryAuthor(
String key,
OpenLibraryReference type,
String name
) {}
record OpenLibraryEdition(
String key,
OpenLibraryReference type,
String title,
Optional<String> subtitle,
Optional<OpenLibraryTypedValue> description,
List<OpenLibraryReference> languages,
List<OpenLibraryReference> authors,
List<OpenLibraryReference> works,
Optional<Map<String, List<String>>> identifiers,
Optional<List<String>> publishers,
@JsonProperty("publish_date")
Optional<String> publishDate,
@JsonProperty("edition_name")
String editionName,
@JsonProperty("number_of_pages")
Optional<Integer> pageCount,
@JsonProperty("isbn_10")
Optional<List<String>> isbn10,
@JsonProperty("isbn_13")
Optional<List<String>> isbn13,
Optional<List<Integer>> covers
) {
String getIdentifier(String name) {
return this.identifiers.flatMap(
i -> i.getOrDefault(name, List.of())
.stream().findFirst()
).orElse(null);
}
}
record OpenLibrarySeries(
OpenLibraryReference type,
String name,
Optional<OpenLibraryTypedValue> description
) {}
record OpenLibraryWorkAuthor(
OpenLibraryReference type,
OpenLibraryReference author
) {}
record OpenLibraryWorkSeries(
String position,
OpenLibraryReference series
) {}
record OpenLibraryWork (
String key,
OpenLibraryReference type,
String title,
Optional<String> subtitle,
Optional<OpenLibraryTypedValue> description,
List<OpenLibraryWorkAuthor> authors,
Optional<List<OpenLibraryWorkSeries>> series,
List<String> subjects,
Optional<List<Integer>> covers,
OpenLibraryTypedValue created,
@JsonProperty("last_modified")
OpenLibraryTypedValue lastModified
) {}
private final HttpClient httpClient;
private final ObjectMapper objectMapper;
private final SleepService sleepService;
private long rateLimitResetTime = 0;
private long rateLimitCounter = 0;
private URI getURI(String path) {
return getURI(path, Map.of(), Map.of());
}
private URI getURI(String path, Map<String, String> pathParameters, Map<String, String> queryParameters) {
return UriComponentsBuilder.fromUriString(BASE_URI)
.path(path)
.queryParams(MultiValueMap.fromSingleValue(queryParameters))
.build(pathParameters);
}
private synchronized void applyRateLimit() throws InterruptedException {
long now = System.currentTimeMillis();
if (rateLimitResetTime < now) {
rateLimitCounter = 0;
rateLimitResetTime = now + RATE_LIMIT_PER;
}
if (rateLimitCounter >= REQUEST_RATE_LIMIT) {
// Slow down.
try {
sleepService.sleep(Math.max(0, rateLimitResetTime - now));
} finally {
rateLimitResetTime = System.currentTimeMillis() + RATE_LIMIT_PER;
rateLimitCounter = 0;
}
} else {
rateLimitCounter++;
}
}
private <T> T sendRequest(HttpRequest request, Class<T> tClass) throws InterruptedException {
request = HttpRequest.newBuilder(request, (n, v) -> !n.equalsIgnoreCase("User-Agent"))
.header("User-Agent", USER_AGENT)
.build();
log.debug("Making request: {}", request.uri().toString());
applyRateLimit();
try {
HttpResponse<InputStream> response = httpClient.send(request, HttpResponse.BodyHandlers.ofInputStream());
if (response.statusCode() < 200 || response.statusCode() > 399) {
log.error("OpenLibrary request failed with status code: {}", response.statusCode());
throw new RuntimeException("Failed to query OpenLibrary");
}
log.debug("Request success with code {}", response.statusCode());
try (InputStream stream = response.body()) {
return objectMapper.readValue(stream, tClass);
}
} catch (IOException e) {
log.error("OpenLibrary request failed", e);
throw new RuntimeException(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
}
}
private String escapeSolrValue(String value) {
return value.replaceAll("[-+&|!(){}\\[\\]^\"~*?:\\\\/]", "\\\\$0");
}
private String getSolrQuery(List<String> predicates, boolean isConjunction) {
predicates = predicates.stream().filter(p -> !p.isBlank()).toList();
if (predicates.isEmpty()) {
return "";
}
return "(" + String.join(isConjunction ? " AND " : " OR ", predicates) + ")";
}
private String getSolrAuthorTitleQuery(FetchMetadataRequest fetchMetadataRequest) {
List<String> predicates = new ArrayList<>();
if (fetchMetadataRequest.getTitle() != null && !fetchMetadataRequest.getTitle().isBlank()) {
predicates.add("title:" + escapeSolrValue(fetchMetadataRequest.getTitle()));
}
if (fetchMetadataRequest.getAuthor() != null && !fetchMetadataRequest.getAuthor().isBlank()) {
predicates.add("author_name:" + escapeSolrValue(fetchMetadataRequest.getAuthor()));
}
return getSolrQuery(predicates, true);
}
private String getSolrQuery(FetchMetadataRequest fetchMetadataRequest) {
List<String> predicates = new ArrayList<>();
predicates.add(getSolrAuthorTitleQuery(fetchMetadataRequest));
if (fetchMetadataRequest.getIsbn() != null && !fetchMetadataRequest.getIsbn().isBlank()) {
predicates.add("isbn:" + escapeSolrValue(fetchMetadataRequest.getIsbn()));
}
return getSolrQuery(predicates, false);
}
private OpenLibrarySearchResult search(FetchMetadataRequest fetchMetadataRequest, int limit) throws InterruptedException {
String solrQuery = getSolrQuery(fetchMetadataRequest);
if (solrQuery.isEmpty()) {
// Empty query means no results.
log.info("No search query available");
return new OpenLibrarySearchResult(0, List.of());
}
URI uri = getURI(
SEARCH_PATH,
Map.of(),
Map.of(
"q", solrQuery,
"fields", SEARCH_FIELDS,
"limit", String.valueOf(limit)
)
);
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.GET()
.build();
return sendRequest(request, OpenLibrarySearchResult.class);
}
private String getId(String type, String reference) {
String[] parts = reference.split("/");
if (parts.length != 3 || !parts[1].equalsIgnoreCase(type)) {
throw new RuntimeException("Wrong key type");
}
return parts[2];
}
private OpenLibraryAuthor getAuthor(String reference) throws InterruptedException {
String id = getId("authors", reference);
URI uri = getURI(AUTHORS_PATH, Map.of("author_id", id), Map.of());
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.GET()
.build();
return sendRequest(request, OpenLibraryAuthor.class);
}
private OpenLibraryEdition getEdition(String reference) throws InterruptedException {
String id = getId("books", reference);
URI uri = getURI(EDITIONS_PATH, Map.of("edition_id", id), Map.of());
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.GET()
.build();
return sendRequest(request, OpenLibraryEdition.class);
}
private OpenLibrarySeries getSeries(String reference) throws InterruptedException {
String id = getId("series", reference);
URI uri = getURI(SERIES_PATH, Map.of("series_id", id), Map.of());
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.GET()
.build();
return sendRequest(request, OpenLibrarySeries.class);
}
private OpenLibraryWork getWork(String reference) throws InterruptedException {
String id = getId("works", reference);
URI uri = getURI(WORKS_PATH, Map.of("work_id", id), Map.of());
HttpRequest request = HttpRequest.newBuilder()
.uri(uri)
.GET()
.build();
return sendRequest(request, OpenLibraryWork.class);
}
private Optional<URI> getCoverUri(
Integer coverId,
String size
) {
if (coverId == null || size == null) {
return Optional.empty();
}
return Optional.of(UriComponentsBuilder.fromUriString(COVERS_BASE_URI)
.path(COVER_PATH)
.build(Map.of("cover_id", coverId, "size", size)));
}
private Optional<URI> getCoverUri(
OpenLibraryWork work,
OpenLibraryEdition edition,
String size
) {
if (edition != null) {
Integer editionCoverId = edition.covers.flatMap(c -> c.stream().findFirst()).orElse(null);
if (editionCoverId != null) {
return getCoverUri(
editionCoverId,
size
);
}
}
Integer workCoverId = work.covers.flatMap(c -> c.stream().findFirst()).orElse(null);
if (workCoverId != null) {
return getCoverUri(
workCoverId,
size
);
}
return Optional.empty();
}
private BookMetadata toMetadata(
OpenLibraryWork work,
OpenLibrarySeries series,
OpenLibraryEdition edition,
List<OpenLibraryAuthor> authors
) {
var builder = BookMetadata.builder()
.provider(MetadataProvider.OpenLibrary)
.description(work.description.map(OpenLibraryTypedValue::value).orElse(null))
.authors(authors.stream().map(a -> a.name).toList())
.thumbnailUrl(getCoverUri(work, edition, "M").map(URI::toString).orElse(null));
if (series != null) {
builder.seriesName(series.name);
}
if (!work.series.map(List::isEmpty).orElse(true)) {
String[] position = work.series.get().getFirst().position.split("-");
if (position.length == 2) {
try {
Float seriesNumber = Float.valueOf(position[0]);
Integer seriesTotal = Integer.valueOf(position[1]);
builder
.seriesNumber(seriesNumber)
.seriesTotal(seriesTotal);
} catch (NumberFormatException e) {
// Do nothing
}
}
}
if (edition != null) {
builder
.externalUrl(getURI(edition.key).toString())
.title(edition.title)
.subtitle(edition.subtitle.orElse(null))
.openlibraryId(edition.key)
.publisher(edition.publishers.flatMap(p -> p.stream().findFirst()).orElse(null))
.isbn10(edition.isbn10.flatMap(i -> i.stream().findFirst()).orElse(null))
.isbn13(edition.isbn13.flatMap(i -> i.stream().findFirst()).orElse(null))
.pageCount(edition.pageCount.orElse(null))
.goodreadsId(edition.getIdentifier(IDENTIFIER_GOODREADS))
.googleId(edition.getIdentifier(IDENTIFIER_GOOGLE))
.asin(edition.getIdentifier(IDENTIFIER_AMAZON));
} else {
builder
.externalUrl(getURI(work.key).toString())
.openlibraryId(work.key)
.title(work.title)
.subtitle(work.subtitle.orElse(null));
}
return builder.build();
}
@Override
public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
return fetchMetadataStream(book, fetchMetadataRequest).collectList().block();
}
public Flux<BookMetadata> fetchMetadataStream(Book book, FetchMetadataRequest fetchMetadataRequest) {
return fetchMetadataStream(book, fetchMetadataRequest, 10);
}
public Flux<BookMetadata> fetchMetadataStream(Book book, FetchMetadataRequest fetchMetadataRequest, int limit) {
return Flux.create(sink -> {
try {
OpenLibrarySearchResult searchResponse = search(fetchMetadataRequest, limit);
log.debug("Found {} total results, using {}", searchResponse.numFound, searchResponse.docs.size());
Map<String, OpenLibraryAuthor> seenAuthors = new HashMap<>();
for (OpenLibrarySearchDocument document : searchResponse.docs) {
if (sink.isCancelled()) {
return;
}
log.debug("OpenLibrary: Fetching metadata for Work: {}", document.key);
try {
OpenLibraryWork work = this.getWork(document.key);
OpenLibrarySeries series = null;
if (!work.series.map(List::isEmpty).orElse(true)) {
series = this.getSeries(work.series.get().getFirst().series.key);
}
OpenLibraryEdition edition = null;
var editionDocs = document.editions
.flatMap(e -> e.docs)
.orElseGet(List::of);
if (!editionDocs.isEmpty()) {
edition = this.getEdition(editionDocs.getFirst().key);
}
List<OpenLibraryAuthor> authors = new ArrayList<>();
for (String authorKey : document.authorKey.orElse(List.of())) {
if (seenAuthors.containsKey(authorKey)) {
authors.add(seenAuthors.get(authorKey));
} else {
OpenLibraryAuthor author = this.getAuthor("/authors/" + authorKey);
seenAuthors.put(authorKey, author);
authors.add(author);
}
}
BookMetadata metadata = this.toMetadata(
work,
series,
edition,
authors
);
if (metadata != null) {
sink.next(metadata);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
} catch (Exception e) {
log.error("Error fetching metadata for Work: {}", document.key, e);
}
}
sink.complete();
} catch (Exception e) {
sink.error(e);
}
});
}
@Override
public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
return fetchMetadataStream(book, fetchMetadataRequest, 1).blockFirst();
}
}
@@ -100,6 +100,7 @@ public class SidecarMetadataMapper {
if (m.getIdentifiers() != null) {
SidecarIdentifiers ids = m.getIdentifiers();
builder.asin(ids.getAsin())
.openlibraryId(ids.getOpenlibraryId())
.goodreadsId(ids.getGoodreadsId())
.googleId(ids.getGoogleId())
.hardcoverId(ids.getHardcoverId())
@@ -202,6 +203,7 @@ public class SidecarMetadataMapper {
.ranobedbId(entity.getRanobedbId())
.audibleId(entity.getAudibleId())
.applebooksId(entity.getApplebooksId())
.openlibraryId(entity.getOpenlibraryId())
.build();
}
@@ -245,6 +245,8 @@ public class CbxMetadataWriter implements MetadataWriter {
primaryUrl = "https://www.amazon.com/dp/" + metadata.getAsin();
} else if (metadata.getApplebooksId() != null && !metadata.getApplebooksId().isBlank()) {
primaryUrl = "https://books.apple.com/us/book/id" + metadata.getApplebooksId();
} else if (metadata.getOpenlibraryId() != null && !metadata.getOpenlibraryId().isBlank()) {
primaryUrl = "https://openlibrary.org/" + metadata.getOpenlibraryId().replaceAll("^/+", "");
}
info.setWeb(primaryUrl);
@@ -288,6 +290,7 @@ public class CbxMetadataWriter implements MetadataWriter {
appendBookLoreTag(notesBuilder, "LubimyczytacId", metadata.getLubimyczytacId());
appendBookLoreTag(notesBuilder, "RanobedbId", metadata.getRanobedbId());
appendBookLoreTag(notesBuilder, "GoogleId", metadata.getGoogleId());
appendBookLoreTag(notesBuilder, "OpenlibraryId", metadata.getOpenlibraryId());
appendBookLoreTag(notesBuilder, "GoodreadsId", metadata.getGoodreadsId());
appendBookLoreTag(notesBuilder, "ASIN", metadata.getAsin());
appendBookLoreTag(notesBuilder, "ComicvineId", metadata.getComicvineId());
@@ -157,6 +157,13 @@ public class EpubMetadataWriter implements MetadataWriter {
}
hasChanges[0] = true;
});
helper.copyOpenlibraryId(clear != null && clear.isOpenlibraryId(), val -> {
removeIdentifierByUrn(metadataElement, "openlibrary");
if (val != null && !val.isBlank()) {
metadataElement.appendChild(createIdentifierElement(opfDoc, "openlibrary", val));
}
hasChanges[0] = true;
});
helper.copyGoodreadsId(clear != null && clear.isGoodreadsId(), val -> {
removeIdentifierByUrn(metadataElement, "goodreads");
if (val != null && !val.isBlank()) {
@@ -117,6 +117,13 @@ public class MetadataCopyHelper {
}
}
public void copyOpenlibraryId(boolean clear, Consumer<String> consumer) {
if (!isLocked(metadata.getOpenlibraryIdLocked())) {
if (clear) consumer.accept(null);
else if (metadata.getOpenlibraryId() != null) consumer.accept(metadata.getOpenlibraryId());
}
}
public void copyComicvineId(boolean clear, Consumer<String> consumer) {
if (!isLocked(metadata.getComicvineIdLocked())) {
if (clear) consumer.accept(null);
@@ -266,6 +266,9 @@ public class PdfMetadataWriter implements MetadataWriter {
helper.copyGoogleId(clear != null && clear.isGoogleId(), id -> {
if (id != null && !id.isBlank()) customFields.put(prefix + "googleId", id);
});
helper.copyOpenlibraryId(clear != null && clear.isOpenlibraryId(), id -> {
if (id != null && !id.isBlank()) customFields.put(prefix + "openlibraryId", id);
});
helper.copyGoodreadsId(clear != null && clear.isGoodreadsId(), id -> {
String normalized = normalizeGoodreadsId(id);
if (normalized != null && !normalized.isBlank()) customFields.put(prefix + "goodreadsId", normalized);
@@ -143,6 +143,10 @@ public class MetadataChangeDetector {
BookMetadata::getIsbn10, BookMetadataEntity::getIsbn10,
BookMetadata::getIsbn10Locked, BookMetadataEntity::getIsbn10Locked,
MetadataClearFlags::isIsbn10, true),
new FieldDescriptor<>("openlibraryId",
BookMetadata::getOpenlibraryId, BookMetadataEntity::getOpenlibraryId,
BookMetadata::getOpenlibraryIdLocked, BookMetadataEntity::getOpenlibraryIdLocked,
MetadataClearFlags::isOpenlibraryId, true),
new FieldDescriptor<>("asin",
BookMetadata::getAsin, BookMetadataEntity::getAsin,
BookMetadata::getAsinLocked, BookMetadataEntity::getAsinLocked,
@@ -0,0 +1,4 @@
-- Add OpenLibrary metadata columns
ALTER TABLE book_metadata
ADD COLUMN IF NOT EXISTS openlibrary_id VARCHAR(100),
ADD COLUMN IF NOT EXISTS openlibrary_id_locked BOOLEAN DEFAULT FALSE;
@@ -59,6 +59,10 @@
<dc:identifier id="goodreads">${goodreadsId}</dc:identifier>
<meta refines="#goodreads" property="identifier-type">GOODREADS</meta>
</#if>
<#if openlibraryId?has_content>
<dc:identifier id="openlibrary">${openlibraryId}</dc:identifier>
<meta refines="#openlibrary" property="identifier-type">OPENLIBRARY</meta>
</#if>
<#if applebooksId?has_content>
<dc:identifier id="applebooks">${applebooksId}</dc:identifier>
<meta refines="#applebooks" property="identifier-type">APPLEBOOKS</meta>