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