From b68e022fc01ba26ba8d91164beef699902102c4b Mon Sep 17 00:00:00 2001 From: NichaesMol <286669527+NichaesMol@users.noreply.github.com> Date: Sat, 18 Jul 2026 10:01:56 +0200 Subject: [PATCH] feat(metadata): RanobeDB search improvements (#1804) Co-authored-by: James Ward --- .../settings/MetadataProviderSettings.java | 1 + .../metadata/parser/RanobeDbParser.java | 251 +++++++++++++----- .../metadata/parser/RanobeDBParserTest.java | 59 +++- .../test/resources/ranobedb/book.json.fixture | 1 + .../resources/ranobedb/books.json.fixture | 27 ++ .../resources/ranobedb/staff.json.fixture | 1 + .../metadata-provider-settings.component.html | 25 +- .../metadata-provider-settings.component.ts | 7 +- .../app/shared/model/app-settings.model.ts | 1 + frontend/src/i18n/en/settings-metadata.json | 4 +- 10 files changed, 303 insertions(+), 74 deletions(-) create mode 100644 backend/src/test/resources/ranobedb/book.json.fixture create mode 100644 backend/src/test/resources/ranobedb/books.json.fixture create mode 100644 backend/src/test/resources/ranobedb/staff.json.fixture diff --git a/backend/src/main/java/org/booklore/model/dto/settings/MetadataProviderSettings.java b/backend/src/main/java/org/booklore/model/dto/settings/MetadataProviderSettings.java index 0bcf3645a..add92c577 100644 --- a/backend/src/main/java/org/booklore/model/dto/settings/MetadataProviderSettings.java +++ b/backend/src/main/java/org/booklore/model/dto/settings/MetadataProviderSettings.java @@ -50,6 +50,7 @@ public class MetadataProviderSettings { @Data public static class Ranobedb { private boolean enabled; + private boolean preferRomaji; } @Data diff --git a/backend/src/main/java/org/booklore/service/metadata/parser/RanobeDbParser.java b/backend/src/main/java/org/booklore/service/metadata/parser/RanobeDbParser.java index 171e94972..ca09abaa4 100644 --- a/backend/src/main/java/org/booklore/service/metadata/parser/RanobeDbParser.java +++ b/backend/src/main/java/org/booklore/service/metadata/parser/RanobeDbParser.java @@ -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 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 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 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 getMetadataListByTerm(String term, Boolean fetchTop) { - log.info("Ranobedb: Fetching metadata for term: '{}'", term); + private List 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 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 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 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 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 parseRanobeDbApiResponse(String responseBody, Boolean fetchTop) throws IOException { + private List 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 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 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 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 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; } diff --git a/backend/src/test/java/org/booklore/service/metadata/parser/RanobeDBParserTest.java b/backend/src/test/java/org/booklore/service/metadata/parser/RanobeDBParserTest.java index b2a8f8890..b00eca4b5 100644 --- a/backend/src/test/java/org/booklore/service/metadata/parser/RanobeDBParserTest.java +++ b/backend/src/test/java/org/booklore/service/metadata/parser/RanobeDBParserTest.java @@ -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 getResponse(int statusCode, String payload) { + HttpResponse 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 response = getResponse(statusCode, payload); + when( + httpClient.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 diff --git a/backend/src/test/resources/ranobedb/book.json.fixture b/backend/src/test/resources/ranobedb/book.json.fixture new file mode 100644 index 000000000..8f4712537 --- /dev/null +++ b/backend/src/test/resources/ranobedb/book.json.fixture @@ -0,0 +1 @@ +{"book":{"description":"It’s the day of the Minegahara Sports Festival! Kaede, Rio, and Yuuma are all on the blue team with Sakuta. That is, until he gets stuck filling in for a beach volleyball junior athlete named Minagi Ootsu—who’s nowhere to be found. The festival goes on with the Ball Toss and the Scavenger Hunt, and finally, Sakuta is free to eat lunch with Mai. On the way there, however, he happens upon Minagi in the last place he would have expected…\n\n[From [Yen Press](https://yenpress.com/titles/9798855434477-rascal-does-not-dream-of-a-beach-queen-light-novel)]","description_ja":"貴重な特典小説に書き下ろしをプラスした、ファン待望の『青ブタ』短編集!\n\nその日は峰ヶ原高校の体育祭。咲太はいつも通り、かえでに起こされ学校に向かう。理央や佑真と同じ青組で応援を決め込むも、憂鬱な相談が舞い込んで……。\n「玉入れのメンバーに欠員が出たから、咲太が出てくれ」\n 任されたのは、急に姿を消した同級生にしてビーチバレーのジュニア選手でもある大津美凪の代役。朋絵と玉入れをしたり、のどかと借り物競争に出たりして、ようやく訪れた麻衣とのお弁当タイム。\n ところが、その途中立ち寄ったあるところで美凪の姿を発見し――!?\n 書き下ろし『トロピカルサマー』も収録する『青ブタ』初の短編集をお届け!\n\n[From [BookWalker](https://bookwalker.jp/defd390ca9-4e03-40fd-bd97-a27fb2210a06/)]","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,"c_release_dates":{"en":20260811,"ja":20250710,"zh-Hant":20260205},"olang":"ja","locked":false,"hidden":false,"image":{"id":47609,"width":220,"height":312,"spoiler":true,"nsfw":false,"filename":"xUJgJ0V2i98PwYrx.jpg"},"rating":{"score":7,"count":1},"num_reviews":{"count":0},"user_stats_score":[{"gs":10,"count":0},{"gs":9,"count":0},{"gs":8,"count":0},{"gs":7,"count":1},{"gs":6,"count":0},{"gs":5,"count":0},{"gs":4,"count":0},{"gs":3,"count":0},{"gs":2,"count":0},{"gs":1,"count":0}],"user_stats_label":[{"label_id":1,"count":2},{"label_id":2,"count":1},{"label_id":3,"count":8},{"label_id":6,"count":1}],"titles":[{"book_id":47136,"lang":"ja","official":true,"title":"青春ブタ野郎はビーチクイーンの夢を見ない+","romaji":"Seishun Buta Yarou wa Beach Queen no Yume o Minai+"},{"book_id":47136,"lang":"en","official":true,"title":"Rascal Does Not Dream of a Beach Queen +","romaji":null},{"book_id":47136,"lang":"zh-Hant","official":true,"title":"青春豬頭少年不會夢到白沙灘女王+","romaji":null}],"editions":[{"book_id":47136,"eid":0,"title":"Original edition","lang":null,"staff":[{"role_type":"author","name":"鴨志田一","romaji":"Kamoshida Hajime","staff_id":961,"staff_alias_id":961,"note":""},{"role_type":"artist","name":"溝口ケージ","romaji":"Mizoguchi Keji","staff_id":1466,"staff_alias_id":1466,"note":""}]},{"book_id":47136,"eid":1,"title":"Traditional Chinese edition","lang":"zh-Hant","staff":[{"role_type":"translator","name":"哈泥蛙","romaji":"Haniwa","staff_id":14102,"staff_alias_id":14395,"note":""}]},{"book_id":47136,"eid":2,"title":"Yen Press's translation","lang":"en","staff":[{"role_type":"translator","name":"Andrew Cunningham","romaji":null,"staff_id":195,"staff_alias_id":195,"note":""},{"role_type":"narrator","name":"Andrew Grace","romaji":null,"staff_id":3196,"staff_alias_id":3196,"note":"Audiobook"}]}],"releases":[{"id":94984,"release_date":20250710,"pages":291,"format":"digital","lang":"ja","locked":false,"hidden":false,"description":"","title":"青春ブタ野郎はビーチクイーンの夢を見ない+","romaji":"Seishun Buta Yarou wa Beach Queen no Yume o Minai+","isbn13":null,"website":"https://www.kadokawa.co.jp/product/322501000124/","amazon":"https://www.amazon.co.jp/dp/B0FFK6VGML","bookwalker":"https://bookwalker.jp/defd390ca9-4e03-40fd-bd97-a27fb2210a06/","rakuten":"https://books.rakuten.co.jp/rk/ea1efb32f2003014b3967aa123aeea49/"},{"id":94985,"release_date":20250710,"pages":296,"format":"print","lang":"ja","locked":false,"hidden":false,"description":"","title":"青春ブタ野郎はビーチクイーンの夢を見ない+","romaji":"Seishun Buta Yarou wa Beach Queen no Yume o Minai+","isbn13":"9784049164046","website":"https://www.kadokawa.co.jp/product/322501000103/","amazon":"https://www.amazon.co.jp/dp/4049164043","bookwalker":null,"rakuten":"https://books.rakuten.co.jp/rb/18208993/"},{"id":103089,"release_date":20260205,"pages":null,"format":"print","lang":"zh-Hant","locked":false,"hidden":false,"description":"","title":"青春豬頭少年不會夢到白沙灘女王+","romaji":null,"isbn13":"9786264359368","website":"https://www.kadokawa.com.tw/products/9786264359368","amazon":null,"bookwalker":null,"rakuten":null},{"id":103090,"release_date":20260205,"pages":null,"format":"print","lang":"zh-Hant","locked":false,"hidden":false,"description":"Special edition that comes with a couple of gifts.","title":"青春豬頭少年不會夢到白沙灘女王+(特裝版)","romaji":null,"isbn13":"4711289627944","website":"https://www.kadokawa.com.tw/products/4711289627944","amazon":null,"bookwalker":null,"rakuten":null},{"id":107242,"release_date":20260206,"pages":null,"format":"digital","lang":"zh-Hant","locked":false,"hidden":false,"description":"","title":"青春豬頭少年不會夢到白沙灘女王+","romaji":null,"isbn13":"9786264450454","website":null,"amazon":null,"bookwalker":"https://www.bookwalker.com.tw/product/279742","rakuten":null},{"id":106475,"release_date":20260811,"pages":null,"format":"digital","lang":"en","locked":false,"hidden":false,"description":"","title":"Rascal Does Not Dream of a Beach Queen +","romaji":null,"isbn13":"9798855434460","website":"https://yenpress.com/titles/9798855434460-rascal-does-not-dream-of-a-beach-queen-light-novel","amazon":null,"bookwalker":null,"rakuten":null},{"id":106476,"release_date":20260811,"pages":null,"format":"print","lang":"en","locked":false,"hidden":false,"description":"","title":"Rascal Does Not Dream of a Beach Queen +","romaji":null,"isbn13":"9798855434453","website":"https://yenpress.com/titles/9798855434453-rascal-does-not-dream-of-a-beach-queen-light-novel","amazon":null,"bookwalker":null,"rakuten":null},{"id":106474,"release_date":20260818,"pages":null,"format":"audio","lang":"en","locked":false,"hidden":false,"description":"","title":"Rascal Does Not Dream of a Beach Queen +","romaji":null,"isbn13":"9798855434477","website":"https://yenpress.com/titles/9798855434477-rascal-does-not-dream-of-a-beach-queen-light-novel","amazon":null,"bookwalker":null,"rakuten":null}],"publishers":[{"id":9,"name":"KADOKAWA","romaji":null,"publisher_type":"publisher","lang":"ja"},{"id":41,"name":"Yen Press","romaji":null,"publisher_type":"publisher","lang":"en"},{"id":575,"name":"台灣角川","romaji":"Kadokawa Taiwan","publisher_type":"publisher","lang":"zh-Hant"},{"id":19,"name":"電撃文庫","romaji":"Dengeki Bunko","publisher_type":"imprint","lang":"ja"},{"id":42,"name":"Yen On","romaji":null,"publisher_type":"imprint","lang":"en"},{"id":43,"name":"Yen Audio","romaji":null,"publisher_type":"imprint","lang":"en"},{"id":576,"name":"Kadokawa Fantastic Novels","romaji":null,"publisher_type":"imprint","lang":"zh-Hant"}],"series":{"books":[{"id":12431,"title":"Rascal Does Not Dream of Bunny Girl Senpai","title_orig":"青春ブタ野郎はバニーガール先輩の夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Bunny Girl Senpai no Yume o Minai","lang":"en","image":{"id":12431,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"Ssz93YlIk25J8Pdc.jpg"}},{"id":13140,"title":"Rascal Does Not Dream of Petite Devil Kohai","title_orig":"青春ブタ野郎はプチデビル後輩の夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Petit Devil Kouhai no Yume o Minai","lang":"en","image":{"id":13140,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"nuaGxRRu0Ypk9G3o.jpg"}},{"id":14123,"title":"Rascal Does Not Dream of Logical Witch","title_orig":"青春ブタ野郎はロジカルウィッチの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Logical Witch no Yume o Minai","lang":"en","image":{"id":14123,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"WuJxRFMQewmLHne1.jpg"}},{"id":14825,"title":"Rascal Does Not Dream of Siscon Idol","title_orig":"青春ブタ野郎はシスコンアイドルの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Siscon Idol no Yume o Minai","lang":"en","image":{"id":14825,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"c1AXeseeHlGpSUQX.jpg"}},{"id":15651,"title":"Rascal Does Not Dream of a Sister Home Alone","title_orig":"青春ブタ野郎はおるすばん妹の夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Orusuban Imouto no Yume o Minai","lang":"en","image":{"id":15651,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"IEvW614GENiAnPh7.jpg"}},{"id":17635,"title":"Rascal Does Not Dream of a Dreaming Girl","title_orig":"青春ブタ野郎はゆめみる少女の夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Yumemiru Shoujo no Yume o Minai","lang":"en","image":{"id":17635,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"l7xMQXBqrDu2vsSm.jpg"}},{"id":18683,"title":"Rascal Does Not Dream of His First Love","title_orig":"青春ブタ野郎はハツコイ少女の夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Hatsukoi Shoujo no Yume o Minai","lang":"en","image":{"id":18683,"width":240,"height":343,"spoiler":false,"nsfw":false,"filename":"IqCRXO3FG58AhnXb.jpg"}},{"id":22868,"title":"Rascal Does Not Dream of a Sister Venturing Out","title_orig":"青春ブタ野郎はおでかけシスターの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Odekake Sister no Yume o Minai","lang":"en","image":{"id":22868,"width":240,"height":341,"spoiler":false,"nsfw":false,"filename":"LVVps280cbGlpILN.jpg"}},{"id":24470,"title":"Rascal Does Not Dream of a Knapsack Kid","title_orig":"青春ブタ野郎はランドセルガールの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Randosel Girl no Yume o Minai","lang":"en","image":{"id":24470,"width":240,"height":341,"spoiler":false,"nsfw":false,"filename":"dBmrSw4Xlh6muXJU.jpg"}},{"id":28688,"title":"Rascal Does Not Dream of a Lost Singer","title_orig":"青春ブタ野郎は迷えるシンガーの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Mayoeru Singer no Yume o Minai","lang":"en","image":{"id":28688,"width":240,"height":341,"spoiler":false,"nsfw":false,"filename":"RgOBrq9oxWdAQR6N.jpg"}},{"id":31128,"title":"Rascal Does Not Dream of a Nightingale","title_orig":"青春ブタ野郎はナイチンゲールの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Nightingale no Yume o Minai","lang":"en","image":{"id":31128,"width":240,"height":340,"spoiler":false,"nsfw":false,"filename":"c7VUKBeJxKQfR7DL.jpg"}},{"id":37104,"title":"Rascal Does Not Dream of His Student","title_orig":"青春ブタ野郎はマイスチューデントの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa My Student no Yume o Minai","lang":"en","image":{"id":37104,"width":240,"height":340,"spoiler":false,"nsfw":false,"filename":"KNVLttSh7s7sKiMj.jpg"}},{"id":39075,"title":"Rascal Does Not Dream of Santa Claus","title_orig":"青春ブタ野郎はサンタクロースの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Santa Claus no Yume o Minai","lang":"en","image":{"id":39075,"width":240,"height":340,"spoiler":false,"nsfw":false,"filename":"pt9g5Jg4Kqt2G7UA.jpg"}},{"id":42984,"title":"Rascal Does Not Dream of His Girlfriend","title_orig":"青春ブタ野郎はガールフレンドの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Girlfriend no Yume o Minai","lang":"en","image":{"id":42984,"width":240,"height":340,"spoiler":false,"nsfw":false,"filename":"oJ93tqDHFcQkoypF.jpg"}},{"id":44067,"title":"Rascal Does Not Dream of a Dear Friend","title_orig":"青春ブタ野郎はディアフレンドの夢を見ない","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Dear Friend no Yume o Minai","lang":"en","image":{"id":44085,"width":240,"height":340,"spoiler":false,"nsfw":false,"filename":"UZy6eQrZXHoO65qj.jpg"}},{"id":47136,"title":"Rascal Does Not Dream of a Beach Queen +","title_orig":"青春ブタ野郎はビーチクイーンの夢を見ない+","romaji":null,"romaji_orig":"Seishun Buta Yarou wa Beach Queen no Yume o Minai+","lang":"en","image":{"id":47609,"width":220,"height":312,"spoiler":true,"nsfw":false,"filename":"xUJgJ0V2i98PwYrx.jpg"}}],"tags":[{"name":"comedy","ttype":"genre","id":4},{"name":"drama","ttype":"genre","id":5},{"name":"fantasy","ttype":"genre","id":7},{"name":"romance","ttype":"genre","id":11},{"name":"slice of life","ttype":"genre","id":13},{"name":"supernatural","ttype":"genre","id":14},{"name":"anime tie-in","ttype":"tag","id":26},{"name":"male protagonist","ttype":"tag","id":82},{"name":"manga tie-in","ttype":"tag","id":145}],"title":"Rascal Does Not Dream","title_orig":"『青春ブタ野郎』シリーズ","romaji":null,"romaji_orig":"Seishun Buta Yarou Series","id":3486,"lang":"en"}}} \ No newline at end of file diff --git a/backend/src/test/resources/ranobedb/books.json.fixture b/backend/src/test/resources/ranobedb/books.json.fixture new file mode 100644 index 000000000..7327cf3e3 --- /dev/null +++ b/backend/src/test/resources/ranobedb/books.json.fixture @@ -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 +} \ No newline at end of file diff --git a/backend/src/test/resources/ranobedb/staff.json.fixture b/backend/src/test/resources/ranobedb/staff.json.fixture new file mode 100644 index 000000000..a5632f3bf --- /dev/null +++ b/backend/src/test/resources/ranobedb/staff.json.fixture @@ -0,0 +1 @@ +{"staff":[{"id":961,"name":"鴨志田一","romaji":"Kamoshida Hajime","sim_score":1}],"count":"1","currentPage":1,"totalPages":1} \ No newline at end of file diff --git a/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.html b/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.html index 645b35941..c6e6068e7 100644 --- a/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.html +++ b/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.html @@ -148,6 +148,24 @@ } + +
+
+ + RanobeDB +
+ @if (ranobedbEnabled) { +
+
+
+ + {{ t('ranobedbPreferRomajiLabel') }} +
+

{{ t('ranobedbPreferRomajiDesc') }}

+
+
+ } +
@@ -175,13 +193,6 @@ Lubimyczytac - -
-
- - Ranobedb -
-
diff --git a/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.ts b/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.ts index b62a86f1e..09a1fea7d 100644 --- a/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.ts +++ b/frontend/src/app/features/settings/global-preferences/metadata-provider-settings/metadata-provider-settings.component.ts @@ -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 diff --git a/frontend/src/app/shared/model/app-settings.model.ts b/frontend/src/app/shared/model/app-settings.model.ts index 5d41f248e..58889157e 100644 --- a/frontend/src/app/shared/model/app-settings.model.ts +++ b/frontend/src/app/shared/model/app-settings.model.ts @@ -81,6 +81,7 @@ export interface Goodreads { export interface Ranobedb { enabled: boolean; + preferRomaji: boolean; } export interface Hardcover { diff --git a/frontend/src/i18n/en/settings-metadata.json b/frontend/src/i18n/en/settings-metadata.json index d7098ac25..8080dfe10 100644 --- a/frontend/src/i18n/en/settings-metadata.json +++ b/frontend/src/i18n/en/settings-metadata.json @@ -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",