RanobeDB Light Novel metadata provider (#2221)
* feat(metadata): added ranobedb metadata provider for light novels * fix(metadata): remove ranobedb review count and fix merge conflicts * test(metadata): added unit tests for RanobeDB parser * fix(metadata): add ranobedb to updated metadata searcher --------- Co-authored-by: ACX <8075870+acx10@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,7 @@ public class BookParserConfig {
|
||||
|
||||
@Bean
|
||||
public Map<MetadataProvider, BookParser> parserMap(GoogleParser googleParser, AmazonBookParser amazonBookParser,
|
||||
GoodReadsParser goodReadsParser, HardcoverParser hardcoverParser, ComicvineBookParser comicvineBookParser, DoubanBookParser doubanBookParser, LubimyCzytacParser lubimyczytacParser) {
|
||||
GoodReadsParser goodReadsParser, HardcoverParser hardcoverParser, ComicvineBookParser comicvineBookParser, DoubanBookParser doubanBookParser, RanobeDbParser ranobedbParser, LubimyCzytacParser lubimyczytacParser) {
|
||||
return Map.of(
|
||||
MetadataProvider.Amazon, amazonBookParser,
|
||||
MetadataProvider.GoodReads, goodReadsParser,
|
||||
@@ -20,7 +20,8 @@ public class BookParserConfig {
|
||||
MetadataProvider.Hardcover, hardcoverParser,
|
||||
MetadataProvider.Comicvine, comicvineBookParser,
|
||||
MetadataProvider.Douban, doubanBookParser,
|
||||
MetadataProvider.Lubimyczytac, lubimyczytacParser
|
||||
MetadataProvider.Lubimyczytac, lubimyczytacParser,
|
||||
MetadataProvider.Ranobedb, ranobedbParser
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ public class MetadataClearFlags {
|
||||
private boolean hardcoverReviewCount;
|
||||
private boolean lubimyczytacId;
|
||||
private boolean lubimyczytacRating;
|
||||
private boolean ranobedbId;
|
||||
private boolean ranobedbRating;
|
||||
private boolean authors;
|
||||
private boolean categories;
|
||||
private boolean moods;
|
||||
|
||||
@@ -46,6 +46,8 @@ public class BookMetadata {
|
||||
private Double lubimyczytacRating;
|
||||
private String googleId;
|
||||
private String lubimyczytacId;
|
||||
private String ranobedbId;
|
||||
private Double ranobedbRating;
|
||||
private String externalUrl;
|
||||
private Instant coverUpdatedOn;
|
||||
private Set<String> authors;
|
||||
@@ -85,6 +87,8 @@ public class BookMetadata {
|
||||
private Boolean doubanReviewCountLocked;
|
||||
private Boolean lubimyczytacIdLocked;
|
||||
private Boolean lubimyczytacRatingLocked;
|
||||
private Boolean ranobedbIdLocked;
|
||||
private Boolean ranobedbRatingLocked;
|
||||
private Boolean externalUrlLocked;
|
||||
private Boolean coverLocked;
|
||||
private Boolean authorsLocked;
|
||||
@@ -92,4 +96,4 @@ public class BookMetadata {
|
||||
private Boolean moodsLocked;
|
||||
private Boolean tagsLocked;
|
||||
private Boolean reviewsLocked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,8 @@ public class EpubMetadata {
|
||||
private Double hardcoverRating;
|
||||
private Integer hardcoverReviewCount;
|
||||
private String googleId;
|
||||
private String ranobedbId;
|
||||
private Double ranobedbRating;
|
||||
private Set<String> authors;
|
||||
private Set<String> categories;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@ public enum RuleField {
|
||||
HARDCOVER_RATING,
|
||||
@JsonProperty("hardcoverReviewCount")
|
||||
HARDCOVER_REVIEW_COUNT,
|
||||
@JsonProperty("ranobedbRating")
|
||||
RANOBEDB_RATING,
|
||||
@JsonProperty("personalRating")
|
||||
PERSONAL_RATING,
|
||||
@JsonProperty("fileType")
|
||||
|
||||
+4
@@ -59,6 +59,8 @@ public class MetadataRefreshOptions {
|
||||
private FieldProvider hardcoverRating;
|
||||
private FieldProvider hardcoverReviewCount;
|
||||
private FieldProvider lubimyczytacRating;
|
||||
private FieldProvider ranobedbId;
|
||||
private FieldProvider ranobedbRating;
|
||||
private FieldProvider moods;
|
||||
private FieldProvider tags;
|
||||
}
|
||||
@@ -109,6 +111,8 @@ public class MetadataRefreshOptions {
|
||||
private boolean hardcoverRating;
|
||||
private boolean hardcoverReviewCount;
|
||||
private boolean lubimyczytacRating;
|
||||
private boolean ranobedbId;
|
||||
private boolean ranobedbRating;
|
||||
private boolean moods;
|
||||
private boolean tags;
|
||||
}
|
||||
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
package com.adityachandel.booklore.model.dto.response.ranobedbapi;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class RanobedbBookResponse {
|
||||
private Book book;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Book {
|
||||
private String description;
|
||||
private String lang;
|
||||
private Long id;
|
||||
private String romaji;
|
||||
|
||||
@JsonProperty("description_ja")
|
||||
private String descriptionJa;
|
||||
|
||||
private Boolean hidden;
|
||||
|
||||
@JsonProperty("image_id")
|
||||
private Long imageId;
|
||||
|
||||
private String olang;
|
||||
private Boolean locked;
|
||||
|
||||
@JsonProperty("c_release_date")
|
||||
private Long cReleaseDate;
|
||||
|
||||
private String title;
|
||||
|
||||
@JsonProperty("title_orig")
|
||||
private String titleOrig;
|
||||
|
||||
@JsonProperty("romaji_orig")
|
||||
private String romajiOrig;
|
||||
|
||||
private Image image;
|
||||
private Rating rating;
|
||||
private List<TitleEntry> titles;
|
||||
private List<Edition> editions;
|
||||
private List<Release> releases;
|
||||
private List<Publisher> publishers;
|
||||
private Series series;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Rating {
|
||||
private Double score;
|
||||
private Integer count;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Image {
|
||||
private Long id;
|
||||
private String filename;
|
||||
private Integer height;
|
||||
private Boolean nsfw;
|
||||
private Boolean spoiler;
|
||||
private Integer width;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class TitleEntry {
|
||||
private String lang;
|
||||
private String romaji;
|
||||
@JsonProperty("book_id")
|
||||
private Long bookId;
|
||||
private Boolean official;
|
||||
private String title;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Edition {
|
||||
@JsonProperty("book_id")
|
||||
private Long bookId;
|
||||
private String lang;
|
||||
private String title;
|
||||
private Long eid;
|
||||
private List<Staff> staff;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Staff {
|
||||
private String note;
|
||||
@JsonProperty("role_type")
|
||||
private RoleType roleType;
|
||||
private String romaji;
|
||||
private String name;
|
||||
@JsonProperty("staff_id")
|
||||
private Long staffId;
|
||||
@JsonProperty("staff_alias_id")
|
||||
private Long staffAliasId;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Release {
|
||||
private String lang;
|
||||
private Long id;
|
||||
private String romaji;
|
||||
private String description;
|
||||
private Boolean hidden;
|
||||
private Boolean locked;
|
||||
@JsonProperty("release_date")
|
||||
private Long releaseDate;
|
||||
private String title;
|
||||
private String website;
|
||||
private String amazon;
|
||||
private String bookwalker;
|
||||
private Format format;
|
||||
private String isbn13;
|
||||
private Integer pages;
|
||||
private String rakuten;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Publisher {
|
||||
private String lang;
|
||||
private Long id;
|
||||
private String romaji;
|
||||
private String name;
|
||||
@JsonProperty("publisher_type")
|
||||
private PublisherType publisherType;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Series {
|
||||
private List<SeriesBook> books;
|
||||
private List<Tag> tags;
|
||||
private String lang;
|
||||
private Long id;
|
||||
private String romaji;
|
||||
private String title;
|
||||
@JsonProperty("title_orig")
|
||||
private String titleOrig;
|
||||
@JsonProperty("romaji_orig")
|
||||
private String romajiOrig;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class SeriesBook {
|
||||
private Long id;
|
||||
private String lang;
|
||||
private String romaji;
|
||||
private String title;
|
||||
@JsonProperty("title_orig")
|
||||
private String titleOrig;
|
||||
@JsonProperty("romaji_orig")
|
||||
private String romajiOrig;
|
||||
private Image image;
|
||||
}
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Tag {
|
||||
private Long id;
|
||||
private String name;
|
||||
private TagType ttype;
|
||||
}
|
||||
|
||||
// --- Enums for strict typing ---
|
||||
|
||||
public enum RoleType {
|
||||
@JsonProperty("editor") EDITOR,
|
||||
@JsonProperty("staff") STAFF,
|
||||
@JsonProperty("author") AUTHOR,
|
||||
@JsonProperty("artist") ARTIST,
|
||||
@JsonProperty("translator") TRANSLATOR,
|
||||
@JsonProperty("narrator") NARRATOR
|
||||
}
|
||||
|
||||
public enum Format {
|
||||
@JsonProperty("digital") DIGITAL,
|
||||
@JsonProperty("print") PRINT,
|
||||
@JsonProperty("audio") AUDIO
|
||||
}
|
||||
|
||||
public enum PublisherType {
|
||||
@JsonProperty("publisher") PUBLISHER,
|
||||
@JsonProperty("imprint") IMPRINT
|
||||
}
|
||||
|
||||
public enum TagType {
|
||||
@JsonProperty("tag") TAG,
|
||||
@JsonProperty("content") CONTENT,
|
||||
@JsonProperty("demographic") DEMOGRAPHIC,
|
||||
@JsonProperty("genre") GENRE
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.adityachandel.booklore.model.dto.response.ranobedbapi;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class RanobedbSearchResponse{
|
||||
private List<Book> books;
|
||||
private String count;
|
||||
private int currentPage;
|
||||
private int totalPages;
|
||||
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class Book {
|
||||
private int id;
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -33,6 +33,7 @@ public class MetadataMatchWeights {
|
||||
private int hardcoverReviewCount;
|
||||
private int doubanRating;
|
||||
private int doubanReviewCount;
|
||||
private int ranobedbRating;
|
||||
private int coverImage;
|
||||
|
||||
public int totalWeight() {
|
||||
@@ -40,6 +41,7 @@ public class MetadataMatchWeights {
|
||||
seriesName + seriesNumber + seriesTotal + isbn13 + isbn10 + language +
|
||||
pageCount + categories + amazonRating + amazonReviewCount +
|
||||
goodreadsRating + goodreadsReviewCount + hardcoverRating +
|
||||
hardcoverReviewCount + doubanRating + doubanReviewCount + coverImage;
|
||||
hardcoverReviewCount + doubanRating + doubanReviewCount +
|
||||
ranobedbRating + coverImage;
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -10,6 +10,7 @@ public class MetadataProviderSettings {
|
||||
private Goodreads goodReads;
|
||||
private Hardcover hardcover;
|
||||
private Comicvine comicvine;
|
||||
private Ranobedb ranobedb;
|
||||
private Douban douban;
|
||||
@JsonProperty("lubimyczytac")
|
||||
private Lubimyczytac lubimyczytac;
|
||||
@@ -44,6 +45,11 @@ public class MetadataProviderSettings {
|
||||
private String apiKey;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Ranobedb {
|
||||
private boolean enabled;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Douban {
|
||||
private boolean enabled;
|
||||
|
||||
+19
-1
@@ -112,6 +112,12 @@ public class BookMetadataEntity {
|
||||
@Column(name = "lubimyczytac_rating")
|
||||
private Double lubimyczytacRating;
|
||||
|
||||
@Column(name = "ranobedb_id", length = 100)
|
||||
private String ranobedbId;
|
||||
|
||||
@Column(name = "ranobedb_rating")
|
||||
private Double ranobedbRating;
|
||||
|
||||
@Column(name = "title_locked")
|
||||
@Builder.Default
|
||||
private Boolean titleLocked = Boolean.FALSE;
|
||||
@@ -236,6 +242,14 @@ public class BookMetadataEntity {
|
||||
@Builder.Default
|
||||
private Boolean lubimyczytacRatingLocked = Boolean.FALSE;
|
||||
|
||||
@Column(name = "ranobedb_id_locked")
|
||||
@Builder.Default
|
||||
private Boolean ranobedbIdLocked = Boolean.FALSE;
|
||||
|
||||
@Column(name = "ranobedb_rating_locked")
|
||||
@Builder.Default
|
||||
private Boolean ranobedbRatingLocked = Boolean.FALSE;
|
||||
|
||||
@Column(name = "reviews_locked")
|
||||
@Builder.Default
|
||||
private Boolean reviewsLocked = Boolean.FALSE;
|
||||
@@ -333,6 +347,8 @@ public class BookMetadataEntity {
|
||||
this.hardcoverBookIdLocked = lock;
|
||||
this.googleIdLocked = lock;
|
||||
this.lubimyczytacIdLocked = lock;
|
||||
this.ranobedbIdLocked = lock;
|
||||
this.ranobedbRatingLocked = lock;
|
||||
this.reviewsLocked = lock;
|
||||
}
|
||||
|
||||
@@ -368,7 +384,9 @@ public class BookMetadataEntity {
|
||||
&& Boolean.TRUE.equals(this.hardcoverBookIdLocked)
|
||||
&& Boolean.TRUE.equals(this.googleIdLocked)
|
||||
&& Boolean.TRUE.equals(this.lubimyczytacIdLocked)
|
||||
&& Boolean.TRUE.equals(this.ranobedbIdLocked)
|
||||
&& Boolean.TRUE.equals(this.ranobedbRatingLocked)
|
||||
&& Boolean.TRUE.equals(this.reviewsLocked)
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
package com.adityachandel.booklore.model.enums;
|
||||
|
||||
public enum MetadataProvider {
|
||||
Amazon, GoodReads, Google, Hardcover, Comicvine, Douban, Lubimyczytac
|
||||
Amazon, GoodReads, Google, Hardcover, Comicvine, Douban, Lubimyczytac, Ranobedb
|
||||
}
|
||||
|
||||
+1
@@ -332,6 +332,7 @@ public class BookRuleEvaluatorService {
|
||||
case GOODREADS_REVIEW_COUNT -> root.get("metadata").get("goodreadsReviewCount");
|
||||
case HARDCOVER_RATING -> root.get("metadata").get("hardcoverRating");
|
||||
case HARDCOVER_REVIEW_COUNT -> root.get("metadata").get("hardcoverReviewCount");
|
||||
case RANOBEDB_RATING -> root.get("metadata").get("ranobedbRating");
|
||||
case FILE_TYPE -> cb.function("SUBSTRING_INDEX", String.class,
|
||||
root.get("fileName"), cb.literal("."), cb.literal(-1));
|
||||
default -> null;
|
||||
|
||||
@@ -162,6 +162,8 @@ public class TelemetryService {
|
||||
enabled.add(MetadataProvider.Hardcover.name());
|
||||
if (providers.getComicvine() != null && providers.getComicvine().isEnabled())
|
||||
enabled.add(MetadataProvider.Comicvine.name());
|
||||
if (providers.getRanobedb() != null && providers.getRanobedb().isEnabled())
|
||||
enabled.add(MetadataProvider.Ranobedb.name());
|
||||
if (providers.getDouban() != null && providers.getDouban().isEnabled())
|
||||
enabled.add(MetadataProvider.Douban.name());
|
||||
if (providers.getLubimyczytac() != null && providers.getLubimyczytac().isEnabled())
|
||||
|
||||
+9
@@ -102,11 +102,15 @@ public class SettingPersistenceHelper {
|
||||
MetadataProviderSettings.Douban defaultDouban = new MetadataProviderSettings.Douban();
|
||||
defaultDouban.setEnabled(false);
|
||||
|
||||
MetadataProviderSettings.Ranobedb defaultRanobedb = new MetadataProviderSettings.Ranobedb();
|
||||
defaultRanobedb.setEnabled(false);
|
||||
|
||||
defaultMetadataProviderSettings.setAmazon(defaultAmazon);
|
||||
defaultMetadataProviderSettings.setGoogle(defaultGoogle);
|
||||
defaultMetadataProviderSettings.setGoodReads(defaultGoodreads);
|
||||
defaultMetadataProviderSettings.setHardcover(defaultHardcover);
|
||||
defaultMetadataProviderSettings.setComicvine(defaultComicvine);
|
||||
defaultMetadataProviderSettings.setRanobedb(defaultRanobedb);
|
||||
defaultMetadataProviderSettings.setDouban(defaultDouban);
|
||||
|
||||
return defaultMetadataProviderSettings;
|
||||
@@ -147,6 +151,8 @@ public class SettingPersistenceHelper {
|
||||
.goodreadsReviewCount(nullProvider)
|
||||
.hardcoverRating(nullProvider)
|
||||
.hardcoverReviewCount(nullProvider)
|
||||
.ranobedbId(nullProvider)
|
||||
.ranobedbRating(nullProvider)
|
||||
.moods(nullProvider)
|
||||
.tags(nullProvider)
|
||||
.build();
|
||||
@@ -178,6 +184,8 @@ public class SettingPersistenceHelper {
|
||||
.goodreadsReviewCount(true)
|
||||
.hardcoverRating(true)
|
||||
.hardcoverReviewCount(true)
|
||||
.ranobedbId(false)
|
||||
.ranobedbRating(false)
|
||||
.moods(true)
|
||||
.tags(true)
|
||||
.build();
|
||||
@@ -216,6 +224,7 @@ public class SettingPersistenceHelper {
|
||||
.hardcoverReviewCount(1)
|
||||
.doubanRating(3)
|
||||
.doubanReviewCount(2)
|
||||
.ranobedbRating(2)
|
||||
.coverImage(5)
|
||||
.build();
|
||||
}
|
||||
|
||||
+3
-1
@@ -123,6 +123,8 @@ public class EpubProcessor extends AbstractFileProcessor implements BookFileProc
|
||||
metadata.setHardcoverReviewCount(epubMetadata.getHardcoverReviewCount());
|
||||
metadata.setGoogleId(truncate(epubMetadata.getGoogleId(), 100));
|
||||
metadata.setComicvineId(truncate(epubMetadata.getComicvineId(), 100));
|
||||
metadata.setRanobedbId(truncate(epubMetadata.getRanobedbId(), 100));
|
||||
metadata.setRanobedbRating(epubMetadata.getRanobedbRating());
|
||||
|
||||
bookCreatorService.addAuthorsToBook(epubMetadata.getAuthors(), bookEntity);
|
||||
|
||||
@@ -133,4 +135,4 @@ public class EpubProcessor extends AbstractFileProcessor implements BookFileProc
|
||||
bookCreatorService.addCategoriesToBook(validSubjects, bookEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -113,6 +113,8 @@ public class Fb2Processor extends AbstractFileProcessor implements BookFileProce
|
||||
metadata.setHardcoverReviewCount(fb2Metadata.getHardcoverReviewCount());
|
||||
metadata.setGoogleId(truncate(fb2Metadata.getGoogleId(), 100));
|
||||
metadata.setComicvineId(truncate(fb2Metadata.getComicvineId(), 100));
|
||||
metadata.setRanobedbId(truncate(fb2Metadata.getRanobedbId(), 100));
|
||||
metadata.setRanobedbRating(fb2Metadata.getRanobedbRating());
|
||||
|
||||
bookCreatorService.addAuthorsToBook(fb2Metadata.getAuthors(), bookEntity);
|
||||
|
||||
|
||||
+4
-1
@@ -130,6 +130,9 @@ public class PdfProcessor extends AbstractFileProcessor implements BookFileProce
|
||||
if (StringUtils.isNotBlank(extracted.getComicvineId())) {
|
||||
bookEntity.getMetadata().setComicvineId(extracted.getComicvineId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(extracted.getRanobedbId())) {
|
||||
bookEntity.getMetadata().setRanobedbId(extracted.getRanobedbId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(extracted.getIsbn10())) {
|
||||
bookEntity.getMetadata().setIsbn10(extracted.getIsbn10());
|
||||
}
|
||||
@@ -160,4 +163,4 @@ public class PdfProcessor extends AbstractFileProcessor implements BookFileProce
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -170,6 +170,8 @@ public class BookMetadataUpdater {
|
||||
handleFieldUpdate(e.getHardcoverReviewCountLocked(), clear.isHardcoverReviewCount(), m.getHardcoverReviewCount(), e::setHardcoverReviewCount, e::getHardcoverReviewCount, replaceMode);
|
||||
handleFieldUpdate(e.getLubimyczytacIdLocked(), clear.isLubimyczytacId(), m.getLubimyczytacId(), v -> e.setLubimyczytacId(nullIfBlank(v)), e::getLubimyczytacId, replaceMode);
|
||||
handleFieldUpdate(e.getLubimyczytacRatingLocked(), clear.isLubimyczytacRating(), m.getLubimyczytacRating(), e::setLubimyczytacRating, e::getLubimyczytacRating, replaceMode);
|
||||
handleFieldUpdate(e.getRanobedbIdLocked(), clear.isRanobedbId(), m.getRanobedbId(), v -> e.setRanobedbId(nullIfBlank(v)), e::getRanobedbId, replaceMode);
|
||||
handleFieldUpdate(e.getRanobedbRatingLocked(), clear.isRanobedbRating(), m.getRanobedbRating(), e::setRanobedbRating, e::getRanobedbRating, replaceMode);
|
||||
}
|
||||
|
||||
private <T> void handleFieldUpdate(Boolean locked, boolean shouldClear, T newValue, Consumer<T> setter, Supplier<T> getter, MetadataReplaceMode mode) {
|
||||
@@ -393,6 +395,8 @@ public class BookMetadataUpdater {
|
||||
Pair.of(m.getGoodreadsReviewCountLocked(), e::setGoodreadsReviewCountLocked),
|
||||
Pair.of(m.getHardcoverRatingLocked(), e::setHardcoverRatingLocked),
|
||||
Pair.of(m.getHardcoverReviewCountLocked(), e::setHardcoverReviewCountLocked),
|
||||
Pair.of(m.getRanobedbIdLocked(), e::setRanobedbIdLocked),
|
||||
Pair.of(m.getRanobedbRatingLocked(), e::setRanobedbRatingLocked),
|
||||
Pair.of(m.getCoverLocked(), e::setCoverLocked),
|
||||
Pair.of(m.getAuthorsLocked(), e::setAuthorsLocked),
|
||||
Pair.of(m.getCategoriesLocked(), e::setCategoriesLocked),
|
||||
|
||||
+1
@@ -63,6 +63,7 @@ public class MetadataMatchService {
|
||||
if (isPositive(metadata.getGoodreadsReviewCount(), metadata.getGoodreadsReviewCountLocked())) score += weights.getGoodreadsReviewCount();
|
||||
if (isPositive(metadata.getHardcoverRating(), metadata.getHardcoverRatingLocked())) score += weights.getHardcoverRating();
|
||||
if (isPositive(metadata.getHardcoverReviewCount(), metadata.getHardcoverReviewCountLocked())) score += weights.getHardcoverReviewCount();
|
||||
if (isPositive(metadata.getRanobedbRating(), metadata.getRanobedbRatingLocked())) score += weights.getRanobedbRating();
|
||||
|
||||
return (score / totalWeight) * 100f;
|
||||
}
|
||||
|
||||
+13
@@ -340,6 +340,8 @@ public class MetadataRefreshService {
|
||||
addProviderToSet(fieldOptions.getGoodreadsReviewCount(), uniqueProviders, appSettings);
|
||||
addProviderToSet(fieldOptions.getHardcoverRating(), uniqueProviders, appSettings);
|
||||
addProviderToSet(fieldOptions.getHardcoverReviewCount(), uniqueProviders, appSettings);
|
||||
addProviderToSet(fieldOptions.getRanobedbId(), uniqueProviders, appSettings);
|
||||
addProviderToSet(fieldOptions.getRanobedbRating(), uniqueProviders, appSettings);
|
||||
addProviderToSet(fieldOptions.getMoods(), uniqueProviders, appSettings);
|
||||
addProviderToSet(fieldOptions.getTags(), uniqueProviders, appSettings);
|
||||
}
|
||||
@@ -368,6 +370,7 @@ public class MetadataRefreshService {
|
||||
case GoodReads -> settings.getGoodReads() != null && settings.getGoodReads().isEnabled();
|
||||
case Hardcover -> settings.getHardcover() != null && settings.getHardcover().isEnabled();
|
||||
case Comicvine -> settings.getComicvine() != null && settings.getComicvine().isEnabled();
|
||||
case Ranobedb -> settings.getRanobedb() != null && settings.getRanobedb().isEnabled();
|
||||
case Douban -> settings.getDouban() != null && settings.getDouban().isEnabled();
|
||||
default -> true;
|
||||
};
|
||||
@@ -507,6 +510,16 @@ public class MetadataRefreshService {
|
||||
metadata.setComicvineId(metadataMap.get(Comicvine).getComicvineId());
|
||||
}
|
||||
}
|
||||
if (enabledFields.isRanobedbId()) {
|
||||
if (metadataMap.containsKey(Ranobedb)) {
|
||||
metadata.setRanobedbId(metadataMap.get(Ranobedb).getRanobedbId());
|
||||
}
|
||||
}
|
||||
if (enabledFields.isRanobedbRating()) {
|
||||
if (metadataMap.containsKey(Ranobedb)) {
|
||||
metadata.setRanobedbRating(metadataMap.get(Ranobedb).getRanobedbRating());
|
||||
}
|
||||
}
|
||||
if (enabledFields.isMoods()) {
|
||||
if (metadataMap.containsKey(Hardcover)) {
|
||||
metadata.setMoods(metadataMap.get(Hardcover).getMoods());
|
||||
|
||||
+3
-1
@@ -193,6 +193,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
|
||||
case "booklore:asin" -> builderMeta.asin(content);
|
||||
case "booklore:goodreads_id" -> builderMeta.goodreadsId(content);
|
||||
case "booklore:comicvine_id" -> builderMeta.comicvineId(content);
|
||||
case "booklore:ranobedb_id" -> builderMeta.ranobedbId(content);
|
||||
case "booklore:hardcover_id" -> builderMeta.hardcoverId(content);
|
||||
case "booklore:google_books_id" -> builderMeta.googleId(content);
|
||||
case "booklore:page_count" -> safeParseInt(content, builderMeta::pageCount);
|
||||
@@ -227,6 +228,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
|
||||
}
|
||||
case "GOODREADS" -> builderMeta.goodreadsId(value);
|
||||
case "COMICVINE" -> builderMeta.comicvineId(value);
|
||||
case "RANOBEDB" -> builderMeta.ranobedbId(value);
|
||||
case "GOOGLE" -> builderMeta.googleId(value);
|
||||
case "AMAZON" -> builderMeta.asin(value);
|
||||
case "HARDCOVER" -> builderMeta.hardcoverId(value);
|
||||
@@ -441,4 +443,4 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -181,6 +181,11 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
|
||||
metadataBuilder.comicvineId(comicvine);
|
||||
}
|
||||
|
||||
String ranobedb = identifiers.get("ranobedb");
|
||||
if (StringUtils.isNotBlank(ranobedb)) {
|
||||
metadataBuilder.ranobedbId(ranobedb);
|
||||
}
|
||||
|
||||
String hardcover = identifiers.get("hardcover");
|
||||
if (StringUtils.isNotBlank(hardcover)) {
|
||||
metadataBuilder.hardcoverId(hardcover);
|
||||
@@ -346,4 +351,4 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
|
||||
return prefixMap.keySet().iterator();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+297
@@ -0,0 +1,297 @@
|
||||
package com.adityachandel.booklore.service.metadata.parser;
|
||||
|
||||
import com.adityachandel.booklore.model.dto.Book;
|
||||
import com.adityachandel.booklore.model.dto.BookMetadata;
|
||||
import com.adityachandel.booklore.model.dto.request.FetchMetadataRequest;
|
||||
import com.adityachandel.booklore.model.dto.response.ranobedbapi.RanobedbSearchResponse;
|
||||
import com.adityachandel.booklore.model.dto.response.ranobedbapi.RanobedbBookResponse;
|
||||
import com.adityachandel.booklore.model.enums.MetadataProvider;
|
||||
import com.adityachandel.booklore.service.appsettings.AppSettingService;
|
||||
import com.adityachandel.booklore.util.BookUtils;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RanobeDbParser implements BookParser {
|
||||
private static final String RANOBEDB_URL = "https://ranobedb.org/api/v0/";
|
||||
private static final String RANOBEDB_IMAGE_URL = "https://images.ranobedb.org/";
|
||||
|
||||
private final AppSettingService appSettingService;
|
||||
private final HttpClient httpClient = HttpClient.newHttpClient();
|
||||
|
||||
// Rate limiter: 2 requests per second
|
||||
private static final int MAX_REQUESTS_PER_SECOND = 2;
|
||||
private static final long RATE_LIMIT_WINDOW_MS = 1000; // 1 second in milliseconds
|
||||
private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
private final AtomicLong lastRequestTime = new AtomicLong(0);
|
||||
private final AtomicLong tokenCount = new AtomicLong(MAX_REQUESTS_PER_SECOND);
|
||||
|
||||
@Override
|
||||
public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||
|
||||
String searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
if (searchTerm == null) {
|
||||
log.warn("No valid search term provided for metadata fetch.");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return getMetadataListByTerm(searchTerm, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||
String searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
if (searchTerm == null) {
|
||||
log.warn("No valid search term provided for metadata fetch.");
|
||||
return null;
|
||||
}
|
||||
List<BookMetadata> metadataList = getMetadataListByTerm(searchTerm, true);
|
||||
return metadataList.isEmpty() ? null : metadataList.getFirst();
|
||||
}
|
||||
|
||||
private void waitForRateLimit() {
|
||||
while (true) {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
long lastTime = lastRequestTime.get();
|
||||
long timeSinceLastRequest = currentTime - lastTime;
|
||||
|
||||
// Refill tokens based on time elapsed
|
||||
if (timeSinceLastRequest >= RATE_LIMIT_WINDOW_MS) {
|
||||
// More than 1 second has passed, refill to max tokens
|
||||
if (lastRequestTime.compareAndSet(lastTime, currentTime)) {
|
||||
tokenCount.set(MAX_REQUESTS_PER_SECOND);
|
||||
}
|
||||
} else {
|
||||
// Calculate how many tokens to add based on time elapsed
|
||||
long tokensToAdd = (timeSinceLastRequest * MAX_REQUESTS_PER_SECOND) / RATE_LIMIT_WINDOW_MS;
|
||||
if (tokensToAdd > 0) {
|
||||
long currentTokens = tokenCount.get();
|
||||
long newTokens = Math.min(currentTokens + tokensToAdd, MAX_REQUESTS_PER_SECOND);
|
||||
tokenCount.compareAndSet(currentTokens, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
// Try to consume a token
|
||||
long currentTokens = tokenCount.get();
|
||||
if (currentTokens > 0) {
|
||||
if (tokenCount.compareAndSet(currentTokens, currentTokens - 1)) {
|
||||
lastRequestTime.set(System.currentTimeMillis());
|
||||
return; // Successfully acquired a token
|
||||
}
|
||||
} else {
|
||||
// No tokens available, wait before retrying
|
||||
try {
|
||||
long waitTime = RATE_LIMIT_WINDOW_MS / MAX_REQUESTS_PER_SECOND;
|
||||
Thread.sleep(waitTime);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
log.warn("Rate limiter interrupted", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<BookMetadata> getMetadataListByTerm(String term, Boolean fetchTop) {
|
||||
log.info("Ranobedb: Fetching metadata for term: '{}'", term);
|
||||
|
||||
try {
|
||||
// Apply rate limiting before making the API request
|
||||
waitForRateLimit();
|
||||
|
||||
URI uri = UriComponentsBuilder.fromUriString(RANOBEDB_URL)
|
||||
.path("/books")
|
||||
.queryParam("q", term)
|
||||
.queryParam("query", term)
|
||||
.queryParam("limit", 5)
|
||||
.queryParam("rl", "en")
|
||||
.queryParam("rll", "or")
|
||||
.queryParam("rf", "digital,print")
|
||||
.queryParam("rfl", "or")
|
||||
.build()
|
||||
.toUri();
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(uri)
|
||||
.header("User-Agent", "BookLore/1.0 (Book and Comic Metadata Fetcher; +https://github.com/booklore-app/booklore)")
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
List<BookMetadata> metadataList = parseRanobeDbApiResponse(response.body(), fetchTop);
|
||||
log.error("Ranobedb: Found {} results for term: '{}'", metadataList.size(), term);
|
||||
return metadataList;
|
||||
} else {
|
||||
log.error("Ranobedb Search API returned status code {}", response.statusCode());
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error("Error fetching metadata from Ranobedb Search API", e);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private String getSearchTerm(Book book, FetchMetadataRequest request) {
|
||||
if (request.getTitle() != null && !request.getTitle().isEmpty()) {
|
||||
return request.getTitle();
|
||||
} else if (book.getFileName() != null && !book.getFileName().isEmpty()) {
|
||||
return BookUtils.cleanFileName(book.getFileName());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<BookMetadata> parseRanobeDbApiResponse(String responseBody, Boolean fetchTop) throws IOException {
|
||||
RanobedbSearchResponse searchResponse = OBJECT_MAPPER.readValue(responseBody, RanobedbSearchResponse.class);
|
||||
if (searchResponse.getBooks() == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (fetchTop && !searchResponse.getBooks().isEmpty()) {
|
||||
BookMetadata topMetadata = searchResultToBookMetadata(searchResponse.getBooks().getFirst().getId());
|
||||
return topMetadata != null ? List.of(topMetadata) : Collections.emptyList();
|
||||
} else {
|
||||
return searchResponse.getBooks().stream()
|
||||
.map(book -> searchResultToBookMetadata(book.getId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
private BookMetadata searchResultToBookMetadata(int bookId) {
|
||||
|
||||
try {
|
||||
// Apply rate limiting before making the API request
|
||||
waitForRateLimit();
|
||||
|
||||
log.info("Ranobedb: Fetching metadata for book id: '{}'", bookId);
|
||||
URI uri = UriComponentsBuilder.fromUriString(RANOBEDB_URL)
|
||||
.pathSegment("book", String.valueOf(bookId))
|
||||
.build()
|
||||
.toUri();
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(uri)
|
||||
.header("User-Agent", "BookLore/1.0 (Book and Comic Metadata Fetcher; +https://github.com/booklore-app/booklore)")
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
RanobedbBookResponse responstObj = OBJECT_MAPPER.readValue(response.body(), RanobedbBookResponse.class);
|
||||
RanobedbBookResponse.Book book = responstObj.getBook();
|
||||
if (book == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RanobedbBookResponse.TitleEntry englishTitleEntry = book.getTitles().stream()
|
||||
.filter(titleEntry -> "en".equalsIgnoreCase(titleEntry.getLang()))
|
||||
.filter(titleEntry -> titleEntry.getOfficial())
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
RanobedbBookResponse.Release englishRelease = book.getReleases().stream()
|
||||
.filter(release -> "en".equalsIgnoreCase(release.getLang()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
RanobedbBookResponse.Publisher englishPublisher = book.getPublishers().stream()
|
||||
.filter(publisher -> "en".equalsIgnoreCase(publisher.getLang()))
|
||||
.filter(publisher -> RanobedbBookResponse.PublisherType.PUBLISHER.equals(publisher.getPublisherType()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
|
||||
List<RanobedbBookResponse.SeriesBook> seriesBooks = book.getSeries() != null ? book.getSeries().getBooks() : List.of();
|
||||
int seriesIndex = IntStream.range(0, seriesBooks.size())
|
||||
.filter(i -> seriesBooks.get(i).getId().equals(book.getId()))
|
||||
.findFirst()
|
||||
.orElse(-1);
|
||||
|
||||
HashSet<String> authors = book.getEditions().stream()
|
||||
.flatMap(edition -> edition.getStaff().stream())
|
||||
.filter(staff -> RanobedbBookResponse.RoleType.AUTHOR.equals(staff.getRoleType()))
|
||||
.map(staff -> staff.getRomaji() != null ? staff.getRomaji() : staff.getName())
|
||||
.collect(Collectors.toCollection(HashSet::new));
|
||||
|
||||
HashSet<String> genres = book.getSeries() != null ? book.getSeries().getTags().stream()
|
||||
.filter(tag -> RanobedbBookResponse.TagType.GENRE.equals(tag.getTtype()))
|
||||
.map(RanobedbBookResponse.Tag::getName)
|
||||
.map(genre -> Pattern.compile("\\b(.)(.*?)\\b").matcher(genre).replaceAll(m -> m.group(1).toUpperCase() + m.group(2).toLowerCase()))
|
||||
.collect(Collectors.toCollection(HashSet::new)) : new HashSet<>();
|
||||
|
||||
String title = englishTitleEntry != null ? englishTitleEntry.getTitle() : book.getTitle();
|
||||
String subtitle = null;
|
||||
if (book.getSeries() != null && book.getSeries().getTitle() != null && title.startsWith(book.getSeries().getTitle())) {
|
||||
String remainingTitle = title.substring(book.getSeries().getTitle().length()).trim();
|
||||
String[] titleParts = remainingTitle.split(":", 2);
|
||||
if (titleParts.length == 2) {
|
||||
title = title.substring(0, title.indexOf(titleParts[1]) - 1).trim();
|
||||
subtitle = titleParts[1].trim();
|
||||
}
|
||||
}
|
||||
|
||||
return BookMetadata.builder()
|
||||
.provider(MetadataProvider.Ranobedb)
|
||||
.ranobedbId(String.valueOf(book.getId()))
|
||||
.ranobedbRating(book.getRating() != null ? book.getRating().getScore() / 2.0 : null)
|
||||
.title(title)
|
||||
.subtitle(subtitle)
|
||||
.authors(authors)
|
||||
.categories(genres)
|
||||
.publisher(englishPublisher != null ? englishPublisher.getName() : null)
|
||||
.thumbnailUrl(book.getImage() != null ? RANOBEDB_IMAGE_URL + book.getImage().getFilename() : null)
|
||||
.description(book.getDescription())
|
||||
.language(englishRelease != null ? englishRelease.getLang() : book.getLang())
|
||||
.seriesName(book.getSeries() != null ? book.getSeries().getTitle() : null)
|
||||
.seriesNumber(seriesIndex != -1 ? seriesIndex + 1.0f : null)
|
||||
.seriesTotal(seriesBooks.isEmpty() ? null : seriesBooks.size())
|
||||
.publishedDate(englishRelease != null ? parseDate(englishRelease.getReleaseDate()) : parseDate(book.getCReleaseDate()))
|
||||
.build();
|
||||
} else {
|
||||
log.error("Ranobedb Get Book API returned status code {}", response.statusCode());
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error("Error fetching metadata from Ranobedb Search API", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private LocalDate parseDate(Long dateInt) {
|
||||
if (dateInt == null || dateInt == 0) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
// Parse date from integer of the format (YYYYMMDD)
|
||||
return LocalDate.of(
|
||||
(int)(dateInt / 10000),
|
||||
(int)((dateInt / 100) % 100),
|
||||
(int)(dateInt % 100)
|
||||
);
|
||||
} catch (DateTimeParseException e) {
|
||||
log.debug("Could not parse date: {}", dateInt);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-1
@@ -140,6 +140,13 @@ public class MetadataCopyHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void copyRanobedbId(boolean clear, Consumer<String> consumer) {
|
||||
if (!isLocked(metadata.getRanobedbIdLocked())) {
|
||||
if (clear) consumer.accept(null);
|
||||
else if (metadata.getRanobedbId() != null) consumer.accept(metadata.getRanobedbId());
|
||||
}
|
||||
}
|
||||
|
||||
public void copyAuthors(boolean clear, Consumer<Set<String>> consumer) {
|
||||
if (!isLocked(metadata.getAuthorsLocked())) {
|
||||
if (clear) {
|
||||
@@ -167,4 +174,4 @@ public class MetadataCopyHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -209,6 +209,7 @@ public class PdfMetadataWriter implements MetadataWriter {
|
||||
helper.copyGoodreadsId(clear != null && clear.isGoodreadsId(), id -> appendIdentifier(doc, rdfBag, "goodreads", id != null ? id : ""));
|
||||
helper.copyComicvineId(clear != null && clear.isComicvineId(), id -> appendIdentifier(doc, rdfBag, "comicvine", id != null ? id : ""));
|
||||
helper.copyHardcoverId(clear != null && clear.isHardcoverId(), id -> appendIdentifier(doc, rdfBag, "hardcover", id != null ? id : ""));
|
||||
helper.copyRanobedbId(clear != null && clear.isRanobedbId(), id -> appendIdentifier(doc, rdfBag, "ranobedb", id != null ? id : ""));
|
||||
helper.copyAsin(clear != null && clear.isAsin(), id -> appendIdentifier(doc, rdfBag, "amazon", id != null ? id : ""));
|
||||
helper.copyIsbn13(clear != null && clear.isIsbn13(), id -> appendIdentifier(doc, rdfBag, "isbn", id != null ? id : ""));
|
||||
|
||||
@@ -300,4 +301,4 @@ public class PdfMetadataWriter implements MetadataWriter {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ public class MetadataChangeDetector {
|
||||
compare(changes, "hardcoverReviewCount", clear.isHardcoverReviewCount(), newMeta.getHardcoverReviewCount(), existingMeta.getHardcoverReviewCount(), () -> !isTrue(existingMeta.getHardcoverReviewCountLocked()), newMeta.getHardcoverReviewCountLocked(), existingMeta.getHardcoverReviewCountLocked());
|
||||
compare(changes, "lubimyczytacId", clear.isLubimyczytacId(), newMeta.getLubimyczytacId(), existingMeta.getLubimyczytacId(), () -> !isTrue(existingMeta.getLubimyczytacIdLocked()), newMeta.getLubimyczytacIdLocked(), existingMeta.getLubimyczytacIdLocked());
|
||||
compare(changes, "lubimyczytacRating", clear.isLubimyczytacRating(), newMeta.getLubimyczytacRating(), existingMeta.getLubimyczytacRating(), () -> !isTrue(existingMeta.getLubimyczytacRatingLocked()), newMeta.getLubimyczytacRatingLocked(), existingMeta.getLubimyczytacRatingLocked());
|
||||
compare(changes, "ranobedbId", clear.isRanobedbId(), newMeta.getRanobedbId(), existingMeta.getRanobedbId(), () -> !isTrue(existingMeta.getRanobedbIdLocked()), newMeta.getRanobedbIdLocked(), existingMeta.getRanobedbIdLocked());
|
||||
compare(changes, "ranobedbRating", clear.isRanobedbRating(), newMeta.getRanobedbRating(), existingMeta.getRanobedbRating(), () -> !isTrue(existingMeta.getRanobedbRatingLocked()), newMeta.getRanobedbRatingLocked(), existingMeta.getRanobedbRatingLocked());
|
||||
compare(changes, "authors", clear.isAuthors(), newMeta.getAuthors(), toNameSet(existingMeta.getAuthors()), () -> !isTrue(existingMeta.getAuthorsLocked()), newMeta.getAuthorsLocked(), existingMeta.getAuthorsLocked());
|
||||
compare(changes, "categories", clear.isCategories(), newMeta.getCategories(), toNameSet(existingMeta.getCategories()), () -> !isTrue(existingMeta.getCategoriesLocked()), newMeta.getCategoriesLocked(), existingMeta.getCategoriesLocked());
|
||||
compare(changes, "moods", clear.isMoods(), newMeta.getMoods(), toNameSet(existingMeta.getMoods()), () -> !isTrue(existingMeta.getMoodsLocked()), newMeta.getMoodsLocked(), existingMeta.getMoodsLocked());
|
||||
@@ -90,6 +92,8 @@ public class MetadataChangeDetector {
|
||||
compareValue(diffs, "hardcoverReviewCount", clear.isHardcoverReviewCount(), newMeta.getHardcoverReviewCount(), existingMeta.getHardcoverReviewCount(), () -> !isTrue(existingMeta.getHardcoverReviewCountLocked()));
|
||||
compareValue(diffs, "lubimyczytacId", clear.isLubimyczytacId(), newMeta.getLubimyczytacId(), existingMeta.getLubimyczytacId(), () -> !isTrue(existingMeta.getLubimyczytacIdLocked()));
|
||||
compareValue(diffs, "lubimyczytacRating", clear.isLubimyczytacRating(), newMeta.getLubimyczytacRating(), existingMeta.getLubimyczytacRating(), () -> !isTrue(existingMeta.getLubimyczytacRatingLocked()));
|
||||
compareValue(diffs, "ranobedbId", clear.isRanobedbId(), newMeta.getRanobedbId(), existingMeta.getRanobedbId(), () -> !isTrue(existingMeta.getRanobedbIdLocked()));
|
||||
compareValue(diffs, "ranobedbRating", clear.isRanobedbRating(), newMeta.getRanobedbRating(), existingMeta.getRanobedbRating(), () -> !isTrue(existingMeta.getRanobedbRatingLocked()));
|
||||
compareValue(diffs, "authors", clear.isAuthors(), newMeta.getAuthors(), toNameSet(existingMeta.getAuthors()), () -> !isTrue(existingMeta.getAuthorsLocked()));
|
||||
compareValue(diffs, "categories", clear.isCategories(), newMeta.getCategories(), toNameSet(existingMeta.getCategories()), () -> !isTrue(existingMeta.getCategoriesLocked()));
|
||||
compareValue(diffs, "moods", clear.isMoods(), newMeta.getMoods(), toNameSet(existingMeta.getMoods()), () -> !isTrue(existingMeta.getMoodsLocked()));
|
||||
@@ -115,6 +119,7 @@ public class MetadataChangeDetector {
|
||||
compareValue(diffs, "hardcoverId", clear.isHardcoverId(), newMeta.getHardcoverId(), existingMeta.getHardcoverId(), () -> !isTrue(existingMeta.getHardcoverIdLocked()));
|
||||
compareValue(diffs, "hardcoverBookId", clear.isHardcoverBookId(), newMeta.getHardcoverBookId(), existingMeta.getHardcoverBookId(), () -> !isTrue(existingMeta.getHardcoverBookIdLocked()));
|
||||
compareValue(diffs, "googleId", clear.isGoogleId(), newMeta.getGoogleId(), existingMeta.getGoogleId(), () -> !isTrue(existingMeta.getGoogleIdLocked()));
|
||||
compareValue(diffs, "ranobedbId", clear.isRanobedbId(), newMeta.getRanobedbId(), existingMeta.getRanobedbId(), () -> !isTrue(existingMeta.getRanobedbIdLocked()));
|
||||
compareValue(diffs, "language", clear.isLanguage(), newMeta.getLanguage(), existingMeta.getLanguage(), () -> !isTrue(existingMeta.getLanguageLocked()));
|
||||
compareValue(diffs, "authors", clear.isAuthors(), newMeta.getAuthors(), toNameSet(existingMeta.getAuthors()), () -> !isTrue(existingMeta.getAuthorsLocked()));
|
||||
compareValue(diffs, "categories", clear.isCategories(), newMeta.getCategories(), toNameSet(existingMeta.getCategories()), () -> !isTrue(existingMeta.getCategoriesLocked()));
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE book_metadata
|
||||
ADD COLUMN ranobedb_id VARCHAR(100),
|
||||
ADD COLUMN ranobedb_rating FLOAT,
|
||||
ADD COLUMN ranobedb_id_locked BOOLEAN DEFAULT FALSE,
|
||||
ADD COLUMN ranobedb_rating_locked BOOLEAN DEFAULT FALSE;
|
||||
Reference in New Issue
Block a user