Skip to content

Commit

Permalink
- do detection in film list reader
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Apr 10, 2024
1 parent cc07a50 commit 3247c50
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/main/java/mediathek/filmlisten/reader/FilmListReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ protected void parseGeo(JsonParser jp, DatenFilm datenFilm) throws IOException {
for (var geoItem : split) {
try {
datenFilm.countrySet.add(Country.valueOf(geoItem));
}
catch (IllegalArgumentException ex) {
} catch (IllegalArgumentException ex) {
logger.error("Unable to parse string {} to Country enum", geoItem);
}
}
Expand Down Expand Up @@ -374,13 +373,13 @@ private void readData(JsonParser jp, ListeFilme listeFilme) throws IOException {
logger.trace("Starting language detection");
detectLanguages(listeFilme);
logger.trace("Language detection done");
}
else {
} else {
logger.trace("Skipping language detection");
}
}

private void detectLanguages(@NotNull ListeFilme listeFilme) {
Stopwatch watch;
final var languageDetector = LanguageDetectorBuilder
.fromAllLanguagesWithout(Language.LATIN,
Language.AMHARIC,
Expand Down Expand Up @@ -419,13 +418,13 @@ private void detectLanguages(@NotNull ListeFilme listeFilme) {
Language.ZULU)
.withPreloadedLanguageModels()
.withLowAccuracyMode().build();
Stopwatch watch = Stopwatch.createStarted();
watch = Stopwatch.createStarted();
listeFilme.parallelStream().filter(f -> f.getLanguage() == Language.UNKNOWN).forEach(f -> {
f.setLanguage(languageDetector.detectLanguageOf(f.getDescription()));
});
watch.stop();
logger.trace("Language detection took {}", watch);
languageDetector.unloadLanguageModels();
logger.trace("Language detection took {}", watch);
}

/**
Expand All @@ -452,8 +451,8 @@ public void readFilmListe(String source, @NotNull ListeFilme listeFilme, int day
notifyStart(source); // für die Progressanzeige

if (source.startsWith("http")) {
final var sourceUrl = new URI(source);
processFromWeb(sourceUrl.toURL(), listeFilme);
final var sourceUrl = new URI(source);
processFromWeb(sourceUrl.toURL(), listeFilme);
} else
processFromFile(source, listeFilme);

Expand Down Expand Up @@ -497,11 +496,10 @@ private void processFromFile(String source, ListeFilme listeFilme) {
}
}

private String buildClientInfo()
{
private String buildClientInfo() {
List<Object> clientData = Arrays.asList(Konstanten.PROGRAMMNAME, Konstanten.MVVERSION, SystemUtils.OS_ARCH,
SystemUtils.OS_NAME, SystemUtils.OS_VERSION);
return clientData.stream().map( Object::toString ).collect( Collectors.joining( "," ) );
return clientData.stream().map(Object::toString).collect(Collectors.joining(","));
}

/**
Expand Down

0 comments on commit 3247c50

Please sign in to comment.