diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 5a5d97a7..8519ff3f 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -133,7 +133,7 @@ public class FormatDialog extends JDialog { public Format getFormat() { switch (this) { case Episode: - return new EpisodeFormat(true, true); + return new EpisodeFormat(); case Movie: // case Movie return new MovieFormat(true, true, false); case Music: diff --git a/source/net/filebot/web/EpisodeFormat.java b/source/net/filebot/web/EpisodeFormat.java index 76f4bb61..9f0b0baa 100644 --- a/source/net/filebot/web/EpisodeFormat.java +++ b/source/net/filebot/web/EpisodeFormat.java @@ -20,15 +20,7 @@ import java.util.stream.Collectors; public class EpisodeFormat extends Format { - public static final EpisodeFormat SeasonEpisode = new EpisodeFormat(true, false); - - private final boolean includeAirdate; - private final boolean includeSpecial; - - public EpisodeFormat(boolean includeSpecial, boolean includeAirdate) { - this.includeSpecial = includeSpecial; - this.includeAirdate = includeAirdate; - } + public static final EpisodeFormat SeasonEpisode = new EpisodeFormat(); @Override public StringBuffer format(Object obj, StringBuffer sb, FieldPosition pos) { @@ -51,27 +43,33 @@ public class EpisodeFormat extends Format { if (episode.getEpisode() != null) { sb.append(String.format("%02d", episode.getEpisode())); - } else if (includeSpecial && episode.getSpecial() != null) { + } else if (episode.getSpecial() != null) { sb.append("Special " + episode.getSpecial()); } } else { // episode, but no season if (episode.getEpisode() != null) { sb.append(" - ").append(episodeNumber); - } else if (includeSpecial && episode.getSpecial() != null) { + } else if (episode.getSpecial() != null) { sb.append(" - ").append("Special " + episode.getSpecial()); } } - sb.append(" - ").append(episode.getTitle()); - - if (includeAirdate && episode.getAirdate() != null) { - sb.append(" [").append(episode.getAirdate().format("yyyy-MM-dd")).append("]"); - } - return sb; } + public String formatMultiEpisode(List episodes) { + Set name = new LinkedHashSet(2); + Set sxe = new LinkedHashSet(2); + Set title = new LinkedHashSet(2); + for (Episode it : episodes) { + name.add(it.getSeriesName()); + sxe.add(formatSxE(it)); + title.add(removeTrailingBrackets(it.getTitle())); + } + return String.format("%s - %s - %s", join(name, " & "), join(" & ", sxe), join(" & ", title)); + } + public String formatSxE(Episode episode) { if (episode instanceof MultiEpisode) { return formatMultiRangeSxE(((MultiEpisode) episode).getEpisodes()); @@ -102,16 +100,8 @@ public class EpisodeFormat extends Format { return sb.toString(); } - public String formatMultiEpisode(Iterable episodes) { - Set name = new LinkedHashSet(); - Set sxe = new LinkedHashSet(); - Set title = new LinkedHashSet(); - for (Episode it : episodes) { - name.add(it.getSeriesName()); - sxe.add(formatSxE(it)); - title.add(removeTrailingBrackets(it.getTitle())); - } - return String.format("%s - %s - %s", join(name, " & "), join(" & ", sxe), join(" & ", title)); + public String formatMultiTitle(List episodes) { + return episodes.stream().map(e -> removeTrailingBrackets(e.getTitle())).distinct().collect(Collectors.joining(" & ")); } public String formatMultiRangeSxE(List episodes) {