retrieve localized series name from response

This commit is contained in:
Reinhard Pointner 2017-10-01 08:07:06 +02:00
parent 491eca20e0
commit af5e0ffd55
1 changed files with 7 additions and 4 deletions

View File

@ -13,7 +13,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.stream.Stream;
import javax.swing.Icon;
@ -98,8 +97,12 @@ public class TMDbTVClient extends AbstractEpisodeListProvider {
// http://api.themoviedb.org/3/tv/id
Object tv = tmdb.request("tv/" + series.getId(), emptyMap(), locale);
// retrieve localized series name from response
String name = getString(tv, "name");
String originalName = getString(tv, "original_name");
SeriesInfo info = new SeriesInfo(this, sortOrder, locale, series.getId());
info.setName(Stream.of("original_name", "name").map(key -> getString(tv, key)).filter(Objects::nonNull).findFirst().orElse(series.getName()));
info.setName(originalName != null ? originalName : name);
info.setAliasNames(series.getAliasNames());
info.setStatus(getString(tv, "status"));
info.setLanguage(getString(tv, "original_language"));
@ -128,9 +131,9 @@ public class TMDbTVClient extends AbstractEpisodeListProvider {
Integer absoluteNumber = episodes.size() + 1;
if (s > 0) {
episodes.add(new Episode(series.getName(), seasonNumber, episodeNumber, episodeTitle, absoluteNumber, null, airdate, id, info));
episodes.add(new Episode(name, seasonNumber, episodeNumber, episodeTitle, absoluteNumber, null, airdate, id, info));
} else {
specials.add(new Episode(series.getName(), null, null, episodeTitle, null, episodeNumber, airdate, id, info));
specials.add(new Episode(name, null, null, episodeTitle, null, episodeNumber, airdate, id, info));
}
});
}