feat(metadata): initial implementation of OpenLibrary source (#1764)
This commit is contained in:
@@ -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;
|
||||
|
||||
+1
@@ -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());
|
||||
|
||||
+8
@@ -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);
|
||||
|
||||
+3
@@ -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);
|
||||
|
||||
+2
@@ -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>
|
||||
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
|
||||
package org.booklore.service.metadata.parser;
|
||||
|
||||
import org.booklore.model.dto.Book;
|
||||
import org.booklore.model.dto.BookMetadata;
|
||||
import org.booklore.model.dto.request.FetchMetadataRequest;
|
||||
import org.booklore.service.SleepService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import tools.jackson.databind.ObjectMapper;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class OpenLibraryParserTest {
|
||||
@Mock
|
||||
private HttpClient httpClient;
|
||||
|
||||
@Mock
|
||||
private SleepService sleepService;
|
||||
|
||||
private OpenLibraryParser parser;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws IOException {
|
||||
parser = new OpenLibraryParser(
|
||||
httpClient,
|
||||
new ObjectMapper(),
|
||||
sleepService
|
||||
);
|
||||
}
|
||||
|
||||
private String readFixture(String fixtureName) throws IOException {
|
||||
String filename = Paths.get("openlibrary", fixtureName + ".fixture").toString();
|
||||
|
||||
try (InputStream is = getClass().getClassLoader().getResourceAsStream(filename)) {
|
||||
assert is != null;
|
||||
|
||||
return new String(is.readAllBytes(), StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private HttpResponse<InputStream> getMockResponse(int statusCode, String response) {
|
||||
HttpResponse<InputStream> httpResponse = (HttpResponse<InputStream>) mock(HttpResponse.class);
|
||||
|
||||
when(httpResponse.statusCode()).thenReturn(statusCode);
|
||||
|
||||
if (response != null) {
|
||||
when(httpResponse.body()).thenAnswer(
|
||||
(_) -> new ByteArrayInputStream(response.getBytes(StandardCharsets.UTF_8))
|
||||
);
|
||||
}
|
||||
|
||||
return httpResponse;
|
||||
}
|
||||
|
||||
private void mockHttpClientResponse(String urlPrefix, int statusCode, String response) throws Exception {
|
||||
when(
|
||||
httpClient.<String>send(
|
||||
argThat(r -> r != null && r.uri().toString().startsWith(urlPrefix)),
|
||||
any()
|
||||
)
|
||||
).thenAnswer((_) -> getMockResponse(statusCode, response));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFetchMetadata_EmptyQuery() {
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("Test Book")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.build();
|
||||
// Empty query - no title or ISBN
|
||||
|
||||
// When
|
||||
List<BookMetadata> results = parser.fetchMetadata(book, request);
|
||||
|
||||
// Then
|
||||
assertThat(results).isNotNull();
|
||||
assertThat(results).as("Should return empty list when query is empty").isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFetchMetadata_parsesBook() throws Exception {
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("A Clockwork Orange")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.title("A Clockwork Orange")
|
||||
.author("Anthony Burgess")
|
||||
.build();
|
||||
|
||||
// Two expected URLs
|
||||
mockHttpClientResponse("https://openlibrary.org/search.json", 200, readFixture("example-search.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/works/OL261794W.json", 200, readFixture("example-work.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/books/OL27284158M.json", 200, readFixture("example-edition.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/authors/OL142238A.json", 200, readFixture("example-author.json"));
|
||||
|
||||
// When
|
||||
List<BookMetadata> results = parser.fetchMetadata(book, request);
|
||||
|
||||
// Then
|
||||
assertThat(results).isNotNull();
|
||||
assertThat(results).as("Should return results for real book").isNotEmpty();
|
||||
|
||||
BookMetadata result = results.getFirst();
|
||||
assertThat(result.getTitle()).isEqualTo("A Clockwork Orange");
|
||||
assertThat(result.getIsbn10()).isEqualTo("1856132668");
|
||||
assertThat(result.getIsbn13()).isEqualTo("9781856132664");
|
||||
assertThat(result.getGoodreadsId()).isEqualTo("59769676");
|
||||
assertThat(result.getAuthors()).isNotNull();
|
||||
assertThat(result.getAuthors()).hasSize(1);
|
||||
assertThat(result.getAuthors().getFirst()).isEqualTo("Anthony Burgess");
|
||||
|
||||
// The description is very long, but we need to make sure we're in the right ballpark.
|
||||
assertThat(result.getDescription()).startsWith("A Clockwork Orange is a dystopian satirical black comedy novel");
|
||||
assertThat(result.getDescription()).hasSize(1307);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFetchMetadata_parsesBookWithComplexDescriptionAndSeries() throws Exception {
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.title("Lord of the Rings")
|
||||
.build();
|
||||
|
||||
// Two expected URLs
|
||||
mockHttpClientResponse("https://openlibrary.org/search.json", 200, readFixture("lotr-search.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/works/OL27448W.json", 200, readFixture("lotr-work.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/series/OL330052L.json", 200, readFixture("lotr-series.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/books/OL51711484M.json", 200, readFixture("lotr-edition.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/authors/OL26320A.json", 200, readFixture("lotr-author.json"));
|
||||
|
||||
// When
|
||||
List<BookMetadata> results = parser.fetchMetadata(book, request);
|
||||
|
||||
// Then
|
||||
assertThat(results).isNotNull();
|
||||
assertThat(results).as("Should return results for real book").isNotEmpty();
|
||||
|
||||
BookMetadata result = results.getFirst();
|
||||
assertThat(result.getTitle()).isEqualTo("The Lord of the Rings");
|
||||
assertThat(result.getIsbn10()).isEqualTo("0618343997");
|
||||
assertThat(result.getIsbn13()).isNull();
|
||||
assertThat(result.getGoodreadsId()).isNull();
|
||||
assertThat(result.getAuthors()).isNotNull();
|
||||
assertThat(result.getAuthors()).hasSize(1);
|
||||
assertThat(result.getAuthors().getFirst()).isEqualTo("J.R.R. Tolkien");
|
||||
|
||||
assertThat(result.getSeriesName()).isEqualTo("The Lord of the Rings");
|
||||
assertThat(result.getSeriesNumber()).isEqualTo(1);
|
||||
assertThat(result.getSeriesTotal()).isEqualTo(3);
|
||||
|
||||
// The description is very long, but we need to make sure we're in the right ballpark.
|
||||
assertThat(result.getDescription()).startsWith("Originally published from 1954 through 1956");
|
||||
assertThat(result.getDescription()).hasSize(2137);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFetchMetadata_appliesRateLimit() throws Exception {
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.title("Lord of the Rings")
|
||||
.build();
|
||||
|
||||
// Two expected URLs
|
||||
mockHttpClientResponse("https://openlibrary.org/search.json", 200, readFixture("lotr-search.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/works/OL27448W.json", 200, readFixture("lotr-work.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/series/OL330052L.json", 200, readFixture("lotr-series.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/books/OL51711484M.json", 200, readFixture("lotr-edition.json"));
|
||||
mockHttpClientResponse("https://openlibrary.org/authors/OL26320A.json", 200, readFixture("lotr-author.json"));
|
||||
|
||||
for (int i = 0; i < 160; i++) {
|
||||
parser.fetchMetadata(book, request);
|
||||
}
|
||||
|
||||
verify(sleepService, times(4)).sleep(anyLong());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"source_records": ["amazon:0671625276", "bwb:9780486820729", "bwb:9780099778806", "bwb:9780099442592", "promise:bwb_daily_pallets_2022-07-11", "promise:bwb_daily_pallets_2022-08-30", "promise:bwb_daily_pallets_2022-10-14:KR-427-373", "promise:bwb_daily_pallets_2021-03-30", "promise:bwb_daily_pallets_2020-11-26", "promise:bwb_daily_pallets_2020-11-13", "amazon:8476698127", "amazon:8389640724", "promise:bwb_daily_pallets_2023-05-16:W3-CPM-838", "promise:bwb_daily_pallets_2023-05-22:692-ABA-806"], "bio": "John Anthony Burgess Wilson, who published under the name Anthony Burgess, was an English writer and composer.\r\n\r\nAlthough Burgess was primarily a comic writer, his dystopian satire *A Clockwork Orange* remains his best-known novel. In 1971, it was adapted into a controversial film by Stanley Kubrick, which Burgess said was chiefly responsible for the popularity of the book. Burgess produced numerous other novels, including the Enderby quartet, and Earthly Powers. He wrote librettos and screenplays, including the 1977 television mini-series Jesus of Nazareth. He worked as a literary critic for several publications, including The Observer and The Guardian, and wrote studies of classic writers, notably James Joyce. A versatile linguist, Burgess lectured in phonetics, and translated Cyrano de Bergerac, Oedipus Rex, and the opera Carmen, among others.\r\n\r\nBurgess also composed over 250 musical works; he considered himself as much a composer as an author, although he achieved considerably more success in writing.", "birth_date": "25 February 1917", "photos": [7277111, 14431059, -1], "death_date": "22 November 1993", "personal_name": "Burgess, Anthony", "links": [{"title": "VIAF", "url": "https://viaf.org/viaf/317283205", "type": {"key": "/type/link"}}, {"title": "ISNI", "url": "http://isni.org/isni/0000000456193171", "type": {"key": "/type/link"}}, {"title": "Wikidata", "url": "https://www.wikidata.org/wiki/Q217619", "type": {"key": "/type/link"}}, {"title": "The International Anthony Burgess Foundation", "url": "https://www.anthonyburgess.org/", "type": {"key": "/type/link"}}], "remote_ids": {"viaf": "71388189", "wikidata": "Q217619", "isni": "0000000121385921"}, "type": {"key": "/type/author"}, "alternate_names": ["Burgess, Anthony", "anthony-burgess", "Anthony BURGESS", "John Anthony Burgess Wilson", "ANTHONY BURGESS", "A. Burgess", "Antony Burgess", "Joseph Kell", "John Burgess Wilson", "A. BURGESS", "anthony burgess", "BURGESS,ANTHONY.", "Burgess Anthony", "\u042d\u043d\u0442\u043e\u043d\u0438 \u0411\u0451\u0440\u0434\u0436\u0435\u0441\u0441"], "name": "Anthony Burgess", "key": "/authors/OL142238A", "latest_revision": 17, "revision": 17, "created": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "last_modified": {"type": "/type/datetime", "value": "2025-03-25T01:01:48.526462"}}
|
||||
@@ -0,0 +1 @@
|
||||
{"publishers": ["Penguin Classics"], "identifiers": {"amazon": ["1856132668"], "goodreads": ["59769676"]}, "source_records": ["amazon:1856132668", "promise:bwb_daily_pallets_2021-01-27"], "title": "A Clockwork Orange", "number_of_pages": 141, "covers": [12393415], "physical_format": "paperback", "full_title": "A Clockwork Orange", "publish_date": "2000", "key": "/books/OL27284158M", "authors": [{"key": "/authors/OL1607339A"}], "works": [{"key": "/works/OL261794W"}], "type": {"key": "/type/edition"}, "publish_places": ["London"], "languages": [{"key": "/languages/eng"}], "pagination": "xxiii, 140p.", "copyright_date": "1996", "edition_name": "reprint 1", "description": "Fifteen-year-old Alex doesn't just like ultra-violence - he also enjoys rape, drugs and Beethoven's Ninth. He and his gang rampage through a dystopian future, hunting for terrible thrills. But when Alex finds himself at the mercy of the state and subject to the ministrations of Dr Brodsky, the government psychologist, he discovers that fun is no longer the order of the day ...\r\n\r\nThe basis for one of the most notorious films ever made, A Clockwork Orange is both a virtuoso performance from an electrifying prose stylist and a serious exploration of the morality of free will.\r\n--back cover", "local_id": ["urn:bwbsku:KP-003-259"], "ocaid": "isbn_9781856132664", "isbn_10": ["1856132668"], "isbn_13": ["9781856132664"], "latest_revision": 14, "revision": 14, "created": {"type": "/type/datetime", "value": "2019-08-26T01:59:15.196224"}, "last_modified": {"type": "/type/datetime", "value": "2025-11-15T21:27:51.839463"}}
|
||||
@@ -0,0 +1 @@
|
||||
{"numFound":75,"start":0,"numFoundExact":true,"num_found":75,"documentation_url":"https://openlibrary.org/dev/docs/api/search","q":"title:Clockwork Orange","offset":null,"docs":[{"author_key":["OL142238A"],"key":"/works/OL261794W","editions":{"numFound":110,"start":0,"numFoundExact":true,"docs":[{"key":"/books/OL27284158M"}]}}]}
|
||||
@@ -0,0 +1 @@
|
||||
{"description": "A Clockwork Orange is a dystopian satirical black comedy novel by English writer Anthony Burgess, published in 1962. It is set in a near-future society that has a youth subculture of extreme violence. The teenage protagonist, Alex, narrates his violent exploits and his experiences with state authorities intent on reforming him. The book is partially written in a Russian-influenced argot called \"Nadsat\", which takes its name from the Russian suffix that is equivalent to '-teen' in English. According to Burgess, it was a jeu d'esprit written in just three weeks.\r\n\r\nIn 2005, A Clockwork Orange was included on Time magazine's list of the 100 best English-language novels written since 1923, and it was named by Modern Library and its readers as one of the 100 best English-language novels of the 20th century. The original manuscript of the book has been kept at McMaster University's William Ready Division of Archives and Research Collections in Hamilton, Ontario, Canada since the institution purchased the documents in 1971. It is considered one of the most influential dystopian books.\r\n\r\n----------\t\t\r\nAlso contained in:\t\t\r\n\r\n[A Clockwork Orange and Honey for the Bears](https://openlibrary.org/works/OL23787405W)\r\n[A Clockwork Orange / The Wanting Seed](https://openlibrary.org/works/OL17306508W)", "first_publish_date": "1972", "title": "A Clockwork Orange", "covers": [13151224, 13950735, 13950736, 12338379, 14122257, 14122256, 11943379, 12269033, 14121728], "first_sentence": {"type": "/type/text", "value": "'WHAT'S it going to be then, eh?'"}, "excerpts": [{"excerpt": "\u2018What\u2019s it going to be then, eh?\u2019", "comment": "first sentence", "author": {"key": "/people/seabelis"}}], "key": "/works/OL261794W", "authors": [{"author": {"key": "/authors/OL142238A"}, "type": {"key": "/type/author_role"}}], "dewey_number": ["823.914"], "type": {"key": "/type/work"}, "links": [{"title": "A Clockwork Orange - The International Anthony Burgess Foundation", "url": "https://www.anthonyburgess.org/a-clockwork-orange/", "type": {"key": "/type/link"}}, {"title": "A Clockwork Orange (novel) - Wikipedia", "url": "https://en.wikipedia.org/wiki/A_Clockwork_Orange_(novel)", "type": {"key": "/type/link"}}, {"title": "The 100 best novels: No 82 \u2013 A Clockwork Orange by Anthony Burgess (1962)", "url": "https://www.theguardian.com/books/2015/apr/13/100-best-novels-clockwork-orange-anthony-burgess", "type": {"key": "/type/link"}}, {"title": "The Shock of the New \u2018A Clockwork Orange\u2019 at 50", "url": "https://www.nytimes.com/2012/09/02/books/review/a-clockwork-orange-at-50.html", "type": {"key": "/type/link"}}, {"title": "A Clockwork Orange | Summary, Analysis, & Facts | Britannica.com", "url": "https://www.britannica.com/topic/A-Clockwork-Orange-novel", "type": {"key": "/type/link"}}, {"title": "thegreatestbooks.org/items/20", "url": "https://thegreatestbooks.org/items/20", "type": {"key": "/type/link"}}], "subject_places": ["England", "Korova Milk Bar"], "subject_people": ["Ludwig van Beethoven", "Alex", "George", "Pet", "Dim", "P.R. Deltoid", "Prison Chaplain", "Billyboy", "Prison Governor", "Minister of the Interior", "Dr. Branom", "Dr. Brodsky", "F. Alexander", "Cat Woman", "Stanley Kubrick", "Anthony Burgess (1917-1993)"], "subjects": ["bible", "aversion therapy", "unintended consequences", "Beethoven's Fifth Symphony", "gang rape", "psychiatric hospitals", "maturity", "metanoia", "assault", "joyriding", "rape", "metafiction", "orgasm", "novella", "antisocial personality disorder", "classical music", "black comedy", "argot", "Nadsat", "dystopias", "satire", "literature", "Juvenile delinquents", "Science fiction", "Rehabilitation", "Fiction", "Teenage boys", "Criminals", "S\u00e1tira", "Muchachos adolescentes", "Criticism and interpretation", "Criminales", "English Authors", "Open Library Staff Picks", "Violence", "Slang language", "Gangs", "Ciencia-ficci\u00f3n", "Social conditions", "Ficci\u00f3n", "Behavior modification", "Long Now Manual for Civilization", "Juvenile delinquency", "Brainwashing", "Fiction, satire", "Fiction, dystopian", "Fiction, science fiction, general", "British and irish fiction (fictional works by one author)", "British and irish drama (dramatic works by one author)", "Kubrick, stanley, 1928-1999", "Burgess, anthony, 1917-1993", "Clockwork orange (Motion picture)", "English literature", "Juvenile delinquents in fiction", "Adventure stories", "Roman d'aventures", "D\u00e9linquance juv\u00e9nile", "Romans, nouvelles", "Jeunes d\u00e9linquants", "R\u00e9habilitation", "English Satire"], "latest_revision": 25, "revision": 25, "created": {"type": "/type/datetime", "value": "2009-10-24T07:26:31.097043"}, "last_modified": {"type": "/type/datetime", "value": "2026-01-01T17:25:03.972618"}}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
{"works": [{"key": "/works/OL27448W"}], "title": "The Lord of the Rings", "publishers": ["Houghton Mifflin Company"], "publish_date": "2003", "key": "/books/OL51711484M", "type": {"key": "/type/edition"}, "identifiers": {}, "isbn_10": ["0618343997"], "ocaid": "lordofrings00tolk_5", "classifications": {}, "publish_places": ["Boston"], "copyright_date": "2003", "edition_name": "Movie tie-in edition (1)", "languages": [{"key": "/languages/eng"}], "physical_format": "hardcover", "pagination": "1137p.", "covers": [15131000], "latest_revision": 5, "revision": 5, "created": {"type": "/type/datetime", "value": "2024-05-17T13:51:26.585267"}, "last_modified": {"type": "/type/datetime", "value": "2025-10-10T23:14:39.486304"}}
|
||||
@@ -0,0 +1 @@
|
||||
{"numFound":784,"start":0,"numFoundExact":true,"num_found":784,"documentation_url":"https://openlibrary.org/dev/docs/api/search","q":"title:Lord of the Rings","offset":null,"docs":[{"author_key":["OL26320A"],"key":"/works/OL27448W","editions":{"numFound":207,"start":0,"numFoundExact":true,"docs":[{"key":"/books/OL51711484M"}]}}]}
|
||||
@@ -0,0 +1 @@
|
||||
{"links": {"self": "/series/OL330052L", "seeds": "/series/OL330052L/seeds"}, "name": "The Lord of the Rings", "type": {"key": "/series/OL330052L"}, "description": null, "seed_count": 4, "meta": {"revision": 1, "created": "2026-03-30T18:09:40.112603", "last_modified": "2026-03-30T18:09:40.112603"}}
|
||||
File diff suppressed because one or more lines are too long
+1
@@ -23,6 +23,7 @@ export const LOCK_FIELDS = [
|
||||
'seriesTotalLocked',
|
||||
'isbn13Locked',
|
||||
'isbn10Locked',
|
||||
'openlibraryIdLocked',
|
||||
'asinLocked',
|
||||
'comicvineIdLocked',
|
||||
'goodreadsIdLocked',
|
||||
|
||||
+2
-1
@@ -34,7 +34,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
|
||||
|
||||
lockableFields: string[] = [
|
||||
'titleLocked', 'subtitleLocked', 'publisherLocked', 'publishedDateLocked', 'descriptionLocked',
|
||||
'titleLocked', 'subtitleLocked', 'publisherLocked', 'publishedDateLocked', 'descriptionLocked', 'openlibraryIdLocked',
|
||||
'isbn13Locked', 'isbn10Locked', 'asinLocked', 'pageCountLocked', 'thumbnailLocked', 'languageLocked', 'coverLocked',
|
||||
'seriesNameLocked', 'seriesNumberLocked', 'seriesTotalLocked', 'authorsLocked', 'categoriesLocked', 'moodsLocked', 'tagsLocked',
|
||||
'amazonRatingLocked', 'amazonReviewCountLocked', 'goodreadsRatingLocked', 'goodreadsReviewCountLocked',
|
||||
@@ -51,6 +51,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
descriptionLocked: 'Description',
|
||||
isbn13Locked: 'ISBN-13',
|
||||
isbn10Locked: 'ISBN-10',
|
||||
openlibraryIdLocked: 'OpenLibrary ID',
|
||||
asinLocked: 'ASIN',
|
||||
pageCountLocked: 'Page Count',
|
||||
thumbnailLocked: 'Thumbnail',
|
||||
|
||||
@@ -255,6 +255,7 @@ export interface BookDetailMetadata extends BookMetadataFields {
|
||||
lubimyczytacId?: string;
|
||||
ranobedbId?: string;
|
||||
audibleId?: string;
|
||||
openlibraryId?: string;
|
||||
doubanRating?: number;
|
||||
doubanReviewCount?: number;
|
||||
lubimyczytacRating?: number;
|
||||
@@ -300,6 +301,7 @@ export interface BookDetailMetadata extends BookMetadataFields {
|
||||
lubimyczytacRatingLocked?: boolean;
|
||||
ranobedbIdLocked?: boolean;
|
||||
ranobedbRatingLocked?: boolean;
|
||||
openlibraryIdLocked?: boolean;
|
||||
audibleIdLocked?: boolean;
|
||||
audibleRatingLocked?: boolean;
|
||||
audibleReviewCountLocked?: boolean;
|
||||
|
||||
@@ -167,6 +167,7 @@ export interface BookMetadata {
|
||||
seriesTotal?: number | null;
|
||||
isbn13?: string;
|
||||
isbn10?: string;
|
||||
openlibraryId?: string;
|
||||
asin?: string;
|
||||
goodreadsId?: string;
|
||||
comicvineId?: string;
|
||||
@@ -220,6 +221,7 @@ export interface BookMetadata {
|
||||
seriesTotalLocked?: boolean;
|
||||
isbn13Locked?: boolean;
|
||||
isbn10Locked?: boolean;
|
||||
openlibraryIdLocked?: boolean;
|
||||
asinLocked?: boolean;
|
||||
comicvineIdLocked?: boolean;
|
||||
goodreadsIdLocked?: boolean;
|
||||
@@ -272,6 +274,7 @@ export interface MetadataClearFlags {
|
||||
seriesTotal?: boolean;
|
||||
isbn13?: boolean;
|
||||
isbn10?: boolean;
|
||||
openlibraryId?: boolean;
|
||||
asin?: boolean;
|
||||
goodreadsId?: boolean;
|
||||
comicvineId?: boolean;
|
||||
|
||||
@@ -410,6 +410,7 @@ export class MagicShelfComponent implements OnInit {
|
||||
{label: this.t.translate('magicShelf.metadataFields.applebooksReviewCount'), value: 'applebooksReviewCount'},
|
||||
]},
|
||||
{ label: this.t.translate('magicShelf.metadataFieldGroups.externalIds'), items: [
|
||||
{label: this.t.translate('magicShelf.metadataFields.openlibraryId'), value: 'openlibraryId'},
|
||||
{label: this.t.translate('magicShelf.metadataFields.goodreadsId'), value: 'goodreadsId'},
|
||||
{label: this.t.translate('magicShelf.metadataFields.hardcoverId'), value: 'hardcoverId'},
|
||||
{label: this.t.translate('magicShelf.metadataFields.googleId'), value: 'googleId'},
|
||||
|
||||
@@ -528,6 +528,7 @@ export class BookRuleEvaluatorService {
|
||||
case 'seriesName': return book.metadata?.seriesName;
|
||||
case 'isbn13': return book.metadata?.isbn13;
|
||||
case 'isbn10': return book.metadata?.isbn10;
|
||||
case 'openlibraryId': return book.metadata?.openlibraryId;
|
||||
case 'asin': return book.metadata?.asin;
|
||||
case 'authors': return book.metadata?.authors;
|
||||
case 'categories': return book.metadata?.categories;
|
||||
|
||||
+14
@@ -664,6 +664,20 @@
|
||||
@if (providerSectionExpanded) {
|
||||
<div class="collapsible-content">
|
||||
<div class="field-row metadata-ids-row">
|
||||
@if (isFieldVisible('openlibraryId')) {
|
||||
<div class="field-group metadata-id-field">
|
||||
<label for="openlibraryId">{{ t('openlibraryId') }} @if (isEmbeddable('openlibraryId', book)) { <i class="pi pi-file-export embeddable-indicator" [pTooltip]="t('writtenToFileTooltip')" tooltipPosition="top"></i> }</label>
|
||||
<div class="field-with-lock">
|
||||
<input pSize="small" pInputText id="openlibraryId" formControlName="openlibraryId"/>
|
||||
@if (!book.metadata!['openlibraryIdLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('openlibraryId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['openlibraryIdLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('openlibraryId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
@if (isFieldVisible('asin')) {
|
||||
<div class="field-group metadata-id-field">
|
||||
<label for="asin">{{ t('amazonAsin') }} @if (isEmbeddable('asin', book)) { <i class="pi pi-file-export embeddable-indicator" [pTooltip]="t('writtenToFileTooltip')" tooltipPosition="top"></i> }</label>
|
||||
|
||||
+9
@@ -148,6 +148,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
audiobookMetadataFields = AUDIOBOOK_METADATA_FIELDS;
|
||||
|
||||
providerSpecificFields: MetadataProviderSpecificFields = {
|
||||
openlibraryId: true,
|
||||
asin: true,
|
||||
amazonRating: true,
|
||||
amazonReviewCount: true,
|
||||
@@ -278,6 +279,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
description: new FormControl(""),
|
||||
pageCount: new FormControl(""),
|
||||
language: new FormControl(""),
|
||||
openlibraryId: new FormControl(""),
|
||||
asin: new FormControl(""),
|
||||
amazonRating: new FormControl(""),
|
||||
amazonReviewCount: new FormControl(""),
|
||||
@@ -319,6 +321,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
descriptionLocked: new FormControl(false),
|
||||
pageCountLocked: new FormControl(false),
|
||||
languageLocked: new FormControl(false),
|
||||
openlibraryIdLocked: new FormControl(false),
|
||||
asinLocked: new FormControl(false),
|
||||
amazonRatingLocked: new FormControl(false),
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
@@ -424,6 +427,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
language: metadata.language ?? null,
|
||||
rating: metadata.rating ?? null,
|
||||
reviewCount: metadata.reviewCount ?? null,
|
||||
openlibraryId: metadata.openlibraryId ?? null,
|
||||
asin: metadata.asin ?? null,
|
||||
amazonRating: metadata.amazonRating ?? null,
|
||||
amazonReviewCount: metadata.amazonReviewCount ?? null,
|
||||
@@ -462,6 +466,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
descriptionLocked: metadata.descriptionLocked ?? false,
|
||||
pageCountLocked: metadata.pageCountLocked ?? false,
|
||||
languageLocked: metadata.languageLocked ?? false,
|
||||
openlibraryIdLocked: metadata.openlibraryIdLocked ?? false,
|
||||
asinLocked: metadata.asinLocked ?? false,
|
||||
amazonRatingLocked: metadata.amazonRatingLocked ?? false,
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked ?? false,
|
||||
@@ -535,6 +540,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: "languageLocked", control: "language"},
|
||||
{key: "isbn10Locked", control: "isbn10"},
|
||||
{key: "isbn13Locked", control: "isbn13"},
|
||||
{key: "openlibraryIdLocked", control: "openlibraryId"},
|
||||
{key: "asinLocked", control: "asin"},
|
||||
{key: "amazonReviewCountLocked", control: "amazonReviewCount"},
|
||||
{key: "amazonRatingLocked", control: "amazonRating"},
|
||||
@@ -729,6 +735,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
pageCount: form.get("pageCount")?.value,
|
||||
rating: form.get("rating")?.value,
|
||||
reviewCount: form.get("reviewCount")?.value,
|
||||
openlibraryId: form.get("openlibraryId")?.value,
|
||||
asin: form.get("asin")?.value,
|
||||
amazonRating: form.get("amazonRating")?.value,
|
||||
amazonReviewCount: form.get("amazonReviewCount")?.value,
|
||||
@@ -778,6 +785,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
descriptionLocked: form.get("descriptionLocked")?.value,
|
||||
pageCountLocked: form.get("pageCountLocked")?.value,
|
||||
languageLocked: form.get("languageLocked")?.value,
|
||||
openlibraryIdLocked: form.get("openlibraryIdLocked")?.value,
|
||||
asinLocked: form.get("asinLocked")?.value,
|
||||
amazonRatingLocked: form.get("amazonRatingLocked")?.value,
|
||||
amazonReviewCountLocked: form.get("amazonReviewCountLocked")?.value,
|
||||
@@ -871,6 +879,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
description: wasCleared("description"),
|
||||
pageCount: wasCleared("pageCount"),
|
||||
language: wasCleared("language"),
|
||||
openlibraryId: wasCleared("openlibraryId"),
|
||||
asin: wasCleared("asin"),
|
||||
amazonRating: wasCleared("amazonRating"),
|
||||
amazonReviewCount: wasCleared("amazonReviewCount"),
|
||||
|
||||
+11
-1
@@ -327,6 +327,7 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
|
||||
private getProviderFromMetadata(metadata: BookMetadata): string | null {
|
||||
if (metadata.audibleId) return 'audible';
|
||||
if (metadata.applebooksId) return 'applebooks';
|
||||
if (metadata.openlibraryId) return 'openlibrary';
|
||||
if (metadata.asin) return 'amazon';
|
||||
if (metadata.goodreadsId) return 'goodreads';
|
||||
if (metadata.googleId) return 'google';
|
||||
@@ -443,6 +444,7 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
|
||||
case 'GoodReads': return metadata.goodreadsId;
|
||||
case 'Amazon': return metadata.asin;
|
||||
case 'Audible': return metadata.audibleId;
|
||||
case 'OpenLibrary': return metadata.openlibraryId;
|
||||
default: return undefined;
|
||||
}
|
||||
}
|
||||
@@ -467,6 +469,10 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
|
||||
return metadata.externalUrl;
|
||||
}
|
||||
|
||||
if (metadata.openlibraryId) {
|
||||
return `https://openlibrary.org/${metadata.openlibraryId.replace(/^\//, '')}`
|
||||
}
|
||||
|
||||
if (metadata.audibleId) {
|
||||
// Audible has to come before Amazon because they both have an ASIN.
|
||||
return `https://www.audible.com/pd/${metadata.audibleId}`;
|
||||
@@ -526,6 +532,10 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
|
||||
return metadata.provider;
|
||||
}
|
||||
|
||||
if (metadata.openlibraryId) {
|
||||
return 'OpenLibrary';
|
||||
}
|
||||
|
||||
if (metadata.audibleId) {
|
||||
// Audible has to come before Amazon because they both have an ASIN.
|
||||
return 'Audible';
|
||||
@@ -571,7 +581,7 @@ export class MetadataSearcherComponent implements OnDestroy, OnChanges {
|
||||
}
|
||||
|
||||
trackByMetadata(index: number, metadata: BookMetadata): string {
|
||||
return metadata.googleId || metadata.goodreadsId || metadata.asin ||
|
||||
return metadata.openlibraryId || metadata.googleId || metadata.goodreadsId || metadata.asin ||
|
||||
metadata.hardcoverId || metadata.comicvineId || metadata.audibleId ||
|
||||
metadata.applebooksId || index.toString();
|
||||
}
|
||||
|
||||
+33
-2
@@ -30,6 +30,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'title', 'subtitle', 'description', 'authors', 'publisher', 'publishedDate',
|
||||
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10',
|
||||
'language', 'categories', 'cover', 'pageCount',
|
||||
'openlibraryId',
|
||||
'asin', 'amazonRating', 'amazonReviewCount',
|
||||
'googleId',
|
||||
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
@@ -42,6 +43,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
];
|
||||
|
||||
providerSpecificFields: (keyof FieldOptions)[] = [
|
||||
'openlibraryId',
|
||||
'asin', 'amazonRating', 'amazonReviewCount',
|
||||
'googleId',
|
||||
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
@@ -59,8 +61,33 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'language', 'categories', 'cover', 'pageCount',
|
||||
];
|
||||
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb', 'Audible', 'AppleBooks'];
|
||||
providersWithClear: string[] = ['Clear All', 'Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb', 'Audible', 'AppleBooks'];
|
||||
providers: string[] = [
|
||||
'OpenLibrary',
|
||||
'Amazon',
|
||||
'Google',
|
||||
'GoodReads',
|
||||
'Hardcover',
|
||||
'Comicvine',
|
||||
'Douban',
|
||||
'Lubimyczytac',
|
||||
'Ranobedb',
|
||||
'Audible',
|
||||
'AppleBooks'
|
||||
];
|
||||
providersWithClear: string[] = [
|
||||
'Clear All',
|
||||
'OpenLibrary',
|
||||
'Amazon',
|
||||
'Google',
|
||||
'GoodReads',
|
||||
'Hardcover',
|
||||
'Comicvine',
|
||||
'Douban',
|
||||
'Lubimyczytac',
|
||||
'Ranobedb',
|
||||
'Audible',
|
||||
'AppleBooks'
|
||||
];
|
||||
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
@@ -89,6 +116,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
private justSubmitted = false;
|
||||
|
||||
private providerSpecificFieldsList = [
|
||||
// OpenLibrary
|
||||
'openlibraryId',
|
||||
|
||||
// Amazon
|
||||
'asin', 'amazonRating', 'amazonReviewCount',
|
||||
|
||||
@@ -273,6 +303,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'pageCount': 'Page Count',
|
||||
'rating': 'Rating',
|
||||
'reviewCount': 'Review Count',
|
||||
'openlibraryId': 'OpenLibrary ID',
|
||||
'asin': 'Amazon ASIN',
|
||||
'goodreadsId': 'Goodreads ID',
|
||||
'comicvineId': 'Comicvine ID',
|
||||
|
||||
+2
@@ -19,6 +19,7 @@ export class MetadataProviderFieldSelectorComponent {
|
||||
private t = inject(TranslocoService);
|
||||
|
||||
providerGroups: { labelKey: string, fields: string[] }[] = [
|
||||
{labelKey: 'openlibrary', fields: ['openlibraryId']},
|
||||
{labelKey: 'amazon', fields: ['asin', 'amazonRating', 'amazonReviewCount']},
|
||||
{labelKey: 'googleBooks', fields: ['googleId']},
|
||||
{labelKey: 'goodreads', fields: ['goodreadsId', 'goodreadsRating', 'goodreadsReviewCount']},
|
||||
@@ -39,6 +40,7 @@ export class MetadataProviderFieldSelectorComponent {
|
||||
}
|
||||
|
||||
private readonly allFieldNames: (keyof MetadataProviderSpecificFields)[] = [
|
||||
'openlibraryId',
|
||||
'asin', 'amazonRating', 'amazonReviewCount',
|
||||
'googleId',
|
||||
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
|
||||
+2
@@ -17,6 +17,7 @@ const provider = (value: string | null): FieldProvider => ({
|
||||
describe('metadata-refresh-options.model', () => {
|
||||
it('supports replace-mode driven refresh settings', () => {
|
||||
const fieldOptions: FieldOptions = {
|
||||
openlibraryId: provider('openlibrary'),
|
||||
title: provider('google'),
|
||||
description: provider('google'),
|
||||
authors: provider('google'),
|
||||
@@ -81,6 +82,7 @@ describe('metadata-refresh-options.model', () => {
|
||||
isbn10: true,
|
||||
language: true,
|
||||
pageCount: true,
|
||||
openlibraryId: true,
|
||||
asin: true,
|
||||
goodreadsId: true,
|
||||
comicvineId: false,
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface FieldOptions {
|
||||
isbn10: FieldProvider;
|
||||
language: FieldProvider;
|
||||
pageCount: FieldProvider;
|
||||
openlibraryId: FieldProvider;
|
||||
asin: FieldProvider;
|
||||
goodreadsId: FieldProvider;
|
||||
comicvineId: FieldProvider;
|
||||
|
||||
@@ -24,6 +24,7 @@ export interface SidecarIdentifiers {
|
||||
ranobedbId?: string;
|
||||
audibleId?: string;
|
||||
applebooksId?: string;
|
||||
openlibraryId?: string;
|
||||
}
|
||||
|
||||
export interface SidecarRating {
|
||||
|
||||
+7
@@ -194,6 +194,13 @@
|
||||
<h4 class="provider-group-title">{{ t('readyToUseTitle') }}</h4>
|
||||
|
||||
<div class="simple-providers-grid">
|
||||
<div class="setting-item simple-provider">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="openLibraryEnabled"></p-toggleswitch>
|
||||
<span class="setting-label">OpenLibrary</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-item simple-provider">
|
||||
<div class="setting-header">
|
||||
<p-toggleswitch [(ngModel)]="goodreadsEnabled"></p-toggleswitch>
|
||||
|
||||
+5
@@ -103,6 +103,7 @@ export class MetadataProviderSettingsComponent {
|
||||
amazonCookie: string = '';
|
||||
hardcoverEnabled: boolean = false;
|
||||
amazonEnabled: boolean = false;
|
||||
openLibraryEnabled: boolean = false;
|
||||
goodreadsEnabled: boolean = false;
|
||||
googleEnabled: boolean = false;
|
||||
comicvineEnabled: boolean = false;
|
||||
@@ -128,6 +129,7 @@ export class MetadataProviderSettingsComponent {
|
||||
|
||||
private applySettings(settings: NonNullable<ReturnType<typeof this.appSettingsService.appSettings>>): void {
|
||||
const metadataProviderSettings = settings.metadataProviderSettings;
|
||||
this.openLibraryEnabled = metadataProviderSettings?.openLibrary?.enabled ?? false;
|
||||
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
|
||||
this.amazonCookie = metadataProviderSettings?.amazon?.cookie ?? "";
|
||||
this.selectedAmazonDomain = metadataProviderSettings?.amazon?.domain ?? 'com';
|
||||
@@ -169,6 +171,9 @@ export class MetadataProviderSettingsComponent {
|
||||
{
|
||||
key: AppSettingKey.METADATA_PROVIDER_SETTINGS,
|
||||
newValue: {
|
||||
openLibrary: {
|
||||
enabled: this.openLibraryEnabled,
|
||||
},
|
||||
amazon: {
|
||||
enabled: this.amazonEnabled,
|
||||
cookie: this.amazonCookie,
|
||||
|
||||
+1
@@ -221,6 +221,7 @@ export class LibraryMetadataSettingsComponent {
|
||||
categories: {p1: null, p2: null, p3: null, p4: null},
|
||||
cover: {p1: null, p2: null, p3: null, p4: null},
|
||||
pageCount: {p1: null, p2: null, p3: null, p4: null},
|
||||
openlibraryId: {p1: null, p2: null, p3: null, p4: null},
|
||||
asin: {p1: null, p2: null, p3: null, p4: null},
|
||||
goodreadsId: {p1: null, p2: null, p3: null, p4: null},
|
||||
comicvineId: {p1: null, p2: null, p3: null, p4: null},
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ function buildMetadataRefreshOptions(): MetadataRefreshOptions {
|
||||
const FIELDS = [
|
||||
'title', 'subtitle', 'description', 'authors', 'publisher', 'publishedDate',
|
||||
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10', 'language',
|
||||
'pageCount', 'categories', 'cover', 'asin', 'goodreadsId', 'comicvineId',
|
||||
'pageCount', 'categories', 'cover', 'asin', 'goodreadsId', 'comicvineId', 'openlibraryId',
|
||||
'hardcoverId', 'hardcoverBookId', 'googleId', 'lubimyczytacId',
|
||||
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating',
|
||||
|
||||
@@ -5,7 +5,7 @@ const EBOOK_EMBEDDABLE: ReadonlySet<string> = new Set([
|
||||
'title', 'subtitle', 'authors', 'publisher', 'publishedDate', 'language',
|
||||
'categories', 'description', 'seriesName', 'seriesNumber', 'seriesTotal',
|
||||
'isbn10', 'isbn13', 'moods', 'tags', 'ageRating', 'contentRating', 'pageCount',
|
||||
'asin', 'amazonRating', 'amazonReviewCount', 'googleId',
|
||||
'openlibraryId', 'asin', 'amazonRating', 'amazonReviewCount', 'googleId',
|
||||
'applebooksId', 'applebooksRating', 'applebooksReviewCount',
|
||||
'goodreadsId', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
'hardcoverId', 'hardcoverBookId', 'hardcoverRating', 'hardcoverReviewCount',
|
||||
|
||||
@@ -41,6 +41,7 @@ describe('metadata-field.config', () => {
|
||||
|
||||
it('filters provider-backed fields when provider flags are supplied', () => {
|
||||
const enabledFields = {
|
||||
openlibraryId: false,
|
||||
googleId: true,
|
||||
asin: false,
|
||||
amazonRating: false,
|
||||
|
||||
@@ -28,6 +28,7 @@ export const ALL_METADATA_FIELDS: MetadataFieldConfig[] = [
|
||||
{ label: 'ISBN-10', controlName: 'isbn10', lockedKey: 'isbn10Locked', fetchedKey: 'isbn10', type: 'string' },
|
||||
{ label: 'ISBN-13', controlName: 'isbn13', lockedKey: 'isbn13Locked', fetchedKey: 'isbn13', type: 'string' },
|
||||
{ label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount', type: 'number' },
|
||||
{ label: 'OpenLibrary ID', controlName: 'openlibraryId', lockedKey: 'openlibraryIdLocked', fetchedKey: 'openlibraryId', type: 'string', providerKey: 'openlibraryId' },
|
||||
{ label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleId', type: 'string', providerKey: 'googleId' },
|
||||
{ label: 'ASIN', controlName: 'asin', lockedKey: 'asinLocked', fetchedKey: 'asin', type: 'string', providerKey: 'asin' },
|
||||
{ label: 'Amazon #', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount', type: 'number', providerKey: 'amazonReviewCount' },
|
||||
|
||||
@@ -51,6 +51,7 @@ export interface OidcAutoProvisionDetails {
|
||||
}
|
||||
|
||||
export interface MetadataProviderSettings {
|
||||
openLibrary: OpenLibrary;
|
||||
amazon: Amazon;
|
||||
google: Google;
|
||||
goodReads: Goodreads;
|
||||
@@ -63,6 +64,10 @@ export interface MetadataProviderSettings {
|
||||
appleBooks: AppleBooks;
|
||||
}
|
||||
|
||||
export interface OpenLibrary {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface Amazon {
|
||||
enabled: boolean;
|
||||
cookie: string;
|
||||
@@ -209,6 +214,7 @@ export interface AppSettings {
|
||||
}
|
||||
|
||||
export interface MetadataProviderSpecificFields {
|
||||
openlibraryId: boolean;
|
||||
asin: boolean;
|
||||
amazonRating: boolean;
|
||||
amazonReviewCount: boolean;
|
||||
|
||||
@@ -768,6 +768,7 @@
|
||||
"sectionTitle": "Enabled Fields in Metadata Editor & Picker",
|
||||
"sectionDesc": "Select which metadata fields to display when editing book information or picking metadata from providers. Disabled fields will be hidden from the interface.",
|
||||
"providers": {
|
||||
"openlibrary": "OpenLibrary",
|
||||
"amazon": "Amazon",
|
||||
"googleBooks": "Google Books",
|
||||
"goodreads": "Goodreads",
|
||||
@@ -779,6 +780,7 @@
|
||||
"ranobedb": "Ranobedb"
|
||||
},
|
||||
"fields": {
|
||||
"openlibraryId": "OpenLibrary ID",
|
||||
"asin": "Amazon ASIN",
|
||||
"amazonRating": "Amazon Rating",
|
||||
"amazonReviewCount": "Amazon Review Count",
|
||||
@@ -2253,6 +2255,7 @@
|
||||
"audiobookDetails": "Audiobook Details",
|
||||
"comicBookDetails": "Comic Book Details",
|
||||
"providerMetadata": "Provider Metadata",
|
||||
"openlibraryId": "OpenLibrary ID",
|
||||
"amazonAsin": "Amazon ASIN",
|
||||
"amazonRating": "Amazon ★",
|
||||
"amazonReviewCount": "Amazon #",
|
||||
@@ -5222,6 +5225,7 @@
|
||||
"hardcoverReviewCount": "Hardcover Reviews",
|
||||
"audibleReviewCount": "Audible Reviews",
|
||||
"applebooksReviewCount": "Apple Books Review Count",
|
||||
"openlibraryId": "OpenLibrary ID",
|
||||
"goodreadsId": "Goodreads ID",
|
||||
"hardcoverId": "Hardcover ID",
|
||||
"googleId": "Google ID",
|
||||
|
||||
Reference in New Issue
Block a user