1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-04 08:25:03 -05:00

* do query pattern matching in strict mode and in non-strict mode as fallback

This commit is contained in:
Reinhard Pointner 2014-04-15 17:34:28 +00:00
parent e9a33eed19
commit 12c5c6809c

View File

@ -327,7 +327,7 @@ public class MediaDetection {
} }
// strict series name matcher for recognizing 1x01 patterns // strict series name matcher for recognizing 1x01 patterns
SeriesNameMatcher snm = new SeriesNameMatcher(locale, true); SeriesNameMatcher strictSeriesNameMatcher = new SeriesNameMatcher(locale, true);
// cross-reference known series names against file structure // cross-reference known series names against file structure
try { try {
@ -338,7 +338,7 @@ public class MediaDetection {
String fn = getName(f); String fn = getName(f);
// try to minimize noise // try to minimize noise
String sn = snm.matchByEpisodeIdentifier(fn); String sn = strictSeriesNameMatcher.matchByEpisodeIdentifier(fn);
if (sn != null) { if (sn != null) {
fn = sn; fn = sn;
} }
@ -363,7 +363,7 @@ public class MediaDetection {
sns.addAll(folders); sns.addAll(folders);
sns.addAll(filenames); sns.addAll(filenames);
for (int i = 0; i < sns.size(); i++) { for (int i = 0; i < sns.size(); i++) {
String sn = snm.matchByEpisodeIdentifier(sns.get(i)); String sn = strictSeriesNameMatcher.matchByEpisodeIdentifier(sns.get(i));
if (sn != null) { if (sn != null) {
sns.set(i, sn); sns.set(i, sn);
} }
@ -389,14 +389,25 @@ public class MediaDetection {
// match common word sequence and clean detected word sequence from unwanted elements // match common word sequence and clean detected word sequence from unwanted elements
Collection<String> matches = new LinkedHashSet<String>(); Collection<String> matches = new LinkedHashSet<String>();
// check CWS matches
matches.addAll(snm.matchAll(files.toArray(new File[files.size()])));
// check for known pattern matches // check for known pattern matches
for (File f : files) { for (boolean strict : new boolean[] { true, false }) {
String sn = snm.matchByEpisodeIdentifier(getName(f.getParentFile())); if (matches.isEmpty()) {
if (sn != null) { // check CWS matches
matches.add(sn); SeriesNameMatcher seriesNameMatcher = new SeriesNameMatcher(Locale.ENGLISH, strict);
matches.addAll(strictSeriesNameMatcher.matchAll(files.toArray(new File[files.size()])));
// try before SxE pattern
if (matches.isEmpty()) {
for (File f : files) {
for (File path : listPathTail(f, 2, true)) {
String sn = seriesNameMatcher.matchByEpisodeIdentifier(getName(path));
if (sn != null && sn.length() > 0) {
matches.add(sn);
break;
}
}
}
}
} }
} }
@ -947,8 +958,12 @@ public class MediaDetection {
} }
public static String stripReleaseInfo(String name) { public static String stripReleaseInfo(String name) {
return stripReleaseInfo(name, true);
}
public static String stripReleaseInfo(String name, boolean strict) {
try { try {
return releaseInfo.cleanRelease(singleton(name), true).iterator().next(); return releaseInfo.cleanRelease(singleton(name), strict).iterator().next();
} catch (NoSuchElementException e) { } catch (NoSuchElementException e) {
return ""; // default value in case all tokens are stripped away return ""; // default value in case all tokens are stripped away
} catch (IOException e) { } catch (IOException e) {