mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-02 08:25:02 -04:00
+ Improved support for Plex multi-episode naming scheme (i.e. use ranges like S01E01-E05)
@see https://www.filebot.net/forums/viewtopic.php?f=10&t=3310
This commit is contained in:
parent
0a48dd41b0
commit
b83fcad638
@ -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:
|
||||
|
@ -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<Episode> episodes) {
|
||||
Set<String> name = new LinkedHashSet<String>(2);
|
||||
Set<String> sxe = new LinkedHashSet<String>(2);
|
||||
Set<String> title = new LinkedHashSet<String>(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<Episode> episodes) {
|
||||
Set<String> name = new LinkedHashSet<String>();
|
||||
Set<String> sxe = new LinkedHashSet<String>();
|
||||
Set<String> title = new LinkedHashSet<String>();
|
||||
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<Episode> episodes) {
|
||||
return episodes.stream().map(e -> removeTrailingBrackets(e.getTitle())).distinct().collect(Collectors.joining(" & "));
|
||||
}
|
||||
|
||||
public String formatMultiRangeSxE(List<Episode> episodes) {
|
||||
|
Loading…
Reference in New Issue
Block a user