Compare commits
1 Commits
main
...
refactor-a
| Author | SHA1 | Date | |
|---|---|---|---|
| 0c056541bd |
@ -48,54 +48,66 @@ public class MangaResolutionService {
|
||||
}
|
||||
|
||||
private Optional<ProviderResult> searchMangaOnAniList(String title) {
|
||||
var searchResults = aniListService.searchMangaByTitle(title);
|
||||
if (searchResults.isEmpty()) {
|
||||
try {
|
||||
var searchResults = aniListService.searchMangaByTitle(title);
|
||||
|
||||
if (searchResults.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var matchResponse =
|
||||
titleMatcherService.findBestMatch(
|
||||
TitleMatcherService.TitleMatchRequest.builder()
|
||||
.title(title)
|
||||
.options(searchResults.keySet())
|
||||
.build());
|
||||
|
||||
if (!matchResponse.matchFound()) {
|
||||
log.warn("No title match found for manga with title {} on AniList", title);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var matchedManga = searchResults.get(matchResponse.bestMatch());
|
||||
|
||||
var bestTitle =
|
||||
nonNull(matchedManga.title().romaji())
|
||||
? matchedManga.title().romaji()
|
||||
: matchedManga.title().english();
|
||||
|
||||
return Optional.of(new ProviderResult(bestTitle, matchedManga.id()));
|
||||
} catch (Exception e) {
|
||||
log.error("Error searching for manga with title {} on AniList: {}", title, e.getMessage());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var matchResponse =
|
||||
titleMatcherService.findBestMatch(
|
||||
TitleMatcherService.TitleMatchRequest.builder()
|
||||
.title(title)
|
||||
.options(searchResults.keySet())
|
||||
.build());
|
||||
|
||||
if (!matchResponse.matchFound()) {
|
||||
log.warn("No title match found for manga with title {} on AniList", title);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var matchedManga = searchResults.get(matchResponse.bestMatch());
|
||||
|
||||
var bestTitle =
|
||||
nonNull(matchedManga.title().romaji())
|
||||
? matchedManga.title().romaji()
|
||||
: matchedManga.title().english();
|
||||
|
||||
return Optional.of(new ProviderResult(bestTitle, matchedManga.id()));
|
||||
}
|
||||
|
||||
private Optional<ProviderResult> searchMangaOnMyAnimeList(String title) {
|
||||
var searchResults = myAnimeListService.searchMangaByTitle(title);
|
||||
if (searchResults.isEmpty()) {
|
||||
try {
|
||||
var searchResults = myAnimeListService.searchMangaByTitle(title);
|
||||
if (searchResults.isEmpty()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var matchResponse =
|
||||
titleMatcherService.findBestMatch(
|
||||
TitleMatcherService.TitleMatchRequest.builder()
|
||||
.title(title)
|
||||
.options(searchResults.keySet())
|
||||
.build());
|
||||
if (!matchResponse.matchFound()) {
|
||||
log.warn("No title match found for manga with title {} on MyAnimeList", title);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var bestTitle = matchResponse.bestMatch();
|
||||
var malId = searchResults.get(bestTitle);
|
||||
|
||||
return Optional.of(new ProviderResult(bestTitle, malId));
|
||||
} catch (Exception e) {
|
||||
log.error(
|
||||
"Error searching for manga with title {} on MyAnimeList: {}", title, e.getMessage());
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var matchResponse =
|
||||
titleMatcherService.findBestMatch(
|
||||
TitleMatcherService.TitleMatchRequest.builder()
|
||||
.title(title)
|
||||
.options(searchResults.keySet())
|
||||
.build());
|
||||
if (!matchResponse.matchFound()) {
|
||||
log.warn("No title match found for manga with title {} on MyAnimeList", title);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
var bestTitle = matchResponse.bestMatch();
|
||||
var malId = searchResults.get(bestTitle);
|
||||
|
||||
return Optional.of(new ProviderResult(bestTitle, malId));
|
||||
}
|
||||
|
||||
public Manga findOrCreateManga(Long aniListId, Long malId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user