* support for multi-episode special episodes

e.g. "The Rockford Files S00E01-E02 Backlash of the Hunter"
This commit is contained in:
Reinhard Pointner 2015-08-19 23:06:08 +00:00
parent fbca0db2f8
commit 48ce0f3d32
2 changed files with 34 additions and 12 deletions

View File

@ -41,7 +41,11 @@ public class EpisodeMatcher extends Matcher<File, Object> {
for (Entry<File, List<Episode>> it : episodeSets.entrySet()) {
Set<SxE> sxe = new HashSet<SxE>(it.getValue().size());
for (Episode ep : it.getValue()) {
sxe.add(new SxE(ep.getSeason(), ep.getEpisode()));
if (ep.getSpecial() == null) {
sxe.add(new SxE(ep.getSeason(), ep.getEpisode()));
} else {
sxe.add(new SxE(0, ep.getSpecial()));
}
}
episodeIdentifierSets.put(it.getKey(), sxe);
}
@ -104,7 +108,7 @@ public class EpisodeMatcher extends Matcher<File, Object> {
for (SxE it : numbers) {
if (it.season > 0 && it.episode > 0 && it.episode < 100) {
identifier.add(it.season * 100 + it.episode);
} else if (it.season < 0 && it.episode > 0) {
} else if (it.season <= 0 && it.episode > 0) {
identifier.add(it.episode);
}
}
@ -120,12 +124,18 @@ public class EpisodeMatcher extends Matcher<File, Object> {
Integer seqIndex = null;
for (Episode it : episodes) {
// any illegal episode object breaks the chain
if (it == null || it.getEpisode() == null || it.getSpecial() != null)
if (it == null)
return false;
if (it.getEpisode() == null && it.getSpecial() == null)
return false;
// non-sequential episode index breaks the chain
if (seqIndex != null && !it.getEpisode().equals(seqIndex + 1))
return false;
if (seqIndex != null) {
Integer num = it.getEpisode() != null ? it.getEpisode() : it.getSpecial();
if (!num.equals(seqIndex + 1)) {
return false;
}
}
seqIndex = it.getEpisode();
}
@ -141,5 +151,4 @@ public class EpisodeMatcher extends Matcher<File, Object> {
return true;
}
}

View File

@ -121,12 +121,21 @@ public class EpisodeFormat extends Format {
if (sb.length() > 0) {
sb.append(' ');
}
sb.append(it.getSeason()).append('x').append(String.format("%02d", it.getEpisode()));
sb.append(it.getSeason()).append('x');
if (it.getSpecial() == null) {
sb.append(String.format("%02d", it.getEpisode()));
} else {
sb.append("Special ").append(it.getSpecial());
}
} else {
if (sb.length() > 0) {
sb.append('-');
}
sb.append(String.format("%02d", it.getEpisode()));
if (it.getSpecial() == null) {
sb.append(String.format("%02d", it.getEpisode()));
} else {
sb.append(it.getSpecial());
}
}
ps = it.getSeason();
}
@ -141,12 +150,16 @@ public class EpisodeFormat extends Format {
if (sb.length() > 0) {
sb.append("-");
}
if (it.getSeason() != null && !it.getSeason().equals(ps)) {
sb.append(String.format("S%02d", it.getSeason())).append(String.format("E%02d", it.getEpisode()));
Integer s = it.getSpecial() == null ? it.getSeason() : 0;
Integer e = it.getEpisode() != null ? it.getEpisode() : it.getSpecial();
if (s != null && !s.equals(ps)) {
sb.append(String.format("S%02d", s)).append(String.format("E%02d", e));
} else {
sb.append(String.format("E%02d", it.getEpisode()));
sb.append(String.format("E%02d", e));
}
ps = it.getSeason();
ps = s;
}
return sb.toString();