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;
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
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.settings.AppSettings;
|
||||
import com.adityachandel.booklore.model.dto.settings.MetadataProviderSettings;
|
||||
import com.adityachandel.booklore.service.appsettings.AppSettingService;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class RanobeDbParserTest {
|
||||
|
||||
@Mock
|
||||
private AppSettingService appSettingService;
|
||||
|
||||
@InjectMocks
|
||||
private RanobeDbParser parser;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFetchMetadata_EmptyQuery() {
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("Test Book")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.build();
|
||||
// Empty query - no title
|
||||
|
||||
// When
|
||||
List<BookMetadata> results = parser.fetchMetadata(book, request);
|
||||
|
||||
// Then
|
||||
assertNotNull(results);
|
||||
assertTrue(results.isEmpty(), "Should return empty list when query is empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("Integration test - requires network access to RanobeDB.org")
|
||||
void testFetchMetadata_Integration_RealBook() {
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("That Time I Got Reincarnated as a Slime, Vol. 1")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.title("That Time I Got Reincarnated as a Slime, Vol. 1")
|
||||
.author("Fuse")
|
||||
.build();
|
||||
|
||||
// When
|
||||
List<BookMetadata> results = parser.fetchMetadata(book, request);
|
||||
|
||||
// Then
|
||||
assertNotNull(results);
|
||||
assertFalse(results.isEmpty(), "Should return results for real book");
|
||||
|
||||
BookMetadata firstResult = results.getFirst();
|
||||
assertNotNull(firstResult.getTitle(), "Title should be present");
|
||||
assertNotNull(firstResult.getRanobedbId(), "RanobeDB ID should be present");
|
||||
assertTrue(firstResult.getAuthors() != null && !firstResult.getAuthors().isEmpty(),
|
||||
"Authors should be present");
|
||||
}
|
||||
}
|
||||
+3
@@ -45,6 +45,7 @@ export type FilterType =
|
||||
| 'pageCount'
|
||||
| 'amazonRating'
|
||||
| 'goodreadsRating'
|
||||
| 'ranobedbRating'
|
||||
| 'hardcoverRating';
|
||||
|
||||
export const ratingRanges = [
|
||||
@@ -222,6 +223,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
amazonRating: 'Amazon Rating',
|
||||
goodreadsRating: 'Goodreads Rating',
|
||||
hardcoverRating: 'Hardcover Rating',
|
||||
ranobedbRating: 'Ranobedb Rating',
|
||||
};
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
@@ -289,6 +291,7 @@ export class BookFilterComponent implements OnInit, OnDestroy {
|
||||
amazonRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.amazonRating ?? undefined), 'id', 'name', 'sortIndex'),
|
||||
goodreadsRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.goodreadsRating ?? undefined), 'id', 'name', 'sortIndex'),
|
||||
hardcoverRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.hardcoverRating ?? undefined), 'id', 'name', 'sortIndex'),
|
||||
ranobedbRating: this.getFilterStream((book: Book) => getRatingRangeFilters(book.metadata?.ranobedbRating ?? undefined), 'id', 'name', 'sortIndex'),
|
||||
};
|
||||
|
||||
this.filterTypes = Object.keys(this.filterStreams) as FilterType[];
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
} @else if (col.field === 'amazonRating' || col.field === 'goodreadsRating' || col.field === 'hardcoverRating') {
|
||||
} @else if (col.field === 'amazonRating' || col.field === 'goodreadsRating' || col.field === 'hardcoverRating' || col.field == 'ranobedbRating') {
|
||||
<td class="min-w-[10rem] max-w-[10rem] overflow-hidden truncate">
|
||||
<span class="flex items-center gap-1">
|
||||
<p-rating
|
||||
|
||||
+4
-2
@@ -72,7 +72,8 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
{field: 'goodreadsRating', header: 'Goodreads'},
|
||||
{field: 'goodreadsReviewCount', header: 'GR #'},
|
||||
{field: 'hardcoverRating', header: 'Hardcover'},
|
||||
{field: 'hardcoverReviewCount', header: 'HC #'}
|
||||
{field: 'hardcoverReviewCount', header: 'HC #'},
|
||||
{field: 'ranobedbRating', header: 'Ranobedb'},
|
||||
];
|
||||
|
||||
scrollHeight = 'calc(100dvh - 160px)';
|
||||
@@ -294,7 +295,8 @@ export class BookTableComponent implements OnInit, OnDestroy, OnChanges {
|
||||
|
||||
case 'amazonRating':
|
||||
case 'goodreadsRating':
|
||||
case 'hardcoverRating': {
|
||||
case 'hardcoverRating':
|
||||
case 'ranobedbRating': {
|
||||
const rating = metadata[field];
|
||||
return typeof rating === 'number' ? rating.toFixed(1) : '';
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ export class FilterLabelHelper {
|
||||
amazonRating: 'Amazon Rating',
|
||||
goodreadsRating: 'Goodreads Rating',
|
||||
hardcoverRating: 'Hardcover Rating',
|
||||
ranobedbRating: 'Ranobedb Rating',
|
||||
mood: 'Mood',
|
||||
tag: 'Tag',
|
||||
};
|
||||
@@ -71,6 +72,7 @@ export class FilterLabelHelper {
|
||||
case 'amazonrating':
|
||||
case 'goodreadsrating':
|
||||
case 'hardcoverrating':
|
||||
case 'ranobedbrating':
|
||||
{
|
||||
const ratingRange = ratingRanges.find(r => r.id === value);
|
||||
if (ratingRange) return ratingRange.label;
|
||||
|
||||
+8
@@ -122,6 +122,7 @@ describe('SideBarFilter', () => {
|
||||
amazonRating: 4.2,
|
||||
goodreadsRating: 3.8,
|
||||
hardcoverRating: 4.0,
|
||||
ranobedbRating: 3.5,
|
||||
publishedDate: '2020-01-01',
|
||||
pageCount: 150,
|
||||
language: 'en'
|
||||
@@ -148,6 +149,7 @@ describe('SideBarFilter', () => {
|
||||
amazonRating: 2.5,
|
||||
goodreadsRating: 2.8,
|
||||
hardcoverRating: 2.0,
|
||||
ranobedbRating: 2.4,
|
||||
publishedDate: '2019-01-01',
|
||||
pageCount: 50,
|
||||
language: 'fr'
|
||||
@@ -235,6 +237,12 @@ describe('SideBarFilter', () => {
|
||||
expect(result?.books?.[0]?.metadata?.hardcoverRating).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
|
||||
it('filters by ranobedbRating', async () => {
|
||||
const result = await firstValueFrom(filterWith({ranobedbRating: ['3to4']}, 'and'));
|
||||
expect(result?.books?.length).toBe(1);
|
||||
expect(result?.books?.[0]?.metadata?.ranobedbRating).toBeGreaterThanOrEqual(3);
|
||||
});
|
||||
|
||||
it('filters by personalRating', async () => {
|
||||
const result = await firstValueFrom(filterWith({personalRating: ['7']}, 'and'));
|
||||
expect(result?.books?.length).toBe(1);
|
||||
|
||||
@@ -94,6 +94,8 @@ export class SideBarFilter implements BookFilter {
|
||||
return filterValues.some(range => isRatingInRange(book.metadata?.goodreadsRating, range));
|
||||
case 'hardcoverRating':
|
||||
return filterValues.some(range => isRatingInRange(book.metadata?.hardcoverRating, range));
|
||||
case 'ranobedbRating':
|
||||
return filterValues.some(range => isRatingInRange(book.metadata?.ranobedbRating, range));
|
||||
case 'personalRating':
|
||||
return filterValues.some(range => isRatingInRange10(book.personalRating, range));
|
||||
case 'publishedDate':
|
||||
|
||||
+4
-1
@@ -35,7 +35,8 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
'isbn13Locked', 'isbn10Locked', 'asinLocked', 'pageCountLocked', 'thumbnailLocked', 'languageLocked', 'coverLocked',
|
||||
'seriesNameLocked', 'seriesNumberLocked', 'seriesTotalLocked', 'authorsLocked', 'categoriesLocked', 'moodsLocked', 'tagsLocked',
|
||||
'amazonRatingLocked', 'amazonReviewCountLocked', 'goodreadsRatingLocked', 'goodreadsReviewCountLocked',
|
||||
'hardcoverRatingLocked', 'hardcoverReviewCountLocked', 'goodreadsIdLocked', 'hardcoverIdLocked', 'hardcoverBookIdLocked', 'googleIdLocked', 'comicvineIdLocked'
|
||||
'hardcoverRatingLocked', 'hardcoverReviewCountLocked', 'goodreadsIdLocked', 'hardcoverIdLocked', 'hardcoverBookIdLocked', 'googleIdLocked', 'comicvineIdLocked',
|
||||
'ranobedbIdLocked', 'ranobedbRatingLocked'
|
||||
];
|
||||
|
||||
fieldLabels: Record<string, string> = {
|
||||
@@ -69,6 +70,8 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
hardcoverBookIdLocked: 'Hardcover Book ID',
|
||||
googleIdLocked: 'Google ID',
|
||||
comicvineIdLocked: 'Comicvine ID',
|
||||
ranobedbIdLocked: 'Ranobedb ID',
|
||||
ranobedbRatingLocked: 'Ranobedb ★',
|
||||
};
|
||||
|
||||
isSaving = false;
|
||||
|
||||
+6
@@ -89,6 +89,12 @@
|
||||
@if (backupMetadata.hardcoverReviewCount !== null) {
|
||||
<div><strong>Hardcover Review Count:</strong> {{ backupMetadata.hardcoverReviewCount }}</div>
|
||||
}
|
||||
@if (backupMetadata.ranobedbId) {
|
||||
<div><strong>Ranobedb ID:</strong> {{ backupMetadata.ranobedbId }}</div>
|
||||
}
|
||||
@if (backupMetadata.ranobedbRating !== null) {
|
||||
<div><strong>Ranobedb Rating:</strong> {{ backupMetadata.ranobedbRating }}</div>
|
||||
}
|
||||
@if (backupMetadata.googleId) {
|
||||
<div><strong>Google Books ID:</strong> {{ backupMetadata.googleId }}</div>
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ export class BookSorter {
|
||||
{label: 'Goodreads #', field: 'goodreadsReviewCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Hardcover Rating', field: 'hardcoverRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Hardcover #', field: 'hardcoverReviewCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Ranobedb Rating', field: 'ranobedbRating', direction: SortDirection.ASCENDING},
|
||||
{label: 'Pages', field: 'pageCount', direction: SortDirection.ASCENDING},
|
||||
{label: 'Random', field: 'random', direction: SortDirection.ASCENDING},
|
||||
];
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ describe('TableColumnPreferenceService', () => {
|
||||
{field: 'goodreadsReviewCount', header: 'GR #'},
|
||||
{field: 'hardcoverRating', header: 'Hardcover'},
|
||||
{field: 'hardcoverReviewCount', header: 'HC #'},
|
||||
{field: 'ranobedbRating', header: 'Ranobedb'},
|
||||
];
|
||||
|
||||
const fallbackPreferences: TableColumnPreference[] = allColumns.map((col, index) => ({
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ export class TableColumnPreferenceService {
|
||||
{field: 'goodreadsReviewCount', header: 'GR #'},
|
||||
{field: 'hardcoverRating', header: 'Hardcover'},
|
||||
{field: 'hardcoverReviewCount', header: 'HC #'},
|
||||
{field: 'ranobedbRating', header: 'Ranobedb'},
|
||||
];
|
||||
|
||||
private readonly fallbackPreferences: TableColumnPreference[] = this.allAvailableColumns.map((col, index) => ({
|
||||
|
||||
@@ -100,10 +100,12 @@ export interface BookMetadata {
|
||||
amazonReviewCount?: number | null;
|
||||
goodreadsRating?: number | null;
|
||||
goodreadsReviewCount?: number | null;
|
||||
hardcoverRating?: number | null;
|
||||
hardcoverReviewCount?: number | null;
|
||||
lubimyczytacId?: string;
|
||||
lubimyczytacRating?: number | null;
|
||||
ranobedbId?: string;
|
||||
ranobedbRating?: number | null;
|
||||
hardcoverRating?: number | null;
|
||||
coverUpdatedOn?: string;
|
||||
authors?: string[];
|
||||
categories?: string[];
|
||||
@@ -139,6 +141,8 @@ export interface BookMetadata {
|
||||
hardcoverReviewCountLocked?: boolean;
|
||||
lubimyczytacIdLocked?: boolean;
|
||||
lubimyczytacRatingLocked?: boolean;
|
||||
ranobedbIdLocked?: boolean;
|
||||
ranobedbRatingLocked?: boolean;
|
||||
coverUpdatedOnLocked?: boolean;
|
||||
authorsLocked?: boolean;
|
||||
categoriesLocked?: boolean;
|
||||
@@ -176,6 +180,8 @@ export interface MetadataClearFlags {
|
||||
hardcoverReviewCount?: boolean;
|
||||
lubimyczytacId?: boolean;
|
||||
lubimyczytacRating?: boolean;
|
||||
ranobedbId?: boolean;
|
||||
ranobedbRating?: boolean;
|
||||
authors?: boolean;
|
||||
categories?: boolean;
|
||||
moods?: boolean;
|
||||
|
||||
@@ -87,6 +87,7 @@ export class SortService {
|
||||
goodreadsReviewCount: (book) => book.metadata?.goodreadsReviewCount || null,
|
||||
hardcoverRating: (book) => book.metadata?.hardcoverRating || null,
|
||||
hardcoverReviewCount: (book) => book.metadata?.hardcoverReviewCount || null,
|
||||
ranobedbRating: (book) => book.metadata?.ranobedbRating || null,
|
||||
locked: (book) =>
|
||||
Object.keys(book.metadata ?? {})
|
||||
.filter((key) => key.endsWith('Locked'))
|
||||
|
||||
+7
-3
@@ -34,7 +34,7 @@ import {DatePicker} from 'primeng/datepicker';
|
||||
export class BookdropFileMetadataPickerComponent {
|
||||
|
||||
private readonly confirmationService = inject(ConfirmationService);
|
||||
|
||||
|
||||
@Input() fetchedMetadata!: BookMetadata;
|
||||
@Input() originalMetadata?: BookMetadata;
|
||||
@Input() metadataForm!: FormGroup;
|
||||
@@ -85,6 +85,8 @@ export class BookdropFileMetadataPickerComponent {
|
||||
{label: 'Hardcover ★', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
|
||||
{label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleId'},
|
||||
{label: 'Comicvine ID', controlName: 'comicvineId', lockedKey: 'comicvineIdLocked', fetchedKey: 'comicvineId'},
|
||||
{label: 'Ranobedb ID', controlName: 'ranobedbId', lockedKey: 'ranobedbIdLocked', fetchedKey: 'ranobedbId'},
|
||||
{label: 'Ranobedb ★', controlName: 'ranobedbRating', lockedKey: 'ranobedbRatingLocked', fetchedKey: 'ranobedbRating'},
|
||||
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
|
||||
];
|
||||
|
||||
@@ -129,12 +131,12 @@ export class BookdropFileMetadataPickerComponent {
|
||||
const [value, original] = this.prepFieldComparison(this.metadataForm.get(field)?.value, this.originalMetadata?.[field]);
|
||||
return (value && value != original) || (!value && original);
|
||||
}
|
||||
|
||||
|
||||
isFetchedDifferent(field: string): boolean {
|
||||
const [value, fetched] = this.prepFieldComparison(this.metadataForm.get(field)?.value, this.fetchedMetadata[field]);
|
||||
return (fetched && fetched != value);
|
||||
}
|
||||
|
||||
|
||||
private prepFieldComparison(field1: any, field2: any) {
|
||||
if (Array.isArray(field1)) {
|
||||
field1 = field1.length > 0 ? JSON.stringify(field1.sort()) : undefined;
|
||||
@@ -216,6 +218,8 @@ export class BookdropFileMetadataPickerComponent {
|
||||
hardcoverReviewCount: this.originalMetadata.hardcoverReviewCount || null,
|
||||
googleId: this.originalMetadata.googleId || null,
|
||||
comicvineId: this.originalMetadata.comicvineId || null,
|
||||
ranobedbId: this.originalMetadata.ranobedbId || null,
|
||||
ranobedbRating: this.originalMetadata.ranobedbRating || null,
|
||||
seriesName: this.originalMetadata.seriesName || null,
|
||||
seriesNumber: this.originalMetadata.seriesNumber || null,
|
||||
seriesTotal: this.originalMetadata.seriesTotal || null,
|
||||
|
||||
+10
-6
@@ -324,6 +324,8 @@ export class BookdropFileReviewComponent implements OnInit {
|
||||
hardcoverReviewCount: original?.hardcoverReviewCount ?? null,
|
||||
googleId: original?.googleId ?? null,
|
||||
comicvineId: original?.comicvineId ?? null,
|
||||
ranobedbId: original?.ranobedbId ?? null,
|
||||
ranobedbRating: original?.ranobedbRating ?? null,
|
||||
seriesName: original?.seriesName ?? null,
|
||||
seriesNumber: original?.seriesNumber ?? null,
|
||||
seriesTotal: original?.seriesTotal ?? null,
|
||||
@@ -571,6 +573,8 @@ export class BookdropFileReviewComponent implements OnInit {
|
||||
hardcoverBookId: new FormControl(original?.hardcoverBookId ?? ''),
|
||||
hardcoverRating: new FormControl(original?.hardcoverRating ?? ''),
|
||||
hardcoverReviewCount: new FormControl(original?.hardcoverReviewCount ?? ''),
|
||||
ranobedbId: new FormControl(original?.ranobedbId ?? ''),
|
||||
ranobedbRating: new FormControl(original?.ranobedbRating ?? ''),
|
||||
googleId: new FormControl(original?.googleId ?? ''),
|
||||
comicvineId: new FormControl(original?.comicvineId ?? ''),
|
||||
seriesName: new FormControl(original?.seriesName ?? ''),
|
||||
@@ -617,10 +621,10 @@ export class BookdropFileReviewComponent implements OnInit {
|
||||
|
||||
openBulkEditDialog(): void {
|
||||
const selectedFiles = this.getSelectedFiles();
|
||||
const totalCount = this.selectAllAcrossPages
|
||||
? this.totalRecords - this.excludedFiles.size
|
||||
const totalCount = this.selectAllAcrossPages
|
||||
? this.totalRecords - this.excludedFiles.size
|
||||
: selectedFiles.length;
|
||||
|
||||
|
||||
if (totalCount === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
@@ -647,10 +651,10 @@ export class BookdropFileReviewComponent implements OnInit {
|
||||
|
||||
openPatternExtractDialog(): void {
|
||||
const selectedFiles = this.getSelectedFiles();
|
||||
const totalCount = this.selectAllAcrossPages
|
||||
? this.totalRecords - this.excludedFiles.size
|
||||
const totalCount = this.selectAllAcrossPages
|
||||
? this.totalRecords - this.excludedFiles.size
|
||||
: selectedFiles.length;
|
||||
|
||||
|
||||
if (totalCount === 0) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
|
||||
@@ -60,6 +60,7 @@ export type RuleField =
|
||||
| 'goodreadsReviewCount'
|
||||
| 'hardcoverRating'
|
||||
| 'hardcoverReviewCount'
|
||||
| 'ranobedbRating'
|
||||
| 'personalRating'
|
||||
| 'fileType'
|
||||
| 'fileSize'
|
||||
@@ -142,7 +143,8 @@ const FIELD_CONFIGS: Record<RuleField, FullFieldConfig> = {
|
||||
goodreadsRating: {label: 'Goodreads Rating', type: 'decimal', max: 5},
|
||||
goodreadsReviewCount: {label: 'Goodreads Review Count', type: 'number'},
|
||||
hardcoverRating: {label: 'Hardcover Rating', type: 'decimal', max: 5},
|
||||
hardcoverReviewCount: {label: 'Hardcover Review Count', type: 'number'}
|
||||
hardcoverReviewCount: {label: 'Hardcover Review Count', type: 'number'},
|
||||
ranobedbRating: {label: 'Ranobedb Rating', type: 'decimal', max: 5}
|
||||
};
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {Book} from '../../book/model/book.model';
|
||||
import {GroupRule, Rule, RuleField} from '../component/magic-shelf-component';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Book } from '../../book/model/book.model';
|
||||
import { GroupRule, Rule, RuleField } from '../component/magic-shelf-component';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class BookRuleEvaluatorService {
|
||||
|
||||
evaluateGroup(book: Book, group: GroupRule): boolean {
|
||||
@@ -252,6 +252,8 @@ export class BookRuleEvaluatorService {
|
||||
return book.metadata?.hardcoverRating;
|
||||
case 'hardcoverReviewCount':
|
||||
return book.metadata?.hardcoverReviewCount;
|
||||
case 'ranobedbRating':
|
||||
return book.metadata?.ranobedbRating;
|
||||
default:
|
||||
return (book as Record<string, unknown>)[field];
|
||||
}
|
||||
|
||||
+27
@@ -507,6 +507,9 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col md:flex-row w-full gap-4 mt-2 pb-1">
|
||||
<div class="field-group metadata-id-field">
|
||||
<label for="lubimyczytacId">LC ID</label>
|
||||
<div class="field-with-lock">
|
||||
@@ -543,6 +546,30 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label class="text-sm" for="ranobedbId">Ranobedb ID</label>
|
||||
<div class="flex withbutton">
|
||||
<input pSize="small" pInputText id="ranobedbId" formControlName="ranobedbId" class="w-full"/>
|
||||
@if (!book.metadata!['ranobedbIdLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['ranobedbIdLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 md:w-1/6">
|
||||
<label class="text-sm" for="ranobedbRating">Ranobedb ★</label>
|
||||
<div class="flex withbutton">
|
||||
<input pSize="small" pInputText id="ranobedbRating" formControlName="ranobedbRating" class="w-full"/>
|
||||
@if (!book.metadata!['ranobedbRatingLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['ranobedbRatingLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('ranobedbRating')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="description-section">
|
||||
|
||||
+17
@@ -169,6 +169,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverReviewCount: new FormControl(""),
|
||||
lubimyczytacId: new FormControl(""),
|
||||
lubimyczytacRating: new FormControl(""),
|
||||
ranobedbId: new FormControl(""),
|
||||
ranobedbRating: new FormControl(""),
|
||||
googleId: new FormControl(""),
|
||||
seriesName: new FormControl(""),
|
||||
seriesNumber: new FormControl(""),
|
||||
@@ -201,6 +203,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverReviewCountLocked: new FormControl(false),
|
||||
lubimyczytacIdLocked: new FormControl(false),
|
||||
lubimyczytacRatingLocked: new FormControl(false),
|
||||
ranobedbIdLocked: new FormControl(""),
|
||||
ranobedbRatingLocked: new FormControl(false),
|
||||
googleIdLocked: new FormControl(false),
|
||||
seriesNameLocked: new FormControl(false),
|
||||
seriesNumberLocked: new FormControl(false),
|
||||
@@ -303,6 +307,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverReviewCount: metadata.hardcoverReviewCount ?? null,
|
||||
lubimyczytacId: metadata.lubimyczytacId ?? null,
|
||||
lubimyczytacRating: metadata.lubimyczytacRating ?? null,
|
||||
ranobedbId: metadata.ranobedbId ?? null,
|
||||
ranobedbRating: metadata.ranobedbRating ?? null,
|
||||
googleId: metadata.googleId ?? null,
|
||||
seriesName: metadata.seriesName ?? null,
|
||||
seriesNumber: metadata.seriesNumber ?? null,
|
||||
@@ -333,6 +339,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked ?? false,
|
||||
lubimyczytacIdLocked: metadata.lubimyczytacIdLocked ?? false,
|
||||
lubimyczytacRatingLocked: metadata.lubimyczytacRatingLocked ?? false,
|
||||
ranobedbIdLocked: metadata.ranobedbIdLocked ?? false,
|
||||
ranobedbRatingLocked: metadata.ranobedbRatingLocked ?? false,
|
||||
googleIdLocked: metadata.googleIdLocked ?? false,
|
||||
seriesNameLocked: metadata.seriesNameLocked ?? false,
|
||||
seriesNumberLocked: metadata.seriesNumberLocked ?? false,
|
||||
@@ -366,6 +374,9 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: "hardcoverRatingLocked", control: "hardcoverRating"},
|
||||
{key: "lubimyczytacIdLocked", control: "lubimyczytacId"},
|
||||
{key: "lubimyczytacRatingLocked", control: "lubimyczytacRating"},
|
||||
{key: "ranobedbReviewCountLocked", control: "ranobedbReviewCount"},
|
||||
{key: "ranobedbIdLocked", control: "ranobedbId"},
|
||||
{key: "ranobedbRatingLocked", control: "ranobedbRating"},
|
||||
{key: "googleIdLocked", control: "googleId"},
|
||||
{key: "pageCountLocked", control: "pageCount"},
|
||||
{key: "descriptionLocked", control: "description"},
|
||||
@@ -507,6 +518,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverReviewCount: form.get("hardcoverReviewCount")?.value,
|
||||
lubimyczytacId: form.get("lubimyczytacId")?.value,
|
||||
lubimyczytacRating: form.get("lubimyczytacRating")?.value,
|
||||
ranobedbId: form.get("ranobedbId")?.value,
|
||||
ranobedbRating: form.get("ranobedbRating")?.value,
|
||||
googleId: form.get("googleId")?.value,
|
||||
language: form.get("language")?.value,
|
||||
seriesName: form.get("seriesName")?.value,
|
||||
@@ -541,6 +554,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverReviewCountLocked: form.get("hardcoverReviewCountLocked")?.value,
|
||||
lubimyczytacIdLocked: form.get("lubimyczytacIdLocked")?.value,
|
||||
lubimyczytacRatingLocked: form.get("lubimyczytacRatingLocked")?.value,
|
||||
ranobedbIdLocked: form.get("ranobedbIdLocked")?.value,
|
||||
ranobedbRatingLocked: form.get("ranobedbRatingLocked")?.value,
|
||||
googleIdLocked: form.get("googleIdLocked")?.value,
|
||||
seriesNameLocked: form.get("seriesNameLocked")?.value,
|
||||
seriesNumberLocked: form.get("seriesNumberLocked")?.value,
|
||||
@@ -589,6 +604,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
hardcoverId: wasCleared("hardcoverId"),
|
||||
hardcoverRating: wasCleared("hardcoverRating"),
|
||||
hardcoverReviewCount: wasCleared("hardcoverReviewCount"),
|
||||
ranobedbId: wasCleared("ranobedbId"),
|
||||
ranobedbRating: wasCleared("ranobedbRating"),
|
||||
googleId: wasCleared("googleId"),
|
||||
seriesName: wasCleared("seriesName"),
|
||||
seriesNumber: wasCleared("seriesNumber"),
|
||||
|
||||
+18
@@ -79,6 +79,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
{label: 'HC Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
|
||||
{label: 'LC ID', controlName: 'lubimyczytacId', lockedKey: 'lubimyczytacIdLocked', fetchedKey: 'lubimyczytacId'},
|
||||
{label: 'LC Rating', controlName: 'lubimyczytacRating', lockedKey: 'lubimyczytacRatingLocked', fetchedKey: 'lubimyczytacRating'},
|
||||
{label: 'Ranobedb ID', controlName: 'ranobedbId', lockedKey: 'ranobedbIdLocked', fetchedKey: 'ranobedbId'},
|
||||
{label: 'RD Rating', controlName: 'ranobedbRating', lockedKey: 'ranobedbRatingLocked', fetchedKey: 'ranobedbRating'},
|
||||
{label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleId'},
|
||||
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
|
||||
];
|
||||
@@ -158,6 +160,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCount: new FormControl(''),
|
||||
lubimyczytacId: new FormControl(''),
|
||||
lubimyczytacRating: new FormControl(''),
|
||||
ranobedbId: new FormControl(''),
|
||||
ranobedbRating: new FormControl(''),
|
||||
googleId: new FormControl(''),
|
||||
seriesName: new FormControl(''),
|
||||
seriesNumber: new FormControl(''),
|
||||
@@ -190,6 +194,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCountLocked: new FormControl(false),
|
||||
lubimyczytacIdLocked: new FormControl(false),
|
||||
lubimyczytacRatingLocked: new FormControl(false),
|
||||
ranobedbIdLocked: new FormControl(false),
|
||||
ranobedbRatingLocked: new FormControl(false),
|
||||
googleIdLocked: new FormControl(false),
|
||||
seriesNameLocked: new FormControl(false),
|
||||
seriesNumberLocked: new FormControl(false),
|
||||
@@ -269,6 +275,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCount: metadata.hardcoverReviewCount || null,
|
||||
lubimyczytacId: metadata.lubimyczytacId || null,
|
||||
lubimyczytacRating: metadata.lubimyczytacRating || null,
|
||||
ranobedbId: metadata.ranobedbId || null,
|
||||
ranobedbRating: metadata.ranobedbRating || null,
|
||||
googleId: metadata.googleId || null,
|
||||
seriesName: metadata.seriesName || null,
|
||||
seriesNumber: metadata.seriesNumber || null,
|
||||
@@ -301,6 +309,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCountLocked: metadata.hardcoverReviewCountLocked || false,
|
||||
lubimyczytacIdLocked: metadata.lubimyczytacIdLocked || false,
|
||||
lubimyczytacRatingLocked: metadata.lubimyczytacRatingLocked || false,
|
||||
ranobedbIdLocked: metadata.ranobedbIdLocked || false,
|
||||
ranobedbRatingLocked: metadata.ranobedbRatingLocked || false,
|
||||
googleIdLocked: metadata.googleIdLocked || false,
|
||||
seriesNameLocked: metadata.seriesNameLocked || false,
|
||||
seriesNumberLocked: metadata.seriesNumberLocked || false,
|
||||
@@ -340,6 +350,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
if (metadata.hardcoverRatingLocked) this.metadataForm.get('hardcoverRating')?.disable({emitEvent: false});
|
||||
if (metadata.lubimyczytacIdLocked) this.metadataForm.get('lubimyczytacId')?.disable({emitEvent: false});
|
||||
if (metadata.lubimyczytacRatingLocked) this.metadataForm.get('lubimyczytacRating')?.disable({emitEvent: false});
|
||||
if (metadata.ranobedbIdLocked) this.metadataForm.get('ranobedbId')?.disable({emitEvent: false});
|
||||
if (metadata.ranobedbRatingLocked) this.metadataForm.get('ranobedbRating')?.disable({emitEvent: false});
|
||||
if (metadata.googleIdLocked) this.metadataForm.get('googleId')?.disable({emitEvent: false});
|
||||
if (metadata.pageCountLocked) this.metadataForm.get('pageCount')?.disable({emitEvent: false});
|
||||
if (metadata.descriptionLocked) this.metadataForm.get('description')?.disable({emitEvent: false});
|
||||
@@ -421,6 +433,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCount: this.metadataForm.get('hardcoverReviewCount')?.value || this.copiedFields['hardcoverReviewCount'] ? this.getNumberOrCopied('hardcoverReviewCount') : null,
|
||||
lubimyczytacId: this.metadataForm.get('lubimyczytacId')?.value || this.copiedFields['lubimyczytacId'] ? this.getValueOrCopied('lubimyczytacId') : '',
|
||||
lubimyczytacRating: this.metadataForm.get('lubimyczytacRating')?.value || this.copiedFields['lubimyczytacRating'] ? this.getNumberOrCopied('lubimyczytacRating') : null,
|
||||
ranobedbId: this.metadataForm.get('ranobedbId')?.value || this.copiedFields['ranobedbId'] ? this.getValueOrCopied('ranobedbId') : '',
|
||||
ranobedbRating: this.metadataForm.get('ranobedbRating')?.value || this.copiedFields['ranobedbRating'] ? this.getNumberOrCopied('ranobedbRating') : null,
|
||||
googleId: this.metadataForm.get('googleId')?.value || this.copiedFields['googleId'] ? this.getValueOrCopied('googleId') : '',
|
||||
seriesName: this.metadataForm.get('seriesName')?.value || this.copiedFields['seriesName'] ? this.getValueOrCopied('seriesName') : '',
|
||||
seriesNumber: this.metadataForm.get('seriesNumber')?.value || this.copiedFields['seriesNumber'] ? this.getNumberOrCopied('seriesNumber') : null,
|
||||
@@ -453,6 +467,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCountLocked: this.metadataForm.get('hardcoverReviewCountLocked')?.value,
|
||||
lubimyczytacIdLocked: this.metadataForm.get('lubimyczytacIdLocked')?.value,
|
||||
lubimyczytacRatingLocked: this.metadataForm.get('lubimyczytacRatingLocked')?.value,
|
||||
ranobedbIdLocked: this.metadataForm.get('ranobedbIdLocked')?.value,
|
||||
ranobedbRatingLocked: this.metadataForm.get('ranobedbRatingLocked')?.value,
|
||||
googleIdLocked: this.metadataForm.get('googleIdLocked')?.value,
|
||||
seriesNameLocked: this.metadataForm.get('seriesNameLocked')?.value,
|
||||
seriesNumberLocked: this.metadataForm.get('seriesNumberLocked')?.value,
|
||||
@@ -498,6 +514,8 @@ export class MetadataPickerComponent implements OnInit {
|
||||
hardcoverReviewCount: current.hardcoverReviewCount === null && original.hardcoverReviewCount !== null,
|
||||
lubimyczytacId: !current.lubimyczytacId && !!original.lubimyczytacId,
|
||||
lubimyczytacRating: current.lubimyczytacRating === null && original.lubimyczytacRating !== null,
|
||||
ranobedbId: !current.ranobedbId && !!original.ranobedbId,
|
||||
ranobedbRating: current.ranobedbRating === null && original.ranobedbRating !== null,
|
||||
googleId: !current.googleId && !!original.googleId,
|
||||
seriesName: !current.seriesName && !!original.seriesName,
|
||||
seriesNumber: current.seriesNumber === null && original.seriesNumber !== null,
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@ $provider-colors: (
|
||||
'hardcover': #6366F1,
|
||||
'douban': #1474E9,
|
||||
'lubimyczytac': #FF5501,
|
||||
'comicvine': #F9E04F
|
||||
'comicvine': #F9E04F,
|
||||
'ranobedb': #06b6d4
|
||||
);
|
||||
|
||||
.metadata-container {
|
||||
|
||||
+3
@@ -252,6 +252,7 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
if (metadata['doubanId']) return 'douban';
|
||||
if (metadata['lubimyczytacId']) return 'lubimyczytac';
|
||||
if (metadata.comicvineId) return 'comicvine';
|
||||
if (metadata.ranobedbId) return 'ranobedb';
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -362,6 +363,8 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
const name = metadata.seriesName;
|
||||
return `<a href="https://comicvine.gamespot.com/volume/${metadata.comicvineId}" target="_blank">Comicvine</a>`;
|
||||
} else if (metadata.ranobedbId) {
|
||||
return `<a href="https://ranobedb.org/book/${metadata.ranobedbId}" target="_blank">RanobeDB</a>`;
|
||||
}
|
||||
throw new Error("No provider ID found in metadata.");
|
||||
}
|
||||
|
||||
+15
-1
@@ -154,7 +154,7 @@
|
||||
</p-button>
|
||||
</div>
|
||||
|
||||
@if (book?.metadata?.amazonRating || book?.metadata?.goodreadsRating || book?.metadata?.hardcoverRating || book?.metadata?.lubimyczytacRating || book?.metadata?.googleId) {
|
||||
@if (book?.metadata?.amazonRating || book?.metadata?.goodreadsRating || book?.metadata?.hardcoverRating || book?.metadata?.lubimyczytacRating || book?.metadata?.ranobedbRating || book?.metadata?.googleId) {
|
||||
<div class="gradient-divider"></div>
|
||||
}
|
||||
|
||||
@@ -215,6 +215,20 @@
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (book?.metadata?.ranobedbRating) {
|
||||
<a
|
||||
class="rating-link"
|
||||
[href]="'https://ranobedb.org/book/' + (book.metadata?.ranobedbId ?? '')"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
[pTooltip]="getRatingTooltip(book, 'ranobedb')"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<img src="https://www.ranobedb.org/favicon.png" alt="Ranobedb" class="rating-favicon"/>
|
||||
<span class="rating-value">{{ getRatingPercent(book.metadata!.ranobedbRating) }}%</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (book?.metadata?.googleId) {
|
||||
<a
|
||||
class="rating-link"
|
||||
|
||||
+5
-1
@@ -809,7 +809,7 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
return p != null ? Math.round(p * 10) / 10 : null;
|
||||
}
|
||||
|
||||
getRatingTooltip(book: Book, source: 'amazon' | 'goodreads' | 'hardcover' | 'lubimyczytac'): string {
|
||||
getRatingTooltip(book: Book, source: 'amazon' | 'goodreads' | 'hardcover' | 'lubimyczytac' | 'ranobedb'): string {
|
||||
const meta = book?.metadata;
|
||||
if (!meta) return '';
|
||||
|
||||
@@ -830,6 +830,10 @@ export class MetadataViewerComponent implements OnInit, OnChanges {
|
||||
return meta.lubimyczytacRating != null
|
||||
? `★ ${meta.lubimyczytacRating}`
|
||||
: '';
|
||||
case 'ranobedb':
|
||||
return meta.ranobedbRating != null
|
||||
? `★ ${meta.ranobedbRating}`
|
||||
: '';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
+10
-8
@@ -25,16 +25,16 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'title', 'subtitle', 'description', 'authors', 'publisher', 'publishedDate',
|
||||
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10',
|
||||
'language', 'categories', 'cover', 'pageCount',
|
||||
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId',
|
||||
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId', 'ranobedbId',
|
||||
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating', 'ranobedbRating',
|
||||
'moods', 'tags'
|
||||
];
|
||||
|
||||
providerSpecificFields: (keyof FieldOptions)[] = [
|
||||
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId',
|
||||
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId', 'ranobedbId',
|
||||
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating', 'ranobedbRating',
|
||||
'moods', 'tags'
|
||||
];
|
||||
|
||||
@@ -44,8 +44,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'language', 'categories', 'cover', 'pageCount',
|
||||
];
|
||||
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac'];
|
||||
providersWithClear: string[] = ['Clear All', 'Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac'];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb'];
|
||||
providersWithClear: string[] = ['Clear All', 'Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine', 'Douban', 'Lubimyczytac', 'Ranobedb'];
|
||||
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
@@ -64,9 +64,9 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
private justSubmitted = false;
|
||||
|
||||
private providerSpecificFieldsList = [
|
||||
'asin', 'goodreadsId', 'comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId',
|
||||
'asin', 'goodreadsId','comicvineId', 'hardcoverId', 'googleId', 'lubimyczytacId', 'ranobedbId',
|
||||
'amazonRating', 'amazonReviewCount', 'goodreadsRating', 'goodreadsReviewCount',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating',
|
||||
'hardcoverRating', 'hardcoverReviewCount', 'lubimyczytacRating', 'ranobedbRating',
|
||||
'moods', 'tags'
|
||||
];
|
||||
|
||||
@@ -233,6 +233,8 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'hardcoverReviewCount': 'Hardcover Review Count',
|
||||
'lubimyczytacId': 'LC ID',
|
||||
'lubimyczytacRating': 'Lubimyczytac Rating',
|
||||
'ranobedbId': 'Ranobedb ID',
|
||||
'ranobedbRating': 'Ranobedb Rating',
|
||||
'moods': 'Moods (Hardcover)',
|
||||
'tags': 'Tags (Hardcover)'
|
||||
};
|
||||
|
||||
@@ -43,6 +43,8 @@ export interface FieldOptions {
|
||||
hardcoverRating: FieldProvider;
|
||||
hardcoverReviewCount: FieldProvider;
|
||||
lubimyczytacRating: FieldProvider;
|
||||
ranobedbId: FieldProvider;
|
||||
ranobedbRating: FieldProvider;
|
||||
moods: FieldProvider;
|
||||
tags: FieldProvider;
|
||||
}
|
||||
|
||||
+3
-1
@@ -44,7 +44,8 @@ export class MetadataMatchWeightsComponent implements OnInit {
|
||||
goodreadsRating: 'Goodreads Rating',
|
||||
goodreadsReviewCount: 'Goodreads Rating #',
|
||||
hardcoverRating: 'Hardcover Rating',
|
||||
hardcoverReviewCount: 'Hardcover Rating #'
|
||||
hardcoverReviewCount: 'Hardcover Rating #',
|
||||
ranobedbRating: 'Ranobedb Rating',
|
||||
};
|
||||
|
||||
form!: FormGroup;
|
||||
@@ -79,6 +80,7 @@ export class MetadataMatchWeightsComponent implements OnInit {
|
||||
goodreadsReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
hardcoverRating: [0, [Validators.required, Validators.min(0)]],
|
||||
hardcoverReviewCount: [0, [Validators.required, Validators.min(0)]],
|
||||
ranobedbRating: [0, [Validators.required, Validators.min(0)]],
|
||||
coverImage: [0, [Validators.required, Validators.min(0)]],
|
||||
});
|
||||
this.appSettings$
|
||||
|
||||
+9
@@ -154,6 +154,15 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="provider-item">
|
||||
<div class="provider-control">
|
||||
<div class="provider-info">
|
||||
<p-checkbox [(ngModel)]="ranobedbEnabled" [binary]="true"></p-checkbox>
|
||||
<label class="provider-label">Ranobedb</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-actions">
|
||||
|
||||
+4
-1
@@ -77,6 +77,7 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
comicvineToken: string = '';
|
||||
doubanEnabled: boolean = false;
|
||||
lubimyCzytacEnabled: boolean = false;
|
||||
ranobedbEnabled: boolean = false;
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
@@ -103,6 +104,7 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
this.comicvineToken = metadataProviderSettings?.comicvine?.apiKey ?? '';
|
||||
this.doubanEnabled = metadataProviderSettings?.douban?.enabled ?? false;
|
||||
this.lubimyCzytacEnabled = metadataProviderSettings?.lubimyczytac?.enabled ?? false;
|
||||
this.ranobedbEnabled = metadataProviderSettings?.ranobedb?.enabled ?? false;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -146,7 +148,8 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
apiKey: this.hardcoverToken.trim()
|
||||
},
|
||||
douban: {enabled: this.doubanEnabled},
|
||||
lubimyczytac: {enabled: this.lubimyCzytacEnabled}
|
||||
lubimyczytac: {enabled: this.lubimyCzytacEnabled},
|
||||
ranobedb: {enabled: this.ranobedbEnabled}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
+2
@@ -217,6 +217,8 @@ export class LibraryMetadataSettingsComponent implements OnInit {
|
||||
hardcoverReviewCount: {p1: null, p2: null, p3: null, p4: null},
|
||||
lubimyczytacId: {p1: null, p2: null, p3: null, p4: null},
|
||||
lubimyczytacRating: {p1: null, p2: null, p3: null, p4: null},
|
||||
ranobedbId: {p1: null, p2: null, p3: null, p4: null},
|
||||
ranobedbRating: {p1: null, p2: null, p3: null, p4: null},
|
||||
moods: {p1: null, p2: null, p3: null, p4: null},
|
||||
tags: {p1: null, p2: null, p3: null, p4: null}
|
||||
}
|
||||
|
||||
+1
@@ -47,6 +47,7 @@ export class ViewPreferencesComponent implements OnInit, OnDestroy {
|
||||
{label: 'Goodreads #', field: 'goodreadsReviewCount'},
|
||||
{label: 'Hardcover Rating', field: 'hardcoverRating'},
|
||||
{label: 'Hardcover #', field: 'hardcoverReviewCount'},
|
||||
{label: 'Ranobedb Rating', field: 'ranobedbRating'},
|
||||
{label: 'Pages', field: 'pageCount'},
|
||||
{label: 'Random', field: 'random'},
|
||||
];
|
||||
|
||||
@@ -280,6 +280,7 @@ export class AuthorPopularityChartService implements OnDestroy {
|
||||
if (book.metadata?.goodreadsRating) ratings.push(book.metadata.goodreadsRating);
|
||||
if (book.metadata?.amazonRating) ratings.push(book.metadata.amazonRating);
|
||||
if (book.metadata?.hardcoverRating) ratings.push(book.metadata.hardcoverRating);
|
||||
if (book.metadata?.ranobedbRating) ratings.push(book.metadata.ranobedbRating);
|
||||
if (book.personalRating) ratings.push(book.personalRating);
|
||||
|
||||
if (ratings.length > 0) {
|
||||
|
||||
@@ -247,6 +247,7 @@ export class BookRatingChartService implements OnDestroy {
|
||||
if (book.metadata?.goodreadsRating) ratings.push(book.metadata.goodreadsRating);
|
||||
if (book.metadata?.amazonRating) ratings.push(book.metadata.amazonRating);
|
||||
if (book.metadata?.hardcoverRating) ratings.push(book.metadata.hardcoverRating);
|
||||
if (book.metadata?.ranobedbRating) ratings.push(book.metadata.ranobedbRating);
|
||||
|
||||
if (ratings.length > 0) {
|
||||
return ratings.reduce((sum, rating) => sum + rating, 0) / ratings.length;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {MetadataRefreshOptions} from '../../features/metadata/model/request/metadata-refresh-options.model';
|
||||
import { MetadataRefreshOptions } from '../../features/metadata/model/request/metadata-refresh-options.model';
|
||||
|
||||
export interface MetadataMatchWeights {
|
||||
title: number;
|
||||
@@ -24,6 +24,7 @@ export interface MetadataMatchWeights {
|
||||
doubanRating: number;
|
||||
doubanReviewCount: number;
|
||||
lubimyczytacRating: number;
|
||||
ranobedbRating: number;
|
||||
coverImage: number;
|
||||
}
|
||||
|
||||
@@ -48,6 +49,7 @@ export interface MetadataProviderSettings {
|
||||
amazon: Amazon;
|
||||
google: Google;
|
||||
goodReads: Goodreads;
|
||||
ranobedb: Ranobedb;
|
||||
hardcover: Hardcover;
|
||||
comicvine: Comicvine;
|
||||
douban: Douban;
|
||||
@@ -69,6 +71,10 @@ export interface Goodreads {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface Ranobedb {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
export interface Hardcover {
|
||||
enabled: boolean;
|
||||
apiKey: string;
|
||||
|
||||
@@ -47,7 +47,8 @@ describe('AppSettingsService', () => {
|
||||
hardcover: {enabled: false, apiKey: ''},
|
||||
comicvine: {enabled: false, apiKey: ''},
|
||||
douban: {enabled: false},
|
||||
lubimyczytac: {enabled: false}
|
||||
lubimyczytac: {enabled: false},
|
||||
ranobedb: {enabled: false}
|
||||
},
|
||||
metadataMatchWeights: {
|
||||
title: 0,
|
||||
@@ -73,6 +74,7 @@ describe('AppSettingsService', () => {
|
||||
doubanRating: 0,
|
||||
doubanReviewCount: 0,
|
||||
lubimyczytacRating: 0,
|
||||
ranobedbRating: 0,
|
||||
coverImage: 0
|
||||
},
|
||||
metadataPersistenceSettings: {
|
||||
@@ -398,7 +400,8 @@ describe('AppSettingsService - API Contract Tests', () => {
|
||||
hardcover: {enabled: false, apiKey: ''},
|
||||
comicvine: {enabled: false, apiKey: ''},
|
||||
douban: {enabled: false},
|
||||
lubimyczytac: {enabled: false}
|
||||
lubimyczytac: {enabled: false},
|
||||
ranobedb: {enabled: false}
|
||||
},
|
||||
metadataMatchWeights: {
|
||||
title: 0,
|
||||
@@ -424,6 +427,7 @@ describe('AppSettingsService - API Contract Tests', () => {
|
||||
doubanRating: 0,
|
||||
doubanReviewCount: 0,
|
||||
lubimyczytacRating: 0,
|
||||
ranobedbRating: 0,
|
||||
coverImage: 0
|
||||
},
|
||||
metadataPersistenceSettings: {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {inject, Injectable} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {Observable} from 'rxjs';
|
||||
import {API_CONFIG} from '../../core/config/api-config';
|
||||
import { inject, Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { API_CONFIG } from '../../core/config/api-config';
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class MetadataMatchWeightsService {
|
||||
private readonly baseUrl = `${API_CONFIG.BASE_URL}/api/v1`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user