Feature: Add Comicvine to metadata providers. (#804)
* added comcivine * updated comicvine schema * added comic vine support * changed SQL changes * fixed init provider bug * updated changes for Flyway migration. --------- Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com>
This commit is contained in:
co-authored by
Aditya Chandel
parent
e027225775
commit
46f86deb24
@@ -12,12 +12,13 @@ public class BookParserConfig {
|
||||
|
||||
@Bean
|
||||
public Map<MetadataProvider, BookParser> parserMap(GoogleParser googleParser, AmazonBookParser amazonBookParser,
|
||||
GoodReadsParser goodReadsParser, HardcoverParser hardcoverParser) {
|
||||
GoodReadsParser goodReadsParser, HardcoverParser hardcoverParser, ComicvineBookParser comicvineBookParser) {
|
||||
return Map.of(
|
||||
MetadataProvider.Amazon, amazonBookParser,
|
||||
MetadataProvider.GoodReads, goodReadsParser,
|
||||
MetadataProvider.Google, googleParser,
|
||||
MetadataProvider.Hardcover, hardcoverParser
|
||||
MetadataProvider.Hardcover, hardcoverParser,
|
||||
MetadataProvider.Comicvine, comicvineBookParser
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -20,6 +20,7 @@ public interface MetadataClearFlagsMapper {
|
||||
@Mapping(target = "isbn10", source = "clearIsbn10")
|
||||
@Mapping(target = "asin", source = "clearAsin")
|
||||
@Mapping(target = "goodreadsId", source = "clearGoodreadsId")
|
||||
@Mapping(target = "comicvineId", source = "clearComicvineId")
|
||||
@Mapping(target = "hardcoverId", source = "clearHardcoverId")
|
||||
@Mapping(target = "googleId", source = "clearGoogleId")
|
||||
@Mapping(target = "pageCount", source = "clearPageCount")
|
||||
|
||||
@@ -17,6 +17,7 @@ public class MetadataClearFlags {
|
||||
private boolean isbn10;
|
||||
private boolean asin;
|
||||
private boolean goodreadsId;
|
||||
private boolean comicvineId;
|
||||
private boolean hardcoverId;
|
||||
private boolean googleId;
|
||||
private boolean pageCount;
|
||||
|
||||
@@ -34,6 +34,7 @@ public class BookMetadata {
|
||||
private Double amazonRating;
|
||||
private Integer amazonReviewCount;
|
||||
private String goodreadsId;
|
||||
private String comicvineId;
|
||||
private Double goodreadsRating;
|
||||
private Integer goodreadsReviewCount;
|
||||
private String hardcoverId;
|
||||
@@ -59,6 +60,7 @@ public class BookMetadata {
|
||||
private Boolean isbn10Locked;
|
||||
private Boolean asinLocked;
|
||||
private Boolean goodreadsIdLocked;
|
||||
private Boolean comicvineIdLocked;
|
||||
private Boolean hardcoverIdLocked;
|
||||
private Boolean googleIdLocked;
|
||||
private Boolean pageCountLocked;
|
||||
|
||||
@@ -35,6 +35,7 @@ public class EpubMetadata {
|
||||
private Double amazonRating;
|
||||
private Integer amazonReviewCount;
|
||||
private String goodreadsId;
|
||||
private String comicvineId;
|
||||
private Double goodreadsRating;
|
||||
private Integer goodreadsReviewCount;
|
||||
private String hardcoverId;
|
||||
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package com.adityachandel.booklore.model.dto.response.comicvineapi;
|
||||
import java.time.LocalDate;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@JsonTypeInfo(
|
||||
use = JsonTypeInfo.Id.NAME,
|
||||
include = JsonTypeInfo.As.EXISTING_PROPERTY,
|
||||
|
||||
property = "resource_type",
|
||||
defaultImpl = Volume.class
|
||||
)
|
||||
|
||||
@JsonSubTypes({
|
||||
@JsonSubTypes.Type(value = Volume.class, name = "volume"),
|
||||
@JsonSubTypes.Type(value = Issue.class, name = "issue")
|
||||
})
|
||||
|
||||
public abstract class Comic {
|
||||
private int id;
|
||||
protected String name;
|
||||
protected ComicVineImage image;
|
||||
private String description;
|
||||
|
||||
@JsonProperty("concept_credits")
|
||||
private List<ComicvineItem> conceptCredits;
|
||||
|
||||
|
||||
@JsonProperty("person_credits")
|
||||
private List<ComicvineItem> personCredits;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@JsonProperty("resource_type")
|
||||
private String resourceType;
|
||||
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
public abstract String getComicId();
|
||||
|
||||
public abstract LocalDate getDate();
|
||||
|
||||
public Set<String> getAuthors() {
|
||||
Set<String> authors = new HashSet<>();
|
||||
if (personCredits != null) {
|
||||
for (ComicvineItem person : personCredits) {
|
||||
authors.add(person.name);
|
||||
}
|
||||
}
|
||||
return authors;
|
||||
}
|
||||
|
||||
public String getImageUrl() {
|
||||
if (image == null) {
|
||||
return null;
|
||||
}
|
||||
return image.getOriginalUrl() != null ? image.getOriginalUrl() : image.getThumbUrl();
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class ComicVineImage {
|
||||
@JsonProperty("icon_url")
|
||||
private String iconUrl;
|
||||
|
||||
@JsonProperty("medium_url")
|
||||
private String mediumUrl;
|
||||
|
||||
@JsonProperty("screen_url")
|
||||
private String screenUrl;
|
||||
|
||||
@JsonProperty("screen_large_url")
|
||||
private String screenLargeUrl;
|
||||
|
||||
@JsonProperty("small_url")
|
||||
private String smallUrl;
|
||||
|
||||
@JsonProperty("super_url")
|
||||
private String superUrl;
|
||||
|
||||
@JsonProperty("thumb_url")
|
||||
private String thumbUrl;
|
||||
|
||||
@JsonProperty("tiny_url")
|
||||
private String tinyUrl;
|
||||
|
||||
@JsonProperty("original_url")
|
||||
private String originalUrl;
|
||||
|
||||
@JsonProperty("image_tags")
|
||||
private String imageTags;
|
||||
}
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class ComicvineItem {
|
||||
@JsonProperty("api_detail_url")
|
||||
private String apiDetailUrl;
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package com.adityachandel.booklore.model.dto.response.comicvineapi;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class ComicvineApiResponse {
|
||||
private String error;
|
||||
private int limit;
|
||||
private int offset;
|
||||
|
||||
@JsonProperty("number_of_page_results")
|
||||
private int numberOfPageResults;
|
||||
|
||||
@JsonProperty("number_of_total_results")
|
||||
private int numberOfTotalResults;
|
||||
|
||||
@JsonProperty("status_code")
|
||||
private int statusCode;
|
||||
private List<Comic> results;
|
||||
private String version;
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.adityachandel.booklore.model.dto.response.comicvineapi;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Issue extends Comic {
|
||||
@JsonProperty("cover_date")
|
||||
private String coverDate;
|
||||
|
||||
@JsonProperty("volume")
|
||||
private ComicvineItem volume;
|
||||
|
||||
@JsonProperty("issue_number")
|
||||
private int issueNumber;
|
||||
|
||||
|
||||
@Override
|
||||
public String getComicId() {
|
||||
return "4000-" + String.valueOf(getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
if(name ==null){
|
||||
if(volume != null){
|
||||
return volume.getName() + " " + "Issue #" + String.valueOf(issueNumber);
|
||||
|
||||
}
|
||||
else{
|
||||
return "Unknown Comic";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getDate() {
|
||||
if (coverDate == null || coverDate.isEmpty()) return null;
|
||||
try {
|
||||
return LocalDate.parse(coverDate, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package com.adityachandel.booklore.model.dto.response.comicvineapi;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Volume extends Comic{
|
||||
@JsonProperty("api_detail_url")
|
||||
private String apiDetailUrl;
|
||||
|
||||
private String description;
|
||||
|
||||
@JsonProperty("publisher")
|
||||
private ComicvineItem publisher;
|
||||
|
||||
@JsonProperty("site_detail_url")
|
||||
private String siteDetailUrl;
|
||||
|
||||
@JsonProperty("start_year")
|
||||
private String startYear;
|
||||
|
||||
public String getPublisherName() {
|
||||
return publisher != null ? publisher.getName() : null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDisplayName(){
|
||||
if(name==null){
|
||||
return "Unknown Comic";
|
||||
}
|
||||
else{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComicId() {
|
||||
return "4500-" + String.valueOf(getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate getDate() {
|
||||
if (startYear == null || startYear.isEmpty()) return null;
|
||||
try {
|
||||
return LocalDate.parse(startYear, DateTimeFormatter.ofPattern("yyyy"));
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
@@ -8,6 +8,7 @@ public class MetadataProviderSettings {
|
||||
private Google google;
|
||||
private Goodreads goodReads;
|
||||
private Hardcover hardcover;
|
||||
private Comicvine comicvine;
|
||||
|
||||
@Data
|
||||
public static class Amazon {
|
||||
@@ -31,4 +32,9 @@ public class MetadataProviderSettings {
|
||||
private boolean enabled;
|
||||
private String apiKey;
|
||||
}
|
||||
@Data
|
||||
public static class Comicvine {
|
||||
private boolean enabled;
|
||||
private String apiKey;
|
||||
}
|
||||
}
|
||||
|
||||
+8
@@ -105,6 +105,9 @@ public class BookMetadataEntity {
|
||||
@Column(name = "google_id", length = 100)
|
||||
private String googleId;
|
||||
|
||||
@Column(name = "comicvine_id", length = 100)
|
||||
private String comicvineId;
|
||||
|
||||
// Locking fields
|
||||
|
||||
@Column(name = "title_locked")
|
||||
@@ -185,6 +188,9 @@ public class BookMetadataEntity {
|
||||
@Column(name = "google_id_locked")
|
||||
private Boolean googleIdLocked = Boolean.FALSE;
|
||||
|
||||
@Column(name = "comicvine_id_locked")
|
||||
private Boolean comicvineIdLocked = Boolean.FALSE;
|
||||
|
||||
@OneToOne(fetch = FetchType.LAZY)
|
||||
@MapsId
|
||||
@JoinColumn(name = "book_id")
|
||||
@@ -231,6 +237,7 @@ public class BookMetadataEntity {
|
||||
this.goodreadsReviewCountLocked = lock;
|
||||
this.hardcoverRatingLocked = lock;
|
||||
this.hardcoverReviewCountLocked = lock;
|
||||
this.comicvineIdLocked = lock;
|
||||
this.personalRatingLocked = lock;
|
||||
this.goodreadsIdLocked = lock;
|
||||
this.hardcoverIdLocked = lock;
|
||||
@@ -262,6 +269,7 @@ public class BookMetadataEntity {
|
||||
&& Boolean.TRUE.equals(this.hardcoverReviewCountLocked)
|
||||
&& Boolean.TRUE.equals(this.personalRatingLocked)
|
||||
&& Boolean.TRUE.equals(this.goodreadsIdLocked)
|
||||
&& Boolean.TRUE.equals(this.comicvineIdLocked)
|
||||
&& Boolean.TRUE.equals(this.hardcoverIdLocked)
|
||||
&& Boolean.TRUE.equals(this.googleIdLocked)
|
||||
;
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
package com.adityachandel.booklore.model.enums;
|
||||
|
||||
public enum MetadataProvider {
|
||||
Amazon, GoodReads, Google, Hardcover
|
||||
Amazon, GoodReads, Google, Hardcover, Comicvine
|
||||
}
|
||||
|
||||
+5
@@ -78,10 +78,15 @@ public class SettingPersistenceHelper {
|
||||
defaultHardcover.setEnabled(false);
|
||||
defaultHardcover.setApiKey(null);
|
||||
|
||||
MetadataProviderSettings.Comicvine defaultComicvine = new MetadataProviderSettings.Comicvine();
|
||||
defaultComicvine.setEnabled(false);
|
||||
defaultComicvine.setApiKey(null);
|
||||
|
||||
defaultMetadataProviderSettings.setAmazon(defaultAmazon);
|
||||
defaultMetadataProviderSettings.setGoogle(defaultGoogle);
|
||||
defaultMetadataProviderSettings.setGoodReads(defaultGoodreads);
|
||||
defaultMetadataProviderSettings.setHardcover(defaultHardcover);
|
||||
defaultMetadataProviderSettings.setComicvine(defaultComicvine);
|
||||
|
||||
return defaultMetadataProviderSettings;
|
||||
}
|
||||
|
||||
+1
@@ -131,6 +131,7 @@ public class EpubProcessor extends AbstractFileProcessor implements BookFileProc
|
||||
metadata.setHardcoverRating(epubMetadata.getHardcoverRating());
|
||||
metadata.setHardcoverReviewCount(epubMetadata.getHardcoverReviewCount());
|
||||
metadata.setGoogleId(truncate(epubMetadata.getGoogleId(), 100));
|
||||
metadata.setComicvineId(truncate(epubMetadata.getComicvineId(), 100));
|
||||
|
||||
bookCreatorService.addAuthorsToBook(epubMetadata.getAuthors(), bookEntity);
|
||||
|
||||
|
||||
+3
@@ -114,6 +114,9 @@ public class PdfProcessor extends AbstractFileProcessor implements BookFileProce
|
||||
if (StringUtils.isNotBlank(extracted.getGoodreadsId())) {
|
||||
bookEntity.getMetadata().setGoodreadsId(extracted.getGoodreadsId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(extracted.getComicvineId())){
|
||||
bookEntity.getMetadata().setComicvineId(extracted.getComicvineId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(extracted.getIsbn10())) {
|
||||
bookEntity.getMetadata().setIsbn10(extracted.getIsbn10());
|
||||
}
|
||||
|
||||
+2
@@ -138,6 +138,7 @@ public class BookMetadataUpdater {
|
||||
handleFieldUpdate(e.getIsbn10Locked(), clear.isIsbn10(), m.getIsbn10(), v -> e.setIsbn10(nullIfBlank(v)));
|
||||
handleFieldUpdate(e.getAsinLocked(), clear.isAsin(), m.getAsin(), v -> e.setAsin(nullIfBlank(v)));
|
||||
handleFieldUpdate(e.getGoodreadsIdLocked(), clear.isGoodreadsId(), m.getGoodreadsId(), v -> e.setGoodreadsId(nullIfBlank(v)));
|
||||
handleFieldUpdate(e.getComicvineIdLocked(), clear.isComicvineId(), m.getComicvineId(), v -> e.setComicvineId(nullIfBlank(v)));
|
||||
handleFieldUpdate(e.getHardcoverIdLocked(), clear.isHardcoverId(), m.getHardcoverId(), v -> e.setHardcoverId(nullIfBlank(v)));
|
||||
handleFieldUpdate(e.getGoogleIdLocked(), clear.isGoogleId(), m.getGoogleId(), v -> e.setGoogleId(nullIfBlank(v)));
|
||||
handleFieldUpdate(e.getPageCountLocked(), clear.isPageCount(), m.getPageCount(), e::setPageCount);
|
||||
@@ -227,6 +228,7 @@ public class BookMetadataUpdater {
|
||||
Pair.of(m.getIsbn10Locked(), e::setIsbn10Locked),
|
||||
Pair.of(m.getAsinLocked(), e::setAsinLocked),
|
||||
Pair.of(m.getGoodreadsIdLocked(), e::setGoodreadsIdLocked),
|
||||
Pair.of(m.getComicvineIdLocked(), e::setComicvineIdLocked),
|
||||
Pair.of(m.getHardcoverIdLocked(), e::setHardcoverIdLocked),
|
||||
Pair.of(m.getGoogleIdLocked(), e::setGoogleIdLocked),
|
||||
Pair.of(m.getPageCountLocked(), e::setPageCountLocked),
|
||||
|
||||
+5
@@ -309,6 +309,11 @@ public class MetadataRefreshService {
|
||||
if (metadataMap.containsKey(Google)) {
|
||||
metadata.setGoogleId(metadataMap.get(Google).getGoogleId());
|
||||
}
|
||||
if (metadataMap.containsKey(Comicvine)){
|
||||
metadata.setComicvineId(metadataMap.get(Comicvine).getComicvineId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (request.getRefreshOptions().isMergeCategories()) {
|
||||
metadata.setCategories(getAllCategories(metadataMap, fieldOptions.getCategories(), BookMetadata::getCategories));
|
||||
|
||||
+1
@@ -56,6 +56,7 @@ public class BookMetadataRestorer {
|
||||
if (!isLocked(metadata.getIsbn10Locked())) metadata.setIsbn10(backup.getIsbn10());
|
||||
if (!isLocked(metadata.getAsinLocked())) metadata.setAsin(backup.getAsin());
|
||||
if (!isLocked(metadata.getGoodreadsIdLocked())) metadata.setGoodreadsId(backup.getGoodreadsId());
|
||||
if (!isLocked(metadata.getComicvineIdLocked())) metadata.setComicvineId(backup.getComicvineId());
|
||||
if (!isLocked(metadata.getHardcoverIdLocked())) metadata.setHardcoverId(backup.getHardcoverId());
|
||||
if (!isLocked(metadata.getGoogleIdLocked())) metadata.setGoogleId(backup.getGoogleId());
|
||||
|
||||
|
||||
+2
@@ -109,6 +109,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
|
||||
else if (value.length() == 10) builderMeta.isbn10(value);
|
||||
}
|
||||
case "GOODREADS" -> builderMeta.goodreadsId(value);
|
||||
case "COMICVINE" -> builderMeta.comicvineId(value);
|
||||
case "GOOGLE" -> builderMeta.googleId(value);
|
||||
case "AMAZON" -> builderMeta.asin(value);
|
||||
case "HARDCOVER" -> builderMeta.hardcoverId(value);
|
||||
@@ -148,6 +149,7 @@ public class EpubMetadataExtractor implements FileMetadataExtractor {
|
||||
switch (prop) {
|
||||
case "booklore:asin" -> builderMeta.asin(content);
|
||||
case "booklore:goodreads_id" -> builderMeta.goodreadsId(content);
|
||||
case "booklore:comicvine_id" -> builderMeta.comicvineId(content);
|
||||
case "booklore:hardcover_id" -> builderMeta.hardcoverId(content);
|
||||
case "booklore:google_books_id" -> builderMeta.googleId(content);
|
||||
case "booklore:page_count" -> safeParseInt(content, builderMeta::pageCount);
|
||||
|
||||
+5
@@ -165,6 +165,11 @@ public class PdfMetadataExtractor implements FileMetadataExtractor {
|
||||
metadataBuilder.goodreadsId(goodreads);
|
||||
}
|
||||
|
||||
String comicvine = identifiers.get("comicvine");
|
||||
if (StringUtils.isNotBlank(comicvine)) {
|
||||
metadataBuilder.comicvineId(comicvine);
|
||||
}
|
||||
|
||||
String hardcover = identifiers.get("hardcover");
|
||||
if (StringUtils.isNotBlank(hardcover)) {
|
||||
metadataBuilder.hardcoverId(hardcover);
|
||||
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
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.comicvineapi.ComicvineApiResponse;
|
||||
import com.adityachandel.booklore.model.dto.response.comicvineapi.Issue;
|
||||
import com.adityachandel.booklore.model.dto.response.comicvineapi.Volume;
|
||||
import com.adityachandel.booklore.model.dto.response.comicvineapi.Comic;
|
||||
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.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collector;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ComicvineBookParser implements BookParser {
|
||||
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
private static final String COMICVINE_URL = "https://comicvine.gamespot.com/api/";
|
||||
private final AppSettingService appSettingService;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||
String searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
return searchTerm != null ? getMetadataListByTerm(searchTerm) : List.of();
|
||||
}
|
||||
|
||||
public List<BookMetadata> getMetadataListByTerm(String term) {
|
||||
String apiToken = appSettingService.getAppSettings().getMetadataProviderSettings().getComicvine().getApiKey();
|
||||
if (apiToken == null || apiToken.isEmpty()) {
|
||||
log.warn("Comicvine API token not set");
|
||||
return Collections.emptyList();
|
||||
}
|
||||
log.info("Comicvine: Fetching metadata for: {}", term);
|
||||
try {
|
||||
|
||||
String fieldsList = "cover_date,id,issue_number,name,person_credits,volume,api_detail_url,concept_credits,start_year,publisher,description,image";
|
||||
String resources = "volume,issue";
|
||||
|
||||
URI uri = UriComponentsBuilder.fromUriString(COMICVINE_URL) // Base URL
|
||||
|
||||
.path("/search/")
|
||||
.queryParam("api_key", apiToken)
|
||||
.queryParam("format", "json")
|
||||
.queryParam("resources", resources)
|
||||
.queryParam("resource_type", resources)
|
||||
.queryParam("query", term)
|
||||
.queryParam("filter", "name:" + term)
|
||||
.queryParam("limit", "10") // Limit results to reduce response size
|
||||
.queryParam("field_list", fieldsList)
|
||||
.build()
|
||||
.toUri();
|
||||
|
||||
log.debug("Comicvine API request URI: {}", uri);
|
||||
HttpClient httpClient = HttpClient.newHttpClient();
|
||||
|
||||
HttpRequest request = HttpRequest.newBuilder()
|
||||
.uri(uri)
|
||||
.header("User-Agent", "MyComicApp/1.0")
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
if (response.statusCode() == 200) {
|
||||
return parseComicvineApiResponse(response.body());
|
||||
} else {
|
||||
log.error("Failed to fetch data from Comicvine API. Status code: {}", response.statusCode());
|
||||
return List.of();
|
||||
}
|
||||
} catch (IOException | InterruptedException e) {
|
||||
log.error("Error fetching metadata from Comicvine API", e);
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||
List<BookMetadata> fetchedBookMetadata = fetchMetadata(book, fetchMetadataRequest);
|
||||
return fetchedBookMetadata.isEmpty() ? null : fetchedBookMetadata.get(0);
|
||||
}
|
||||
|
||||
private String getSearchTerm(Book book, FetchMetadataRequest request) {
|
||||
return (request.getTitle() != null && !request.getTitle().isEmpty())
|
||||
? request.getTitle()
|
||||
: (book.getFileName() != null && !book.getFileName().isEmpty()
|
||||
? BookUtils.cleanFileName(book.getFileName())
|
||||
: null);
|
||||
}
|
||||
|
||||
private List<BookMetadata> parseComicvineApiResponse(String responseBody) throws IOException {
|
||||
ComicvineApiResponse apiResponse = objectMapper.readValue(responseBody, ComicvineApiResponse.class);
|
||||
return apiResponse.getResults().stream()
|
||||
.map(this::convertToBookMetadata)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private BookMetadata convertToBookMetadata(Comic comic) {
|
||||
BookMetadata.BookMetadataBuilder builder = BookMetadata.builder()
|
||||
.title(comic.getDisplayName())
|
||||
.comicvineId(String.valueOf(comic.getId()))
|
||||
.authors(comic.getAuthors())
|
||||
.thumbnailUrl(comic.getImageUrl())
|
||||
.description(comic.getDescription())
|
||||
.provider(MetadataProvider.Comicvine);
|
||||
|
||||
// Handle publishedDate based on the comic type
|
||||
if (comic instanceof Volume) {
|
||||
Volume volume = (Volume) comic;
|
||||
builder.publisher(volume.getPublisherName());
|
||||
builder.publishedDate(volume.getDate());
|
||||
} else if (comic instanceof Issue) {
|
||||
Issue issue = (Issue) comic;
|
||||
builder.seriesName(issue.getVolume().getName());
|
||||
builder.seriesNumber((float) issue.getIssueNumber());
|
||||
builder.publishedDate(issue.getDate()); // Already parsed
|
||||
}
|
||||
|
||||
// Return the final built object
|
||||
return builder.build();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
+4
@@ -119,6 +119,7 @@ public class EpubMetadataWriter implements MetadataWriter {
|
||||
boolean clearFlag = clear != null && switch (scheme) {
|
||||
case "AMAZON" -> clear.isAsin();
|
||||
case "GOOGLE" -> clear.isGoogleId();
|
||||
case "COMICVINE" -> clear.isComicvineId();
|
||||
case "GOODREADS" -> clear.isGoodreadsId();
|
||||
case "HARDCOVER" -> clear.isHardcoverId();
|
||||
case "ISBN" -> clear.isIsbn10();
|
||||
@@ -135,6 +136,9 @@ public class EpubMetadataWriter implements MetadataWriter {
|
||||
case "GOODREADS" -> helper.copyGoodreadsId(restoreMode, clearFlag, idValue -> {
|
||||
updateIdentifier(metadataElement, opfDoc, scheme, idValue, hasChanges);
|
||||
});
|
||||
case "COMICVINE" -> helper.copyComicvineId(restoreMode, clearFlag, idValue -> {
|
||||
updateIdentifier(metadataElement, opfDoc, scheme, idValue, hasChanges);
|
||||
});
|
||||
case "HARDCOVER" -> helper.copyHardcoverId(restoreMode, clearFlag, idValue -> {
|
||||
updateIdentifier(metadataElement, opfDoc, scheme, idValue, hasChanges);
|
||||
});
|
||||
|
||||
+7
@@ -126,6 +126,13 @@ public class MetadataCopyHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void copyComicvineId(boolean restore, boolean clear, Consumer<String> consumer) {
|
||||
if (!isLocked(metadata.getComicvineIdLocked())) {
|
||||
if (clear) consumer.accept(null);
|
||||
else if (metadata.getComicvineId() != null || restore) consumer.accept(metadata.getComicvineId());
|
||||
}
|
||||
}
|
||||
|
||||
public void copyHardcoverId(boolean restore, boolean clear, Consumer<String> consumer) {
|
||||
if (!isLocked(metadata.getHardcoverIdLocked())) {
|
||||
if (clear) consumer.accept(null);
|
||||
|
||||
+1
@@ -151,6 +151,7 @@ public class PdfMetadataWriter implements MetadataWriter {
|
||||
|
||||
helper.copyGoogleId(restoreMode, clear != null && clear.isGoogleId(), id -> appendIdentifier(doc, rdfBag, "google", id != null ? id : ""));
|
||||
helper.copyGoodreadsId(restoreMode, clear != null && clear.isGoodreadsId(), id -> appendIdentifier(doc, rdfBag, "goodreads", id != null ? id : ""));
|
||||
helper.copyComicvineId(restoreMode, clear != null && clear.isComicvineId(), id -> appendIdentifier(doc, rdfBag, "comicvine", id != null ? id : ""));
|
||||
helper.copyHardcoverId(restoreMode, clear != null && clear.isHardcoverId(), id -> appendIdentifier(doc, rdfBag, "hardcover", id != null ? id : ""));
|
||||
helper.copyAsin(restoreMode, clear != null && clear.isAsin(), id -> appendIdentifier(doc, rdfBag, "amazon", id != null ? id : ""));
|
||||
helper.copyIsbn13(restoreMode, clear != null && clear.isIsbn13(), id -> appendIdentifier(doc, rdfBag, "isbn", id != null ? id : ""));
|
||||
|
||||
@@ -31,6 +31,7 @@ public class MetadataChangeDetector {
|
||||
compare(changes, "isbn10", clear.isIsbn10(), newMeta.getIsbn10(), existingMeta.getIsbn10(), () -> !isTrue(existingMeta.getIsbn10Locked()), newMeta.getIsbn10Locked(), existingMeta.getIsbn10Locked());
|
||||
compare(changes, "asin", clear.isAsin(), newMeta.getAsin(), existingMeta.getAsin(), () -> !isTrue(existingMeta.getAsinLocked()), newMeta.getAsinLocked(), existingMeta.getAsinLocked());
|
||||
compare(changes, "goodreadsId", clear.isGoodreadsId(), newMeta.getGoodreadsId(), existingMeta.getGoodreadsId(), () -> !isTrue(existingMeta.getGoodreadsIdLocked()), newMeta.getGoodreadsIdLocked(), existingMeta.getGoodreadsIdLocked());
|
||||
compare(changes, "comicvineId", clear.isComicvineId(), newMeta.getComicvineId(), existingMeta.getComicvineId(), () -> !isTrue(existingMeta.getComicvineIdLocked()), newMeta.getComicvineIdLocked(), existingMeta.getComicvineIdLocked());
|
||||
compare(changes, "hardcoverId", clear.isHardcoverId(), newMeta.getHardcoverId(), existingMeta.getHardcoverId(), () -> !isTrue(existingMeta.getHardcoverIdLocked()), newMeta.getHardcoverIdLocked(), existingMeta.getHardcoverIdLocked());
|
||||
compare(changes, "googleId", clear.isGoogleId(), newMeta.getGoogleId(), existingMeta.getGoogleId(), () -> !isTrue(existingMeta.getGoogleIdLocked()), newMeta.getGoogleIdLocked(), existingMeta.getGoogleIdLocked());
|
||||
compare(changes, "pageCount", clear.isPageCount(), newMeta.getPageCount(), existingMeta.getPageCount(), () -> !isTrue(existingMeta.getPageCountLocked()), newMeta.getPageCountLocked(), existingMeta.getPageCountLocked());
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
ALTER TABLE book_metadata
|
||||
ADD COLUMN comicvine_id VARCHAR(100),
|
||||
ADD COLUMN comicvine_id_locked BOOLEAN DEFAULT FALSE;
|
||||
+3
-1
@@ -32,7 +32,8 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
'isbn13Locked', 'isbn10Locked', 'asinLocked', 'pageCountLocked', 'thumbnailLocked', 'languageLocked', 'coverLocked',
|
||||
'seriesNameLocked', 'seriesNumberLocked', 'seriesTotalLocked', 'authorsLocked', 'categoriesLocked',
|
||||
'amazonRatingLocked', 'amazonReviewCountLocked', 'goodreadsRatingLocked', 'goodreadsReviewCountLocked',
|
||||
'hardcoverRatingLocked', 'hardcoverReviewCountLocked', 'goodreadsIdLocked', 'hardcoverIdLocked', 'googleIdLocked'
|
||||
'hardcoverRatingLocked', 'hardcoverReviewCountLocked', 'goodreadsIdLocked', 'hardcoverIdLocked', 'googleIdLocked',
|
||||
'comicvineIdLocked'
|
||||
];
|
||||
|
||||
fieldLabels: Record<string, string> = {
|
||||
@@ -62,6 +63,7 @@ export class LockUnlockMetadataDialogComponent implements OnInit {
|
||||
goodreadsIdLocked: 'Goodreads ID',
|
||||
hardcoverIdLocked: 'Hardcover ID',
|
||||
googleIdLocked: 'Google ID',
|
||||
comicvineIdLocked: 'Comicvine ID',
|
||||
};
|
||||
|
||||
isSaving = false;
|
||||
|
||||
+3
@@ -65,6 +65,9 @@
|
||||
@if (backupMetadata.amazonReviewCount !== null) {
|
||||
<div><strong>Amazon Review Count:</strong> {{ backupMetadata.amazonReviewCount }}</div>
|
||||
}
|
||||
@if (backupMetadata.comicvineId) {
|
||||
<div><strong>Comicvine ID:</strong> {{ backupMetadata.comicvineId }}</div>
|
||||
}
|
||||
@if (backupMetadata.goodreadsId) {
|
||||
<div><strong>Goodreads ID:</strong> {{ backupMetadata.goodreadsId }}</div>
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ export interface BookMetadata {
|
||||
isbn10?: string;
|
||||
asin?: string;
|
||||
goodreadsId?: string;
|
||||
comicvineId?: string;
|
||||
hardcoverId?: string;
|
||||
googleId?: string;
|
||||
pageCount?: number | null;
|
||||
@@ -85,6 +86,7 @@ export interface BookMetadata {
|
||||
isbn13Locked?: boolean;
|
||||
isbn10Locked?: boolean;
|
||||
asinLocked?: boolean;
|
||||
comicvineIdLocked?: boolean;
|
||||
goodreadsIdLocked?: boolean;
|
||||
hardcoverIdLocked?: boolean;
|
||||
googleIdLocked?: boolean;
|
||||
@@ -118,6 +120,7 @@ export interface MetadataClearFlags {
|
||||
isbn10?: boolean;
|
||||
asin?: boolean;
|
||||
goodreadsId?: boolean;
|
||||
comicvineId?: boolean;
|
||||
hardcoverId?: boolean;
|
||||
googleId?: boolean;
|
||||
pageCount?: boolean;
|
||||
|
||||
+2
@@ -68,6 +68,7 @@ export class BookdropFileMetadataPickerComponent {
|
||||
{label: 'HC Reviews', controlName: 'hardcoverReviewCount', lockedKey: 'hardcoverReviewCountLocked', fetchedKey: 'hardcoverReviewCount'},
|
||||
{label: 'HC Rating', controlName: 'hardcoverRating', lockedKey: 'hardcoverRatingLocked', fetchedKey: 'hardcoverRating'},
|
||||
{label: 'Google ID', controlName: 'googleId', lockedKey: 'googleIdLocked', fetchedKey: 'googleIdRating'},
|
||||
{label: 'CV ID', controlName: 'comicvineId', lockedKey: 'comicvineIdLocked', fetchedKey: 'comicvineId'},
|
||||
{label: 'Pages', controlName: 'pageCount', lockedKey: 'pageCountLocked', fetchedKey: 'pageCount'}
|
||||
];
|
||||
|
||||
@@ -155,6 +156,7 @@ export class BookdropFileMetadataPickerComponent {
|
||||
hardcoverRating: this.originalMetadata.hardcoverRating || null,
|
||||
hardcoverReviewCount: this.originalMetadata.hardcoverReviewCount || null,
|
||||
googleId: this.originalMetadata.googleId || null,
|
||||
comicvineId: this.originalMetadata.comicvineId || null,
|
||||
seriesName: this.originalMetadata.seriesName || null,
|
||||
seriesNumber: this.originalMetadata.seriesNumber || null,
|
||||
seriesTotal: this.originalMetadata.seriesTotal || null,
|
||||
|
||||
+2
@@ -252,6 +252,7 @@ export class BookdropFileReviewComponent implements OnInit {
|
||||
hardcoverRating: original.hardcoverRating ?? null,
|
||||
hardcoverReviewCount: original.hardcoverReviewCount ?? null,
|
||||
googleId: original.googleId ?? null,
|
||||
comicvineId: original.comicvineId ?? null,
|
||||
seriesName: original.seriesName ?? null,
|
||||
seriesNumber: original.seriesNumber ?? null,
|
||||
seriesTotal: original.seriesTotal ?? null,
|
||||
@@ -495,6 +496,7 @@ export class BookdropFileReviewComponent implements OnInit {
|
||||
hardcoverRating: new FormControl(original.hardcoverRating ?? ''),
|
||||
hardcoverReviewCount: new FormControl(original.hardcoverReviewCount ?? ''),
|
||||
googleId: new FormControl(original.googleId ?? ''),
|
||||
comicvineId: new FormControl(original.comicvineId ?? ''),
|
||||
seriesName: new FormControl(original.seriesName ?? ''),
|
||||
seriesNumber: new FormControl(original.seriesNumber ?? ''),
|
||||
seriesTotal: new FormControl(original.seriesTotal ?? ''),
|
||||
|
||||
@@ -46,6 +46,7 @@ export interface MetadataProviderSettings {
|
||||
google: Google;
|
||||
goodReads: Goodreads;
|
||||
hardcover: Hardcover;
|
||||
comicvine: Comicvine;
|
||||
}
|
||||
|
||||
export interface Amazon {
|
||||
@@ -66,7 +67,10 @@ export interface Hardcover {
|
||||
enabled: boolean;
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
export interface Comicvine {
|
||||
enabled: boolean;
|
||||
apiKey: string;
|
||||
}
|
||||
export interface MetadataPersistenceSettings {
|
||||
saveToOriginalFile: boolean;
|
||||
backupMetadata: boolean;
|
||||
|
||||
+12
@@ -355,6 +355,18 @@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-1 w-1/6">
|
||||
<label for="comicvineId">Comicvine ID</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pInputText id="comicvineId" formControlName="comicvineId" class="w-full"/>
|
||||
@if (!book.metadata!['comicvineIdLocked']) {
|
||||
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="success"></p-button>
|
||||
}
|
||||
@if (book.metadata!['comicvineIdLocked']) {
|
||||
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock('comicvineId')" severity="warn"></p-button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+8
@@ -97,6 +97,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonRating: new FormControl(''),
|
||||
amazonReviewCount: new FormControl(''),
|
||||
goodreadsId: new FormControl(''),
|
||||
comicvineId: new FormControl(''),
|
||||
goodreadsRating: new FormControl(''),
|
||||
goodreadsReviewCount: new FormControl(''),
|
||||
hardcoverId: new FormControl(''),
|
||||
@@ -123,6 +124,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonRatingLocked: new FormControl(false),
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
goodreadsIdLocked: new FormControl(''),
|
||||
comicvineIdLocked: new FormControl(false),
|
||||
goodreadsRatingLocked: new FormControl(false),
|
||||
goodreadsReviewCountLocked: new FormControl(false),
|
||||
hardcoverIdLocked: new FormControl(false),
|
||||
@@ -189,6 +191,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonRating: metadata.amazonRating ?? null,
|
||||
amazonReviewCount: metadata.amazonReviewCount ?? null,
|
||||
goodreadsId: metadata.goodreadsId ?? null,
|
||||
comicvineId: metadata.comicvineId ?? null,
|
||||
goodreadsRating: metadata.goodreadsRating ?? null,
|
||||
goodreadsReviewCount: metadata.goodreadsReviewCount ?? null,
|
||||
hardcoverId: metadata.hardcoverId ?? null,
|
||||
@@ -214,6 +217,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonRatingLocked: metadata.amazonRatingLocked ?? false,
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked ?? false,
|
||||
goodreadsIdLocked: metadata.goodreadsIdLocked ?? false,
|
||||
comicvineIdLocked: metadata.comicvineIdLocked ?? false,
|
||||
goodreadsRatingLocked: metadata.goodreadsRatingLocked ?? false,
|
||||
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked ?? false,
|
||||
hardcoverIdLocked: metadata.hardcoverIdLocked ?? false,
|
||||
@@ -241,6 +245,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
{key: 'amazonRatingLocked', control: 'amazonRating'},
|
||||
{key: 'personalRatingLocked', control: 'personalRating'},
|
||||
{key: 'goodreadsIdLocked', control: 'goodreadsId'},
|
||||
{key: 'comicvineIdLocked', control: 'comicvineId'},
|
||||
{key: 'goodreadsReviewCountLocked', control: 'goodreadsReviewCount'},
|
||||
{key: 'goodreadsRatingLocked', control: 'goodreadsRating'},
|
||||
{key: 'hardcoverIdLocked', control: 'hardcoverId'},
|
||||
@@ -352,6 +357,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonRating: form.get('amazonRating')?.value,
|
||||
amazonReviewCount: form.get('amazonReviewCount')?.value,
|
||||
goodreadsId: form.get('goodreadsId')?.value,
|
||||
comicvineId: form.get('comicvineId')?.value,
|
||||
goodreadsRating: form.get('goodreadsRating')?.value,
|
||||
goodreadsReviewCount: form.get('goodreadsReviewCount')?.value,
|
||||
hardcoverId: form.get('hardcoverId')?.value,
|
||||
@@ -380,6 +386,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
personalRatingLocked: form.get('personalRatingLocked')?.value,
|
||||
amazonReviewCountLocked: form.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsIdLocked: form.get('goodreadsIdLocked')?.value,
|
||||
comicvineIdLocked: form.get('comicvineIdLocked')?.value,
|
||||
goodreadsRatingLocked: form.get('goodreadsRatingLocked')?.value,
|
||||
goodreadsReviewCountLocked: form.get('goodreadsReviewCountLocked')?.value,
|
||||
hardcoverIdLocked: form.get('hardcoverIdLocked')?.value,
|
||||
@@ -423,6 +430,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
amazonRating: wasCleared('personalRating'),
|
||||
amazonReviewCount: wasCleared('amazonReviewCount'),
|
||||
goodreadsId: wasCleared('goodreadsId'),
|
||||
comicvineId: wasCleared('comicvineId'),
|
||||
goodreadsRating: wasCleared('goodreadsRating'),
|
||||
goodreadsReviewCount: wasCleared('goodreadsReviewCount'),
|
||||
hardcoverId: wasCleared('hardcoverId'),
|
||||
|
||||
+8
@@ -62,6 +62,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
{label: 'Amz Reviews', controlName: 'amazonReviewCount', lockedKey: 'amazonReviewCountLocked', fetchedKey: 'amazonReviewCount'},
|
||||
{label: 'Amz Rating', controlName: 'amazonRating', lockedKey: 'amazonRatingLocked', fetchedKey: 'amazonRating'},
|
||||
{label: 'GR ID', controlName: 'goodreadsId', lockedKey: 'goodreadsIdLocked', fetchedKey: 'goodreadsId'},
|
||||
{label: 'CV ID', controlName: 'comicvineId', lockedKey: 'comicvineIdLocked', fetchedKey: 'comicvineId'},
|
||||
{label: 'GR Reviews', controlName: 'goodreadsReviewCount', lockedKey: 'goodreadsReviewCountLocked', fetchedKey: 'goodreadsReviewCount'},
|
||||
{label: 'GR Rating', controlName: 'goodreadsRating', lockedKey: 'goodreadsRatingLocked', fetchedKey: 'goodreadsRating'},
|
||||
{label: 'HC ID', controlName: 'hardcoverId', lockedKey: 'hardcoverIdLocked', fetchedKey: 'hardcoverId'},
|
||||
@@ -105,6 +106,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRating: new FormControl(''),
|
||||
amazonReviewCount: new FormControl(''),
|
||||
goodreadsId: new FormControl(''),
|
||||
comicvineId: new FormControl(''),
|
||||
goodreadsRating: new FormControl(''),
|
||||
goodreadsReviewCount: new FormControl(''),
|
||||
hardcoverId: new FormControl(''),
|
||||
@@ -132,6 +134,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRatingLocked: new FormControl(false),
|
||||
amazonReviewCountLocked: new FormControl(false),
|
||||
goodreadsIdLocked: new FormControl(false),
|
||||
comicvineIdLocked: new FormControl(false),
|
||||
goodreadsRatingLocked: new FormControl(false),
|
||||
goodreadsReviewCountLocked: new FormControl(false),
|
||||
hardcoverIdLocked: new FormControl(false),
|
||||
@@ -180,6 +183,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRating: metadata.amazonRating || null,
|
||||
amazonReviewCount: metadata.amazonReviewCount || null,
|
||||
goodreadsId: metadata.goodreadsId || null,
|
||||
comicvineId: metadata.comicvineId || null,
|
||||
goodreadsRating: metadata.goodreadsRating || null,
|
||||
goodreadsReviewCount: metadata.goodreadsReviewCount || null,
|
||||
hardcoverId: metadata.hardcoverId || null,
|
||||
@@ -207,6 +211,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRatingLocked: metadata.amazonRatingLocked || false,
|
||||
amazonReviewCountLocked: metadata.amazonReviewCountLocked || false,
|
||||
goodreadsIdLocked: metadata.goodreadsIdLocked || false,
|
||||
comicvineIdLocked: metadata.comicvineIdLocked || false,
|
||||
goodreadsRatingLocked: metadata.goodreadsRatingLocked || false,
|
||||
goodreadsReviewCountLocked: metadata.goodreadsReviewCountLocked || false,
|
||||
hardcoverIdLocked: metadata.hardcoverIdLocked || false,
|
||||
@@ -287,6 +292,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRating: this.metadataForm.get('amazonRating')?.value || this.copiedFields['amazonRating'] ? this.getNumberOrCopied('amazonRating') : null,
|
||||
amazonReviewCount: this.metadataForm.get('amazonReviewCount')?.value || this.copiedFields['amazonReviewCount'] ? this.getNumberOrCopied('amazonReviewCount') : null,
|
||||
goodreadsId: this.metadataForm.get('goodreadsId')?.value || this.copiedFields['goodreadsId'] ? this.getValueOrCopied('goodreadsId') : '',
|
||||
comicvineId: this.metadataForm.get('comicvineId')?.value || this.copiedFields['comicvineId'] ? this.getValueOrCopied('comicvineId') : '',
|
||||
goodreadsRating: this.metadataForm.get('goodreadsRating')?.value || this.copiedFields['goodreadsRating'] ? this.getNumberOrCopied('goodreadsRating') : null,
|
||||
goodreadsReviewCount: this.metadataForm.get('goodreadsReviewCount')?.value || this.copiedFields['goodreadsReviewCount'] ? this.getNumberOrCopied('goodreadsReviewCount') : null,
|
||||
hardcoverId: this.metadataForm.get('hardcoverId')?.value || this.copiedFields['hardcoverId'] ? this.getValueOrCopied('hardcoverId') : '',
|
||||
@@ -314,6 +320,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRatingLocked: this.metadataForm.get('amazonRatingLocked')?.value,
|
||||
amazonReviewCountLocked: this.metadataForm.get('amazonReviewCountLocked')?.value,
|
||||
goodreadsIdLocked: this.metadataForm.get('goodreadsIdLocked')?.value,
|
||||
comicvineIdLocked: this.metadataForm.get('comicvineIdLocked')?.value,
|
||||
goodreadsRatingLocked: this.metadataForm.get('goodreadsRatingLocked')?.value,
|
||||
goodreadsReviewCountLocked: this.metadataForm.get('goodreadsReviewCountLocked')?.value,
|
||||
hardcoverIdLocked: this.metadataForm.get('hardcoverIdLocked')?.value,
|
||||
@@ -353,6 +360,7 @@ export class MetadataPickerComponent implements OnInit {
|
||||
amazonRating: current.amazonRating === null && original.amazonRating !== null,
|
||||
amazonReviewCount: current.amazonReviewCount === null && original.amazonReviewCount !== null,
|
||||
goodreadsId: !current.goodreadsId && !!original.goodreadsId,
|
||||
comicvineId: !current.comicvineId && !!original.comicvineId,
|
||||
goodreadsRating: current.goodreadsRating === null && original.goodreadsRating !== null,
|
||||
goodreadsReviewCount: current.goodreadsReviewCount === null && original.goodreadsReviewCount !== null,
|
||||
hardcoverId: !current.hardcoverId && !!original.hardcoverId,
|
||||
|
||||
+8
-1
@@ -183,7 +183,14 @@ export class MetadataSearcherComponent implements OnInit, OnDestroy {
|
||||
} else if (metadata.hardcoverId) {
|
||||
return `<a href="https://hardcover.app/books/${metadata.hardcoverId}" target="_blank">Hardcover</a>`;
|
||||
}
|
||||
|
||||
else if (metadata.comicvineId) {
|
||||
if( metadata.comicvineId.startsWith('4000')) {
|
||||
const name = metadata.seriesName ? metadata.seriesName.replace(/ /g, '-').toLowerCase() + "-" + metadata.seriesNumber : '';
|
||||
return `<a href="https://comicvine.gamespot.com/${name}/${metadata.comicvineId}" target="_blank">Comicvine</a>`;
|
||||
}
|
||||
const name = metadata.seriesName;
|
||||
return `<a href="https://comicvine.gamespot.com/volume/${metadata.comicvineId}" target="_blank">Comicvine</a>`;
|
||||
}
|
||||
throw new Error("No provider ID found in metadata.");
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -181,9 +181,25 @@
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (book?.metadata?.comicvineId) {
|
||||
<a
|
||||
class="flex items-center gap-1"
|
||||
[href]="'https://comicvine.gamespot.com/' + book.metadata!.comicvineId"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<img
|
||||
src="https://www.comicvine.com/favicon.ico"
|
||||
alt="Comic Vine"
|
||||
class="w-5 h-5 object-contain transform transition duration-200 hover:scale-125 hover:drop-shadow-lg"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@if (book?.metadata?.categories?.length) {
|
||||
<div class="overflow-x-auto scrollbar-hide max-w-7xl pt-2 md:pt-0">
|
||||
<div class="flex gap-2 w-max max-w-[1150px]">
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
'seriesName', 'seriesNumber', 'seriesTotal', 'isbn13', 'isbn10',
|
||||
'language', 'categories', 'cover'
|
||||
];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover'];
|
||||
providers: string[] = ['Amazon', 'Google', 'GoodReads', 'Hardcover', 'Comicvine'];
|
||||
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
|
||||
+27
@@ -52,6 +52,7 @@
|
||||
<p-checkbox [(ngModel)]="googleEnabled" [binary]="true"></p-checkbox>
|
||||
<label class="font-medium">Google</label>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex items-center gap-4">
|
||||
@@ -72,7 +73,33 @@
|
||||
[(ngModel)]="hardcoverToken"
|
||||
(ngModelChange)="onTokenChange($event)" />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex items-center gap-4">
|
||||
<p-checkbox
|
||||
[binary]="true"
|
||||
[(ngModel)]="comicvineEnabled"
|
||||
[disabled]="!comicvineToken">
|
||||
</p-checkbox>
|
||||
<label class="font-medium">Comic Vine</label>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 pl-9 pt-1">
|
||||
<label class="font-medium text-sm">API Token</label>
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Enter Comic Vine API token"
|
||||
class="w-full max-w-3xl"
|
||||
[(ngModel)]="comicvineToken"
|
||||
(ngModelChange)="onComicTokenChange($event)" />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex justify-start px-4">
|
||||
|
||||
+17
@@ -58,6 +58,8 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
amazonEnabled: boolean = false;
|
||||
goodreadsEnabled: boolean = false;
|
||||
googleEnabled: boolean = false;
|
||||
comicvineEnabled: boolean = false;
|
||||
comicvineToken: string = '';
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private messageService = inject(MessageService);
|
||||
@@ -79,6 +81,8 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
this.googleEnabled = metadataProviderSettings?.google?.enabled ?? false;
|
||||
this.hardcoverToken = metadataProviderSettings?.hardcover?.apiKey ?? '';
|
||||
this.hardcoverEnabled = metadataProviderSettings?.hardcover?.enabled ?? false;
|
||||
this.comicvineEnabled = metadataProviderSettings?.comicvine?.enabled ?? false;
|
||||
this.comicvineToken = metadataProviderSettings?.comicvine?.apiKey ?? '';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -89,6 +93,13 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
onComicTokenChange(newToken: string): void {
|
||||
this.comicvineToken = newToken;
|
||||
if (!newToken.trim()) {
|
||||
this.comicvineEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
saveSettings(): void {
|
||||
const payload = [
|
||||
{
|
||||
@@ -99,6 +110,12 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
cookie: this.amazonCookie,
|
||||
domain: this.selectedAmazonDomain
|
||||
},
|
||||
|
||||
comicvine: {
|
||||
enabled: this.comicvineEnabled,
|
||||
apiKey: this.comicvineToken.trim()
|
||||
},
|
||||
|
||||
goodReads: {enabled: this.goodreadsEnabled},
|
||||
google: {enabled: this.googleEnabled},
|
||||
hardcover: {
|
||||
|
||||
Reference in New Issue
Block a user