feat(MangaDexProvider): support multiple languages for chapter filtering

This commit is contained in:
Rodrigo Verdiani 2025-12-31 13:47:01 -03:00
parent 9e44f031d2
commit b238f66e08

View File

@ -49,14 +49,16 @@ public class MangaDexProvider implements ContentProvider, ManualImportContentPro
log.warn(e.getMessage()); log.warn(e.getMessage());
} }
// TODO this is filtering only pt-br chapters for now, we may want to make this configurable // NOTE: this is getting only pt-br and en chapters for now, we may want to make this configurable
// later // later
var languagesToImport = Map.of("pt-br", "pt-BR", "en", "en-US");
return mangas.stream() return mangas.stream()
.filter( .filter(
c -> c ->
c.type().equals("chapter") c.type().equals("chapter")
&& c.attributes().isUnavailable().equals(Boolean.FALSE) && c.attributes().isUnavailable().equals(Boolean.FALSE)
&& c.attributes().translatedLanguage().equals("pt-br")) && languagesToImport.containsKey(c.attributes().translatedLanguage()))
.sorted( .sorted(
(o1, o2) -> { (o1, o2) -> {
try { try {
@ -73,7 +75,7 @@ public class MangaDexProvider implements ContentProvider, ManualImportContentPro
c.attributes().chapter() + " - " + c.attributes().title(), c.attributes().chapter() + " - " + c.attributes().title(),
c.id().toString(), c.id().toString(),
c.attributes().chapter(), c.attributes().chapter(),
c.attributes().translatedLanguage())) languagesToImport.get(c.attributes().translatedLanguage())))
.toList(); .toList();
} catch (Exception e) { } catch (Exception e) {
log.warn(e.getMessage()); log.warn(e.getMessage());