feat(metadata): RanobeDB search improvements (#1804)
Co-authored-by: James Ward <james@notjam.es>
This commit is contained in:
@@ -50,6 +50,7 @@ public class MetadataProviderSettings {
|
||||
@Data
|
||||
public static class Ranobedb {
|
||||
private boolean enabled;
|
||||
private boolean preferRomaji;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
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.extern.slf4j.Slf4j;
|
||||
import org.booklore.model.dto.Book;
|
||||
@@ -20,11 +22,14 @@ import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.DateTimeException;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -39,18 +44,24 @@ public class RanobeDbParser implements BookParser {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
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
|
||||
private static final int MAX_REQUESTS_PER_SECOND = 2;
|
||||
private static final long RATE_LIMIT_WINDOW_MS = 1000; // 1 second in milliseconds
|
||||
private final AtomicLong lastRequestTime = new AtomicLong(0);
|
||||
private final AtomicLong tokenCount = new AtomicLong(MAX_REQUESTS_PER_SECOND);
|
||||
|
||||
private record SearchTerms(String title, Integer authorId) {}
|
||||
|
||||
@Override
|
||||
public List<BookMetadata> fetchMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||
|
||||
String searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
SearchTerms searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
if (searchTerm == null) {
|
||||
log.warn("No valid search term provided for metadata fetch.");
|
||||
return Collections.emptyList();
|
||||
@@ -60,7 +71,7 @@ public class RanobeDbParser implements BookParser {
|
||||
|
||||
@Override
|
||||
public BookMetadata fetchTopMetadata(Book book, FetchMetadataRequest fetchMetadataRequest) {
|
||||
String searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
SearchTerms searchTerm = getSearchTerm(book, fetchMetadataRequest);
|
||||
if (searchTerm == null) {
|
||||
log.warn("No valid search term provided for metadata fetch.");
|
||||
return null;
|
||||
@@ -68,13 +79,13 @@ public class RanobeDbParser implements BookParser {
|
||||
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
|
||||
@@ -90,7 +101,7 @@ public class RanobeDbParser implements BookParser {
|
||||
tokenCount.compareAndSet(currentTokens, newTokens);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Try to consume a token
|
||||
long currentTokens = tokenCount.get();
|
||||
if (currentTokens > 0) {
|
||||
@@ -112,24 +123,38 @@ public class RanobeDbParser implements BookParser {
|
||||
}
|
||||
}
|
||||
|
||||
public List<BookMetadata> getMetadataListByTerm(String term, Boolean fetchTop) {
|
||||
log.info("Ranobedb: Fetching metadata for term: '{}'", term);
|
||||
private List<BookMetadata> getMetadataListByTerm(SearchTerms 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();
|
||||
List<BookMetadata> metadataList = getMetadataList(term, fetchTop);
|
||||
|
||||
if (metadataList != null && metadataList.isEmpty() && term.authorId() != null) {
|
||||
log.info("RanobeDB: Failed to find results with author, trying again with only the title.");
|
||||
metadataList = getMetadataList(new SearchTerms(term.title(), null), fetchTop);
|
||||
}
|
||||
|
||||
if (metadataList != null) return metadataList;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private List<BookMetadata> getMetadataList(SearchTerms term, boolean fetchTop) {
|
||||
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()
|
||||
.uri(uri)
|
||||
@@ -141,7 +166,7 @@ public class RanobeDbParser implements BookParser {
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
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;
|
||||
} else {
|
||||
log.error("Ranobedb Search API returned status code {}", response.statusCode());
|
||||
@@ -149,33 +174,117 @@ public class RanobeDbParser implements BookParser {
|
||||
} catch (IOException | InterruptedException 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()) {
|
||||
return request.getTitle();
|
||||
title = request.getTitle();
|
||||
} 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;
|
||||
}
|
||||
|
||||
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);
|
||||
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()))
|
||||
.filter(Objects::nonNull)
|
||||
.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) {
|
||||
|
||||
try {
|
||||
@@ -197,28 +306,29 @@ public class RanobeDbParser implements BookParser {
|
||||
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() == 200) {
|
||||
RanobedbBookResponse responstObj = objectMapper.readValue(response.body(), RanobedbBookResponse.class);
|
||||
RanobedbBookResponse.Book book = responstObj.getBook();
|
||||
RanobedbBookResponse responseObj = objectMapper.readValue(response.body(), RanobedbBookResponse.class);
|
||||
RanobedbBookResponse.Book book = responseObj.getBook();
|
||||
if (book == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
RanobedbBookResponse.TitleEntry englishTitleEntry = book.getTitles().stream()
|
||||
.filter(titleEntry -> "en".equalsIgnoreCase(titleEntry.getLang()))
|
||||
.filter(titleEntry -> titleEntry.getOfficial())
|
||||
RanobedbBookResponse.Release release = book.getReleases().stream()
|
||||
.filter(Objects::nonNull)
|
||||
.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()
|
||||
.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);
|
||||
String publisherName = null;
|
||||
if (publisher != null) {
|
||||
publisherName = getPreferredValue(publisher.getRomaji(), publisher.getName());
|
||||
}
|
||||
|
||||
List<RanobedbBookResponse.SeriesBook> seriesBooks = book.getSeries() != null ? book.getSeries().getBooks() : List.of();
|
||||
int seriesIndex = IntStream.range(0, seriesBooks.size())
|
||||
@@ -229,7 +339,7 @@ public class RanobeDbParser implements BookParser {
|
||||
List<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())
|
||||
.map(staff -> getPreferredValue(staff.getRomaji(), staff.getName()))
|
||||
.toList();
|
||||
|
||||
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()))
|
||||
.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;
|
||||
if (book.getSeries() != null && book.getSeries().getTitle() != null && title.startsWith(book.getSeries().getTitle())) {
|
||||
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()
|
||||
.provider(MetadataProvider.Ranobedb)
|
||||
.ranobedbId(String.valueOf(book.getId()))
|
||||
@@ -257,17 +380,18 @@ public class RanobeDbParser implements BookParser {
|
||||
.subtitle(subtitle)
|
||||
.authors(authors)
|
||||
.categories(genres)
|
||||
.publisher(englishPublisher != null ? englishPublisher.getName() : null)
|
||||
.publisher(publisherName)
|
||||
.thumbnailUrl(book.getImage() != null ? RANOBEDB_IMAGE_URL + book.getImage().getFilename() : null)
|
||||
.description(book.getDescription())
|
||||
.language(LanguageNormalizer.normalize(englishRelease != null ? englishRelease.getLang() : book.getLang()))
|
||||
.description(description)
|
||||
.language(LanguageNormalizer.normalize(bookLang))
|
||||
.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()))
|
||||
.publishedDate(release != null ? parseDate(release.getReleaseDate()) : parseDate(book.getCReleaseDate()))
|
||||
.isbn13(release != null ? release.getIsbn13() : null)
|
||||
.build();
|
||||
} 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) {
|
||||
log.error("Error fetching metadata from Ranobedb Search API", e);
|
||||
@@ -280,14 +404,21 @@ public class RanobeDbParser implements BookParser {
|
||||
if (dateInt == null || dateInt == 0) {
|
||||
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 {
|
||||
// Parse date from integer of the format (YYYYMMDD)
|
||||
return LocalDate.of(
|
||||
(int)(dateInt / 10000),
|
||||
(int)((dateInt / 100) % 100),
|
||||
(int)(dateInt % 100)
|
||||
);
|
||||
} catch (DateTimeParseException e) {
|
||||
return LocalDate.of(year, month, day);
|
||||
} catch (DateTimeException ignored) {
|
||||
log.debug("Could not parse date: {}", dateInt);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -10,19 +10,65 @@ import org.junit.jupiter.api.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
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 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 {
|
||||
@Spy
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@Mock
|
||||
private AppSettingService appSettingService;
|
||||
|
||||
@Mock
|
||||
private HttpClient httpClient;
|
||||
|
||||
@InjectMocks
|
||||
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
|
||||
void setUp() {
|
||||
MockitoAnnotations.openMocks(this);
|
||||
@@ -48,16 +94,19 @@ class RanobeDbParserTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled("Integration test - requires network access to RanobeDB.org")
|
||||
void testFetchMetadata_Integration_RealBook() {
|
||||
void testFetchMetadata_Integration_RealBook() throws Exception {
|
||||
mockResponse("/books", 200, readFixture("books.json"));
|
||||
mockResponse("/book/", 200, readFixture("book.json"));
|
||||
mockResponse("/staff", 200, readFixture("staff.json"));
|
||||
|
||||
// Given
|
||||
Book book = Book.builder()
|
||||
.title("That Time I Got Reincarnated as a Slime, Vol. 1")
|
||||
.title("seishun buta yarou")
|
||||
.build();
|
||||
|
||||
FetchMetadataRequest request = FetchMetadataRequest.builder()
|
||||
.title("That Time I Got Reincarnated as a Slime, Vol. 1")
|
||||
.author("Fuse")
|
||||
.title("seishun buta yarou")
|
||||
.author("Kamoshida Hajime")
|
||||
.build();
|
||||
|
||||
// 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}
|
||||
+18
-7
@@ -148,6 +148,24 @@
|
||||
</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>
|
||||
|
||||
@@ -175,13 +193,6 @@
|
||||
<span class="setting-label">Lubimyczytac</span>
|
||||
</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>
|
||||
|
||||
|
||||
+6
-1
@@ -96,6 +96,7 @@ export class MetadataProviderSettingsComponent {
|
||||
doubanEnabled: boolean = false;
|
||||
lubimyCzytacEnabled: boolean = false;
|
||||
ranobedbEnabled: boolean = false;
|
||||
ranobedbPreferRomaji: boolean = false;
|
||||
googleApiKey: string = '';
|
||||
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
@@ -126,6 +127,7 @@ export class MetadataProviderSettingsComponent {
|
||||
this.doubanEnabled = metadataProviderSettings?.douban?.enabled ?? false;
|
||||
this.lubimyCzytacEnabled = metadataProviderSettings?.lubimyczytac?.enabled ?? false;
|
||||
this.ranobedbEnabled = metadataProviderSettings?.ranobedb?.enabled ?? false;
|
||||
this.ranobedbPreferRomaji = metadataProviderSettings?.ranobedb?.preferRomaji ?? false;
|
||||
this.audibleEnabled = metadataProviderSettings?.audible?.enabled ?? false;
|
||||
this.selectedAudibleDomain = metadataProviderSettings?.audible?.domain ?? 'com';
|
||||
}
|
||||
@@ -171,7 +173,10 @@ export class MetadataProviderSettingsComponent {
|
||||
},
|
||||
douban: {enabled: this.doubanEnabled},
|
||||
lubimyczytac: {enabled: this.lubimyCzytacEnabled},
|
||||
ranobedb: {enabled: this.ranobedbEnabled},
|
||||
ranobedb: {
|
||||
enabled: this.ranobedbEnabled,
|
||||
preferRomaji: this.ranobedbPreferRomaji
|
||||
},
|
||||
audible: {
|
||||
enabled: this.audibleEnabled,
|
||||
domain: this.selectedAudibleDomain
|
||||
|
||||
@@ -81,6 +81,7 @@ export interface Goodreads {
|
||||
|
||||
export interface Ranobedb {
|
||||
enabled: boolean;
|
||||
preferRomaji: boolean;
|
||||
}
|
||||
|
||||
export interface Hardcover {
|
||||
|
||||
@@ -61,7 +61,9 @@
|
||||
"googleApiPlaceholder": "Enter Google Books API key",
|
||||
"apiToken": "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": {
|
||||
"sectionTitle": "Public Reviews",
|
||||
|
||||
Reference in New Issue
Block a user