feat(metadata): RanobeDB search improvements (#1804)

Co-authored-by: James Ward <james@notjam.es>
This commit is contained in:
NichaesMol
2026-07-18 08:01:56 +00:00
committed by GitHub
co-authored by James Ward
parent fbd1d5e30a
commit b68e022fc0
10 changed files with 303 additions and 74 deletions
@@ -50,6 +50,7 @@ public class MetadataProviderSettings {
@Data @Data
public static class Ranobedb { public static class Ranobedb {
private boolean enabled; private boolean enabled;
private boolean preferRomaji;
} }
@Data @Data
@@ -1,5 +1,7 @@
package org.booklore.service.metadata.parser; package org.booklore.service.metadata.parser;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.booklore.model.dto.Book; import org.booklore.model.dto.Book;
@@ -20,11 +22,14 @@ import java.net.URI;
import java.net.http.HttpClient; import java.net.http.HttpClient;
import java.net.http.HttpRequest; import java.net.http.HttpRequest;
import java.net.http.HttpResponse; import java.net.http.HttpResponse;
import java.time.Duration;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeParseException; import java.time.DateTimeException;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -39,7 +44,11 @@ public class RanobeDbParser implements BookParser {
private final ObjectMapper objectMapper; private final ObjectMapper objectMapper;
private final AppSettingService appSettingService; private final AppSettingService appSettingService;
private final HttpClient httpClient = HttpClient.newHttpClient(); private final HttpClient httpClient;
private final Cache<String, Integer> authorIds = Caffeine.newBuilder()
.maximumSize(500)
.expireAfterWrite(Duration.ofHours(1))
.build();
// Rate limiter: 2 requests per second // Rate limiter: 2 requests per second
private static final int MAX_REQUESTS_PER_SECOND = 2; private static final int MAX_REQUESTS_PER_SECOND = 2;
@@ -47,10 +56,12 @@ public class RanobeDbParser implements BookParser {
private final AtomicLong lastRequestTime = new AtomicLong(0); private final AtomicLong lastRequestTime = new AtomicLong(0);
private final AtomicLong tokenCount = new AtomicLong(MAX_REQUESTS_PER_SECOND); private final AtomicLong tokenCount = new AtomicLong(MAX_REQUESTS_PER_SECOND);
private record SearchTerms(String title, Integer authorId) {}
@Override @Override
public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) { public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
String searchTerm = getSearchTerm(book, fetchMetadataRequest); SearchTerms searchTerm = getSearchTerm(book, fetchMetadataRequest);
if (searchTerm == null) { if (searchTerm == null) {
log.warn("No valid search term provided for metadata fetch."); log.warn("No valid search term provided for metadata fetch.");
return Collections.emptyList(); return Collections.emptyList();
@@ -60,7 +71,7 @@ public class RanobeDbParser implements BookParser {
@Override @Override
public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) { public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
String searchTerm = getSearchTerm(book, fetchMetadataRequest); SearchTerms searchTerm = getSearchTerm(book, fetchMetadataRequest);
if (searchTerm == null) { if (searchTerm == null) {
log.warn("No valid search term provided for metadata fetch."); log.warn("No valid search term provided for metadata fetch.");
return null; return null;
@@ -112,24 +123,38 @@ public class RanobeDbParser implements BookParser {
} }
} }
public List<BookMetadata> getMetadataListByTerm(String term, Boolean fetchTop) { private List<BookMetadata> getMetadataListByTerm(SearchTerms term, boolean fetchTop) {
log.info("Ranobedb: Fetching metadata for term: '{}'", term); log.info("Ranobedb: Fetching metadata for term: '{}'", term);
try { List<BookMetadata> metadataList = getMetadataList(term, fetchTop);
// Apply rate limiting before making the API request
waitForRateLimit();
URI uri = UriComponentsBuilder.fromUriString(RANOBEDB_URL) if (metadataList != null && metadataList.isEmpty() && term.authorId() != null) {
.path("/books") log.info("RanobeDB: Failed to find results with author, trying again with only the title.");
.queryParam("q", term) metadataList = getMetadataList(new SearchTerms(term.title(), null), fetchTop);
.queryParam("query", term) }
.queryParam("limit", 5)
.queryParam("rl", "en") if (metadataList != null) return metadataList;
.queryParam("rll", "or") return Collections.emptyList();
.queryParam("rf", "digital,print") }
.queryParam("rfl", "or")
.build() private List<BookMetadata> getMetadataList(SearchTerms term, boolean fetchTop) {
.toUri(); try {
// Apply rate limiting before making the API request
waitForRateLimit();
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(RANOBEDB_URL)
.path("/books")
.queryParam("q", term.title())
.queryParam("limit", 20)
.queryParam("rf", "digital")
.queryParam("rfl", "or");
if (term.authorId() != null) {
builder.queryParam("staff", term.authorId())
.queryParam("sl", "and");
}
URI uri = builder.build().toUri();
HttpRequest request = HttpRequest.newBuilder() HttpRequest request = HttpRequest.newBuilder()
.uri(uri) .uri(uri)
@@ -141,7 +166,7 @@ public class RanobeDbParser implements BookParser {
if (response.statusCode() == 200) { if (response.statusCode() == 200) {
List<BookMetadata> metadataList = parseRanobeDbApiResponse(response.body(), fetchTop); List<BookMetadata> metadataList = parseRanobeDbApiResponse(response.body(), fetchTop);
log.error("Ranobedb: Found {} results for term: '{}'", metadataList.size(), term); log.info("Ranobedb: Found {} results for term: '{}'", metadataList.size(), term);
return metadataList; return metadataList;
} else { } else {
log.error("Ranobedb Search API returned status code {}", response.statusCode()); log.error("Ranobedb Search API returned status code {}", response.statusCode());
@@ -149,33 +174,117 @@ public class RanobeDbParser implements BookParser {
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
log.error("Error fetching metadata from Ranobedb Search API", e); log.error("Error fetching metadata from Ranobedb Search API", e);
} }
return Collections.emptyList(); return null;
} }
private String getSearchTerm(Book book, FetchMetadataRequest request) { private SearchTerms getSearchTerm(Book book, FetchMetadataRequest request) {
String title = null;
if (request.getTitle() != null && !request.getTitle().isEmpty()) { if (request.getTitle() != null && !request.getTitle().isEmpty()) {
return request.getTitle(); title = request.getTitle();
} else if (book.getPrimaryFile() != null && book.getPrimaryFile().getFileName() != null && !book.getPrimaryFile().getFileName().isEmpty()) { } else if (book.getPrimaryFile() != null && book.getPrimaryFile().getFileName() != null && !book.getPrimaryFile().getFileName().isEmpty()) {
return BookUtils.cleanFileName(book.getPrimaryFile().getFileName()); title = BookUtils.cleanFileName(book.getPrimaryFile().getFileName());
}
if (title == null) {
return null;
}
Integer authorId = getAuthorID(request.getAuthor());
return new SearchTerms(title, authorId);
}
private Integer getAuthorID(String author) {
if (author == null || author.isEmpty()) {
return null;
}
Integer cachedAuthorId = authorIds.getIfPresent(author);
if (cachedAuthorId != null) {
return cachedAuthorId;
}
try {
// Apply rate limiting before making the API request
waitForRateLimit();
URI uri = UriComponentsBuilder.fromUriString(RANOBEDB_URL)
.path("/staff")
.queryParam("q", author)
.queryParam("limit", 1)
.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) {
// parse response and return first staff id
var root = objectMapper.readTree(response.body());
var staffArray = root.path("staff");
if (staffArray.isArray() && !staffArray.isEmpty()) {
var staffNode = staffArray.get(0).path("id");
if (staffNode.isInt()) {
authorIds.put(author, staffNode.asInt());
return staffNode.asInt();
}
}
} else {
log.error("Ranobedb Staff API returned status code {}", response.statusCode());
}
} catch (IOException | InterruptedException e) {
log.error("Error fetching staff from Ranobedb API", e);
} }
return null; return null;
} }
private List<BookMetadata> parseRanobeDbApiResponse(String responseBody, Boolean fetchTop) throws IOException { private List<BookMetadata> parseRanobeDbApiResponse(String responseBody, boolean fetchTop) throws IOException {
RanobedbSearchResponse searchResponse = objectMapper.readValue(responseBody, RanobedbSearchResponse.class); RanobedbSearchResponse searchResponse = objectMapper.readValue(responseBody, RanobedbSearchResponse.class);
if (searchResponse.getBooks() == null) { if (searchResponse.getBooks() == null) {
return Collections.emptyList(); return Collections.emptyList();
} }
if (fetchTop && !searchResponse.getBooks().isEmpty()) { if (fetchTop && !searchResponse.getBooks().isEmpty()) {
BookMetadata topMetadata = searchResultToBookMetadata(searchResponse.getBooks().getFirst().getId()); BookMetadata topMetadata = searchResultToBookMetadata(searchResponse.getBooks().getFirst().getId());
return topMetadata != null ? List.of(topMetadata) : Collections.emptyList(); return topMetadata != null ? List.of(topMetadata) : Collections.emptyList();
} else { } else {
return searchResponse.getBooks().stream() return searchResponse.getBooks().stream()
.map(book -> searchResultToBookMetadata(book.getId())) .map(book -> searchResultToBookMetadata(book.getId()))
.filter(Objects::nonNull)
.toList(); .toList();
} }
} }
private boolean isPreferringRomaji() {
var appSettings = appSettingService.getAppSettings();
if (appSettings == null || appSettings.getMetadataProviderSettings() == null) {
return false;
}
var ranobedbSettings = appSettings.getMetadataProviderSettings().getRanobedb();
if (ranobedbSettings == null) {
return false;
}
return ranobedbSettings.isPreferRomaji();
}
private String getPreferredValue(String romaji, String normal) {
if (isPreferringRomaji() && romaji != null && !romaji.isBlank()) {
return romaji;
}
if (normal != null && !normal.isBlank()) {
return normal;
}
return romaji;
}
private BookMetadata searchResultToBookMetadata(int bookId) { private BookMetadata searchResultToBookMetadata(int bookId) {
try { try {
@@ -197,28 +306,29 @@ public class RanobeDbParser implements BookParser {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 200) { if (response.statusCode() == 200) {
RanobedbBookResponse responstObj = objectMapper.readValue(response.body(), RanobedbBookResponse.class); RanobedbBookResponse responseObj = objectMapper.readValue(response.body(), RanobedbBookResponse.class);
RanobedbBookResponse.Book book = responstObj.getBook(); RanobedbBookResponse.Book book = responseObj.getBook();
if (book == null) { if (book == null) {
return null; return null;
} }
RanobedbBookResponse.TitleEntry englishTitleEntry = book.getTitles().stream() RanobedbBookResponse.Release release = book.getReleases().stream()
.filter(titleEntry -> "en".equalsIgnoreCase(titleEntry.getLang())) .filter(Objects::nonNull)
.filter(titleEntry -> titleEntry.getOfficial()) .min(Comparator.comparingInt(r -> "en".equalsIgnoreCase(r.getLang()) ? 1 : -1))
.orElse(null);
String bookLang = release != null ? release.getLang() : book.getLang();
RanobedbBookResponse.Publisher publisher = book.getPublishers().stream()
.filter(p -> bookLang != null && bookLang.equalsIgnoreCase(p.getLang()))
.filter(p -> RanobedbBookResponse.PublisherType.PUBLISHER.equals(p.getPublisherType()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);
RanobedbBookResponse.Release englishRelease = book.getReleases().stream() String publisherName = null;
.filter(release -> "en".equalsIgnoreCase(release.getLang())) if (publisher != null) {
.findFirst() publisherName = getPreferredValue(publisher.getRomaji(), publisher.getName());
.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(); List<RanobedbBookResponse.SeriesBook> seriesBooks = book.getSeries() != null ? book.getSeries().getBooks() : List.of();
int seriesIndex = IntStream.range(0, seriesBooks.size()) int seriesIndex = IntStream.range(0, seriesBooks.size())
@@ -229,7 +339,7 @@ public class RanobeDbParser implements BookParser {
List<String> authors = book.getEditions().stream() List<String> authors = book.getEditions().stream()
.flatMap(edition -> edition.getStaff().stream()) .flatMap(edition -> edition.getStaff().stream())
.filter(staff -> RanobedbBookResponse.RoleType.AUTHOR.equals(staff.getRoleType())) .filter(staff -> RanobedbBookResponse.RoleType.AUTHOR.equals(staff.getRoleType()))
.map(staff -> staff.getRomaji() != null ? staff.getRomaji() : staff.getName()) .map(staff -> getPreferredValue(staff.getRomaji(), staff.getName()))
.toList(); .toList();
HashSet<String> genres = book.getSeries() != null ? book.getSeries().getTags().stream() HashSet<String> genres = book.getSeries() != null ? book.getSeries().getTags().stream()
@@ -238,7 +348,13 @@ public class RanobeDbParser implements BookParser {
.map(genre -> Pattern.compile("\\b(.)(.*?)\\b").matcher(genre).replaceAll(m -> m.group(1).toUpperCase() + m.group(2).toLowerCase())) .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<>(); .collect(Collectors.toCollection(HashSet::new)) : new HashSet<>();
String title = englishTitleEntry != null ? englishTitleEntry.getTitle() : book.getTitle(); String title;
if (release != null) {
title = getPreferredValue(release.getRomaji(), release.getTitle());
} else {
title = getPreferredValue(book.getRomaji(), book.getTitle());
}
String subtitle = null; String subtitle = null;
if (book.getSeries() != null && book.getSeries().getTitle() != null && title.startsWith(book.getSeries().getTitle())) { if (book.getSeries() != null && book.getSeries().getTitle() != null && title.startsWith(book.getSeries().getTitle())) {
String remainingTitle = title.substring(book.getSeries().getTitle().length()).trim(); String remainingTitle = title.substring(book.getSeries().getTitle().length()).trim();
@@ -249,6 +365,13 @@ public class RanobeDbParser implements BookParser {
} }
} }
String description;
if (release != null && release.getDescription() != null && !release.getDescription().isBlank()) {
description = release.getDescription();
} else {
description = "ja".equalsIgnoreCase(bookLang) ? book.getDescriptionJa() : book.getDescription();
}
return BookMetadata.builder() return BookMetadata.builder()
.provider(MetadataProvider.Ranobedb) .provider(MetadataProvider.Ranobedb)
.ranobedbId(String.valueOf(book.getId())) .ranobedbId(String.valueOf(book.getId()))
@@ -257,17 +380,18 @@ public class RanobeDbParser implements BookParser {
.subtitle(subtitle) .subtitle(subtitle)
.authors(authors) .authors(authors)
.categories(genres) .categories(genres)
.publisher(englishPublisher != null ? englishPublisher.getName() : null) .publisher(publisherName)
.thumbnailUrl(book.getImage() != null ? RANOBEDB_IMAGE_URL + book.getImage().getFilename() : null) .thumbnailUrl(book.getImage() != null ? RANOBEDB_IMAGE_URL + book.getImage().getFilename() : null)
.description(book.getDescription()) .description(description)
.language(LanguageNormalizer.normalize(englishRelease != null ? englishRelease.getLang() : book.getLang())) .language(LanguageNormalizer.normalize(bookLang))
.seriesName(book.getSeries() != null ? book.getSeries().getTitle() : null) .seriesName(book.getSeries() != null ? book.getSeries().getTitle() : null)
.seriesNumber(seriesIndex != -1 ? seriesIndex + 1.0f : null) .seriesNumber(seriesIndex != -1 ? seriesIndex + 1.0f : null)
.seriesTotal(seriesBooks.isEmpty() ? null : seriesBooks.size()) .seriesTotal(seriesBooks.isEmpty() ? null : seriesBooks.size())
.publishedDate(englishRelease != null ? parseDate(englishRelease.getReleaseDate()) : parseDate(book.getCReleaseDate())) .publishedDate(release != null ? parseDate(release.getReleaseDate()) : parseDate(book.getCReleaseDate()))
.isbn13(release != null ? release.getIsbn13() : null)
.build(); .build();
} else { } else {
log.error("Ranobedb Get Book API returned status code {}", response.statusCode()); log.info("Ranobedb Get Book API returned status code {}", response.statusCode());
} }
} catch (IOException | InterruptedException e) { } catch (IOException | InterruptedException e) {
log.error("Error fetching metadata from Ranobedb Search API", e); log.error("Error fetching metadata from Ranobedb Search API", e);
@@ -280,14 +404,21 @@ public class RanobeDbParser implements BookParser {
if (dateInt == null || dateInt == 0) { if (dateInt == null || dateInt == 0) {
return null; return null;
} }
if (dateInt < 9999) {
dateInt = (dateInt * 10000) + 101;
} else if (dateInt < 999999) {
dateInt = (dateInt * 100) + 1;
}
// Parse date from integer of the format (YYYYMMDD)
int year = (int) (dateInt / 10000);
int month = (int) ((dateInt / 100) % 100);
int day = (int) (dateInt % 100);
try { try {
// Parse date from integer of the format (YYYYMMDD) return LocalDate.of(year, month, day);
return LocalDate.of( } catch (DateTimeException ignored) {
(int)(dateInt / 10000),
(int)((dateInt / 100) % 100),
(int)(dateInt % 100)
);
} catch (DateTimeParseException e) {
log.debug("Could not parse date: {}", dateInt); log.debug("Could not parse date: {}", dateInt);
return null; return null;
} }
@@ -10,19 +10,65 @@ import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import tools.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.io.InputStream;
import java.net.http.HttpClient;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
class RanobeDbParserTest { class RanobeDbParserTest {
@Spy
private ObjectMapper objectMapper = new ObjectMapper();
@Mock @Mock
private AppSettingService appSettingService; private AppSettingService appSettingService;
@Mock
private HttpClient httpClient;
@InjectMocks @InjectMocks
private RanobeDbParser parser; private RanobeDbParser parser;
@SuppressWarnings("unchecked")
private HttpResponse<String> getResponse(int statusCode, String payload) {
HttpResponse<String> mockResponse = mock(HttpResponse.class);
when(mockResponse.statusCode()).thenReturn(statusCode);
when(mockResponse.body()).thenReturn(payload);
return mockResponse;
}
private void mockResponse(String uri, int statusCode, String payload) throws IOException, InterruptedException {
HttpResponse<String> response = getResponse(statusCode, payload);
when(
httpClient.<String>send(
argThat(arg -> arg != null && arg.uri().toString().contains(uri)),
any()
)
).thenReturn(response);
}
private String readFixture(String fixtureName) throws IOException {
String filename = "ranobedb/" + fixtureName + ".fixture";
try (InputStream is = getClass().getClassLoader().getResourceAsStream(filename)) {
assert is != null;
return new String(is.readAllBytes(), StandardCharsets.UTF_8);
}
}
@BeforeEach @BeforeEach
void setUp() { void setUp() {
MockitoAnnotations.openMocks(this); MockitoAnnotations.openMocks(this);
@@ -48,16 +94,19 @@ class RanobeDbParserTest {
} }
@Test @Test
@Disabled("Integration test - requires network access to RanobeDB.org") void testFetchMetadata_Integration_RealBook() throws Exception {
void testFetchMetadata_Integration_RealBook() { mockResponse("/books", 200, readFixture("books.json"));
mockResponse("/book/", 200, readFixture("book.json"));
mockResponse("/staff", 200, readFixture("staff.json"));
// Given // Given
Book book = Book.builder() Book book = Book.builder()
.title("That Time I Got Reincarnated as a Slime, Vol. 1") .title("seishun buta yarou")
.build(); .build();
FetchMetadataRequest request = FetchMetadataRequest.builder() FetchMetadataRequest request = FetchMetadataRequest.builder()
.title("That Time I Got Reincarnated as a Slime, Vol. 1") .title("seishun buta yarou")
.author("Fuse") .author("Kamoshida Hajime")
.build(); .build();
// When // When
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
{
"books":[
{
"id":47136,
"image_id":47609,
"lang":"en",
"romaji":null,
"romaji_orig":"Seishun Buta Yarou wa Beach Queen no Yume o Minai+",
"title":"Rascal Does Not Dream of a Beach Queen +",
"title_orig":"青春ブタ野郎はビーチクイーンの夢を見ない+",
"c_release_date":20250710,
"olang":"ja",
"image":{
"id":47609,
"width":220,
"height":312,
"spoiler":true,
"nsfw":false,
"filename":"xUJgJ0V2i98PwYrx.jpg"
},
"sim_score":1
}
],
"count":"1",
"currentPage":1,
"totalPages":1
}
@@ -0,0 +1 @@
{"staff":[{"id":961,"name":"鴨志田一","romaji":"Kamoshida Hajime","sim_score":1}],"count":"1","currentPage":1,"totalPages":1}
@@ -148,6 +148,24 @@
</div> </div>
} }
</div> </div>
<div class="setting-item">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="ranobedbEnabled"></p-toggleswitch>
<span class="setting-label">RanobeDB</span>
</div>
@if (ranobedbEnabled) {
<div class="setting-options">
<div class="config-field">
<div class="config-label-row">
<p-toggleswitch [(ngModel)]="ranobedbPreferRomaji"></p-toggleswitch>
<span class="config-label">{{ t('ranobedbPreferRomajiLabel') }}</span>
</div>
<p class="config-description">{{ t('ranobedbPreferRomajiDesc') }}</p>
</div>
</div>
}
</div>
</div> </div>
</div> </div>
@@ -175,13 +193,6 @@
<span class="setting-label">Lubimyczytac</span> <span class="setting-label">Lubimyczytac</span>
</div> </div>
</div> </div>
<div class="setting-item simple-provider">
<div class="setting-header">
<p-toggleswitch [(ngModel)]="ranobedbEnabled"></p-toggleswitch>
<span class="setting-label">Ranobedb</span>
</div>
</div>
</div> </div>
</div> </div>
@@ -96,6 +96,7 @@ export class MetadataProviderSettingsComponent {
doubanEnabled: boolean = false; doubanEnabled: boolean = false;
lubimyCzytacEnabled: boolean = false; lubimyCzytacEnabled: boolean = false;
ranobedbEnabled: boolean = false; ranobedbEnabled: boolean = false;
ranobedbPreferRomaji: boolean = false;
googleApiKey: string = ''; googleApiKey: string = '';
private appSettingsService = inject(AppSettingsService); private appSettingsService = inject(AppSettingsService);
@@ -126,6 +127,7 @@ export class MetadataProviderSettingsComponent {
this.doubanEnabled = metadataProviderSettings?.douban?.enabled ?? false; this.doubanEnabled = metadataProviderSettings?.douban?.enabled ?? false;
this.lubimyCzytacEnabled = metadataProviderSettings?.lubimyczytac?.enabled ?? false; this.lubimyCzytacEnabled = metadataProviderSettings?.lubimyczytac?.enabled ?? false;
this.ranobedbEnabled = metadataProviderSettings?.ranobedb?.enabled ?? false; this.ranobedbEnabled = metadataProviderSettings?.ranobedb?.enabled ?? false;
this.ranobedbPreferRomaji = metadataProviderSettings?.ranobedb?.preferRomaji ?? false;
this.audibleEnabled = metadataProviderSettings?.audible?.enabled ?? false; this.audibleEnabled = metadataProviderSettings?.audible?.enabled ?? false;
this.selectedAudibleDomain = metadataProviderSettings?.audible?.domain ?? 'com'; this.selectedAudibleDomain = metadataProviderSettings?.audible?.domain ?? 'com';
} }
@@ -171,7 +173,10 @@ export class MetadataProviderSettingsComponent {
}, },
douban: {enabled: this.doubanEnabled}, douban: {enabled: this.doubanEnabled},
lubimyczytac: {enabled: this.lubimyCzytacEnabled}, lubimyczytac: {enabled: this.lubimyCzytacEnabled},
ranobedb: {enabled: this.ranobedbEnabled}, ranobedb: {
enabled: this.ranobedbEnabled,
preferRomaji: this.ranobedbPreferRomaji
},
audible: { audible: {
enabled: this.audibleEnabled, enabled: this.audibleEnabled,
domain: this.selectedAudibleDomain domain: this.selectedAudibleDomain
@@ -81,6 +81,7 @@ export interface Goodreads {
export interface Ranobedb { export interface Ranobedb {
enabled: boolean; enabled: boolean;
preferRomaji: boolean;
} }
export interface Hardcover { export interface Hardcover {
+3 -1
View File
@@ -61,7 +61,9 @@
"googleApiPlaceholder": "Enter Google Books API key", "googleApiPlaceholder": "Enter Google Books API key",
"apiToken": "API Token", "apiToken": "API Token",
"hardcoverPlaceholder": "Enter Hardcover API token", "hardcoverPlaceholder": "Enter Hardcover API token",
"comicvinePlaceholder": "Enter Comic Vine API token" "comicvinePlaceholder": "Enter Comic Vine API token",
"ranobedbPreferRomajiLabel": "Prefer Romaji",
"ranobedbPreferRomajiDesc": "When enabled, Japanese releases use romanization of Japanese characters where possible."
}, },
"publicReviews": { "publicReviews": {
"sectionTitle": "Public Reviews", "sectionTitle": "Public Reviews",