Skip to content

Commit

Permalink
use two digits for season and episode in title
Browse files Browse the repository at this point in the history
  • Loading branch information
pidoubleyou committed Apr 29, 2024
1 parent fa8a8df commit ac39221
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ private Optional<String> parseTitle(final JsonObject aRootNode, final JsonObject
resultingTitle = formatTitle(targetTitle, targetSubtitle);
}
if (resultingTitle.isPresent()) {
final Optional<String> season = JsonUtils.getElementValueAsString(aTarget, SEASONNUMBER);
final Optional<String> episode = JsonUtils.getElementValueAsString(aTarget, EPISODENUMBER);
final Optional<Integer> season = JsonUtils.getElementValueAsInteger(aTarget, SEASONNUMBER);
final Optional<Integer> episode = JsonUtils.getElementValueAsInteger(aTarget, EPISODENUMBER);
final Optional<String> seasonEpisodeTitle = formatEpisodeTitle(season, episode);
return cleanupTitle((resultingTitle.get() + " " + seasonEpisodeTitle.orElse("")).trim());
}
Expand All @@ -295,16 +295,16 @@ private Optional<String> formatTitle(Optional<String> title, Optional<String> su
}
}

private Optional<String> formatEpisodeTitle(Optional<String> season, Optional<String> episode) {
private Optional<String> formatEpisodeTitle(Optional<Integer> season, Optional<Integer> episode) {
if (season.isEmpty() && episode.isEmpty()) {
return Optional.empty();
}
String result = "";
if (season.isPresent()) {
result += "S"+season.get();
result += String.format("S%02d", season.get());
}
if (episode.isPresent()) {
result += "E"+episode.get();
result += String.format("E%02d", episode.get());
}
return Optional.of("("+result+")");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static Collection<Object[]> data() {
"/zdf/zdf_film_details_with_episodes.json",
Sender.ZDF,
"The Rookie",
"Der Prozess (S5E1)",
"Der Prozess (S05E01)",
LocalDateTime.of(2024, 4, 11, 20, 15, 0),
Duration.ofMinutes(41).plusSeconds(6),
"Officer John Nolan sieht sich wieder mit der Serienmörderin Rosalind Dyer konfrontiert. Vor Beginn der Gerichtsverhandlung gelingt ihr die Flucht und sie muss erneut gefasst werden.",
Expand Down

0 comments on commit ac39221

Please sign in to comment.