* fix issues with multi-episode anime default numbering bindings {sxe} and {s00e00}
This commit is contained in:
parent
8f31ed3977
commit
f61f30e862
|
@ -1,7 +1,5 @@
|
|||
|
||||
package net.sourceforge.filebot.web;
|
||||
|
||||
|
||||
import static net.sourceforge.tuned.StringUtilities.*;
|
||||
|
||||
import java.text.FieldPosition;
|
||||
|
@ -13,7 +11,6 @@ import java.util.Set;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
||||
public class EpisodeFormat extends Format {
|
||||
|
||||
public static final EpisodeFormat SeasonEpisode = new EpisodeFormat(true, false);
|
||||
|
@ -21,13 +18,11 @@ public class EpisodeFormat extends Format {
|
|||
private final boolean includeAirdate;
|
||||
private final boolean includeSpecial;
|
||||
|
||||
|
||||
public EpisodeFormat(boolean includeSpecial, boolean includeAirdate) {
|
||||
this.includeSpecial = includeSpecial;
|
||||
this.includeAirdate = includeAirdate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public StringBuffer format(Object obj, StringBuffer sb, FieldPosition pos) {
|
||||
if (obj instanceof MultiEpisode) {
|
||||
|
@ -70,7 +65,6 @@ public class EpisodeFormat extends Format {
|
|||
return sb;
|
||||
}
|
||||
|
||||
|
||||
public String formatSxE(Episode episode) {
|
||||
if (episode instanceof MultiEpisode) {
|
||||
return formatMultiSxE(((MultiEpisode) episode).getEpisodes());
|
||||
|
@ -89,7 +83,6 @@ public class EpisodeFormat extends Format {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public String formatS00E00(Episode episode) {
|
||||
if (episode instanceof MultiEpisode) {
|
||||
return formatMultiS00E00(((MultiEpisode) episode).getEpisodes());
|
||||
|
@ -108,7 +101,6 @@ 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>();
|
||||
|
@ -122,18 +114,20 @@ public class EpisodeFormat extends Format {
|
|||
return String.format("%s - %s - %s", join(name, " & "), join(sxe, " & "), join(title, " & "));
|
||||
}
|
||||
|
||||
|
||||
public String formatMultiSxE(Iterable<Episode> episodes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Integer ps = null;
|
||||
for (Episode it : episodes) {
|
||||
if (!it.getSeason().equals(ps)) {
|
||||
if (it.getSeason() != null && !it.getSeason().equals(ps)) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(it.getSeason()).append('x').append(String.format("%02d", it.getEpisode()));
|
||||
} else {
|
||||
sb.append('-').append(String.format("%02d", it.getEpisode()));
|
||||
if (sb.length() > 0) {
|
||||
sb.append('-');
|
||||
}
|
||||
sb.append(String.format("%02d", it.getEpisode()));
|
||||
}
|
||||
ps = it.getSeason();
|
||||
}
|
||||
|
@ -141,7 +135,6 @@ public class EpisodeFormat extends Format {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public String formatMultiS00E00(Iterable<Episode> episodes) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Integer ps = null;
|
||||
|
@ -149,7 +142,7 @@ public class EpisodeFormat extends Format {
|
|||
if (sb.length() > 0) {
|
||||
sb.append("-");
|
||||
}
|
||||
if (!it.getSeason().equals(ps)) {
|
||||
if (it.getSeason() != null && !it.getSeason().equals(ps)) {
|
||||
sb.append(String.format("S%02d", it.getSeason())).append(String.format("E%02d", it.getEpisode()));
|
||||
} else {
|
||||
sb.append(String.format("E%02d", it.getEpisode()));
|
||||
|
@ -163,7 +156,6 @@ public class EpisodeFormat extends Format {
|
|||
private final Pattern sxePattern = Pattern.compile("- (?:(\\d{1,2})x)?(Special )?(\\d{1,3}) -");
|
||||
private final Pattern airdatePattern = Pattern.compile("\\[(\\d{4}-\\d{1,2}-\\d{1,2})\\]");
|
||||
|
||||
|
||||
@Override
|
||||
public Episode parseObject(String s, ParsePosition pos) {
|
||||
StringBuilder source = new StringBuilder(s);
|
||||
|
@ -203,7 +195,6 @@ public class EpisodeFormat extends Format {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Episode parseObject(String source) throws ParseException {
|
||||
return (Episode) super.parseObject(source);
|
||||
|
|
Loading…
Reference in New Issue