* improved support for matching Season 05/01.avi naming patterns
This commit is contained in:
parent
444ddd8883
commit
8fa0531f1b
|
@ -105,6 +105,11 @@ public class MediaDetection {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static List<SxE> parseEpisodeNumber(File file, boolean strict) {
|
||||||
|
return new SeasonEpisodeMatcher(SeasonEpisodeMatcher.DEFAULT_SANITY, strict).match(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Date parseDate(Object object) {
|
public static Date parseDate(Object object) {
|
||||||
return new DateMetric().parse(object);
|
return new DateMetric().parse(object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ package net.sourceforge.filebot.similarity;
|
||||||
|
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
|
import static java.util.regex.Pattern.*;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -20,6 +22,7 @@ public class SeasonEpisodeMatcher {
|
||||||
public static final SeasonEpisodeFilter DEFAULT_SANITY = new SeasonEpisodeFilter(50, 50, 1000);
|
public static final SeasonEpisodeFilter DEFAULT_SANITY = new SeasonEpisodeFilter(50, 50, 1000);
|
||||||
|
|
||||||
private SeasonEpisodePattern[] patterns;
|
private SeasonEpisodePattern[] patterns;
|
||||||
|
private Pattern seasonPattern;
|
||||||
|
|
||||||
|
|
||||||
public SeasonEpisodeMatcher(SeasonEpisodeFilter sanity, boolean strict) {
|
public SeasonEpisodeMatcher(SeasonEpisodeFilter sanity, boolean strict) {
|
||||||
|
@ -86,6 +89,9 @@ public class SeasonEpisodeMatcher {
|
||||||
if (strict) {
|
if (strict) {
|
||||||
patterns = new SeasonEpisodePattern[] { patterns[0], patterns[1], patterns[2] };
|
patterns = new SeasonEpisodePattern[] { patterns[0], patterns[1], patterns[2] };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// season folder pattern for complementing partial sxe info from filename
|
||||||
|
seasonPattern = compile("Season\\D?(\\d{1,2})", CASE_INSENSITIVE | UNICODE_CASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,6 +111,27 @@ public class SeasonEpisodeMatcher {
|
||||||
return match;
|
return match;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<SxE> match(File file) {
|
||||||
|
for (SeasonEpisodePattern pattern : patterns) {
|
||||||
|
List<SxE> match = pattern.match(file.getName());
|
||||||
|
|
||||||
|
if (!match.isEmpty()) {
|
||||||
|
// current pattern did match
|
||||||
|
for (int i = 0; i < match.size(); i++) {
|
||||||
|
if (match.get(i).season < 0) {
|
||||||
|
Matcher sm = seasonPattern.matcher(file.getPath());
|
||||||
|
if (sm.find()) {
|
||||||
|
match.set(i, new SxE(Integer.parseInt(sm.group(1)), match.get(i).episode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return match;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,7 @@ public class SeasonEpisodeMetric implements SimilarityMetric {
|
||||||
|
|
||||||
protected Collection<SxE> parse(Object object) {
|
protected Collection<SxE> parse(Object object) {
|
||||||
if (object instanceof File) {
|
if (object instanceof File) {
|
||||||
// parse file name
|
return seasonEpisodeMatcher.match((File) object);
|
||||||
object = ((File) object).getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return seasonEpisodeMatcher.match(object.toString());
|
return seasonEpisodeMatcher.match(object.toString());
|
||||||
|
|
|
@ -193,7 +193,7 @@ samples
|
||||||
SBS
|
SBS
|
||||||
Screenshot
|
Screenshot
|
||||||
sd
|
sd
|
||||||
Season.[0-9]+
|
Season.?[0-9]+
|
||||||
sed
|
sed
|
||||||
ShareGo
|
ShareGo
|
||||||
ShareReactor
|
ShareReactor
|
||||||
|
|
|
@ -45,7 +45,7 @@ def forceMovie(f) {
|
||||||
}
|
}
|
||||||
|
|
||||||
def forceSeries(f) {
|
def forceSeries(f) {
|
||||||
parseEpisodeNumber(f) || parseDate(f) || tryQuietly{ ut_label } =~ /^(?i:TV|Kids.Shows)/
|
parseEpisodeNumber(f) || parseDate(f) || f.path =~ /(?i:Season)\D?[0-9]{1,2}/ || tryQuietly{ ut_label } =~ /^(?i:TV|Kids.Shows)/
|
||||||
}
|
}
|
||||||
|
|
||||||
def forceAnime(f) {
|
def forceAnime(f) {
|
||||||
|
|
Loading…
Reference in New Issue