diff --git a/source/net/filebot/similarity/EpisodeMatcher.java b/source/net/filebot/similarity/EpisodeMatcher.java index b48999ca..f83e5a77 100644 --- a/source/net/filebot/similarity/EpisodeMatcher.java +++ b/source/net/filebot/similarity/EpisodeMatcher.java @@ -41,7 +41,11 @@ public class EpisodeMatcher extends Matcher { for (Entry> it : episodeSets.entrySet()) { Set sxe = new HashSet(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 { 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 { 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 { return true; } - } diff --git a/source/net/filebot/web/EpisodeFormat.java b/source/net/filebot/web/EpisodeFormat.java index 24209a17..1cad23a5 100644 --- a/source/net/filebot/web/EpisodeFormat.java +++ b/source/net/filebot/web/EpisodeFormat.java @@ -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();