mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 01:08:52 -05: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() {
|
public Format getFormat() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
case Episode:
|
case Episode:
|
||||||
return new EpisodeFormat(true, true);
|
return new EpisodeFormat();
|
||||||
case Movie: // case Movie
|
case Movie: // case Movie
|
||||||
return new MovieFormat(true, true, false);
|
return new MovieFormat(true, true, false);
|
||||||
case Music:
|
case Music:
|
||||||
|
@ -20,15 +20,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class EpisodeFormat extends Format {
|
public class EpisodeFormat extends Format {
|
||||||
|
|
||||||
public static final EpisodeFormat SeasonEpisode = new EpisodeFormat(true, false);
|
public static final EpisodeFormat SeasonEpisode = new EpisodeFormat();
|
||||||
|
|
||||||
private final boolean includeAirdate;
|
|
||||||
private final boolean includeSpecial;
|
|
||||||
|
|
||||||
public EpisodeFormat(boolean includeSpecial, boolean includeAirdate) {
|
|
||||||
this.includeSpecial = includeSpecial;
|
|
||||||
this.includeAirdate = includeAirdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringBuffer format(Object obj, StringBuffer sb, FieldPosition pos) {
|
public StringBuffer format(Object obj, StringBuffer sb, FieldPosition pos) {
|
||||||
@ -51,27 +43,33 @@ public class EpisodeFormat extends Format {
|
|||||||
|
|
||||||
if (episode.getEpisode() != null) {
|
if (episode.getEpisode() != null) {
|
||||||
sb.append(String.format("%02d", episode.getEpisode()));
|
sb.append(String.format("%02d", episode.getEpisode()));
|
||||||
} else if (includeSpecial && episode.getSpecial() != null) {
|
} else if (episode.getSpecial() != null) {
|
||||||
sb.append("Special " + episode.getSpecial());
|
sb.append("Special " + episode.getSpecial());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// episode, but no season
|
// episode, but no season
|
||||||
if (episode.getEpisode() != null) {
|
if (episode.getEpisode() != null) {
|
||||||
sb.append(" - ").append(episodeNumber);
|
sb.append(" - ").append(episodeNumber);
|
||||||
} else if (includeSpecial && episode.getSpecial() != null) {
|
} else if (episode.getSpecial() != null) {
|
||||||
sb.append(" - ").append("Special " + episode.getSpecial());
|
sb.append(" - ").append("Special " + episode.getSpecial());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(" - ").append(episode.getTitle());
|
sb.append(" - ").append(episode.getTitle());
|
||||||
|
|
||||||
if (includeAirdate && episode.getAirdate() != null) {
|
|
||||||
sb.append(" [").append(episode.getAirdate().format("yyyy-MM-dd")).append("]");
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb;
|
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) {
|
public String formatSxE(Episode episode) {
|
||||||
if (episode instanceof MultiEpisode) {
|
if (episode instanceof MultiEpisode) {
|
||||||
return formatMultiRangeSxE(((MultiEpisode) episode).getEpisodes());
|
return formatMultiRangeSxE(((MultiEpisode) episode).getEpisodes());
|
||||||
@ -102,16 +100,8 @@ public class EpisodeFormat extends Format {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String formatMultiEpisode(Iterable<Episode> episodes) {
|
public String formatMultiTitle(List<Episode> episodes) {
|
||||||
Set<String> name = new LinkedHashSet<String>();
|
return episodes.stream().map(e -> removeTrailingBrackets(e.getTitle())).distinct().collect(Collectors.joining(" & "));
|
||||||
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 formatMultiRangeSxE(List<Episode> episodes) {
|
public String formatMultiRangeSxE(List<Episode> episodes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user