Make sure that the filename is not uses as exclude keyword when the object happens to be a File

@see https://www.filebot.net/forums/viewtopic.php?f=6&t=5469
This commit is contained in:
Reinhard Pointner 2017-11-11 17:00:29 +01:00
parent 9ed7bbc503
commit 88ed6513c2
3 changed files with 13 additions and 12 deletions

View File

@ -1262,9 +1262,9 @@ public class MediaBindingBean {
private Pattern getKeywordExcludePattern() { private Pattern getKeywordExcludePattern() {
// collect key information // collect key information
List<Object> keys = new ArrayList<Object>(); List<Object> keys = new ArrayList<Object>();
keys.add(getName());
if (infoObject instanceof Episode || infoObject instanceof Movie) { if (infoObject instanceof Episode || infoObject instanceof Movie) {
keys.add(getName());
keys.addAll(getAliasNames()); keys.addAll(getAliasNames());
if (infoObject instanceof Episode) { if (infoObject instanceof Episode) {

View File

@ -141,18 +141,8 @@ public class ReleaseInfo {
} }
protected String matchLast(Pattern pattern, String[] paragon, CharSequence... sequence) { protected String matchLast(Pattern pattern, String[] paragon, CharSequence... sequence) {
String lastMatch = null;
// match last occurrence // match last occurrence
for (CharSequence name : sequence) { String lastMatch = stream(sequence).filter(Objects::nonNull).map(s -> matchLastOccurrence(s, pattern)).filter(Objects::nonNull).findFirst().orElse(null);
if (name == null)
continue;
Matcher matcher = pattern.matcher(name);
while (matcher.find()) {
lastMatch = matcher.group();
}
}
// prefer standard value over matched value // prefer standard value over matched value
if (lastMatch != null && paragon != null) { if (lastMatch != null && paragon != null) {

View File

@ -55,6 +55,17 @@ public final class StringUtilities {
return null; return null;
} }
public static String matchLastOccurrence(CharSequence s, Pattern pattern) {
String lastMatch = null;
Matcher matcher = pattern.matcher(s);
while (matcher.find()) {
lastMatch = matcher.group();
}
return lastMatch;
}
public static Stream<String> tokenize(CharSequence s) { public static Stream<String> tokenize(CharSequence s) {
return tokenize(s, SPACE); return tokenize(s, SPACE);
} }