* make movie detection smarter (hopefully) and cover more cases
This commit is contained in:
parent
473cc6bd44
commit
8b887055aa
|
@ -147,7 +147,7 @@ public class MediaBindingBean {
|
|||
public String getImdbId() {
|
||||
int imdb = getMovie().getImdbId();
|
||||
|
||||
if (imdb < 0)
|
||||
if (imdb <= 0)
|
||||
return null;
|
||||
|
||||
return String.format("%07d", imdb);
|
||||
|
|
|
@ -40,8 +40,10 @@ import net.sourceforge.filebot.MediaTypes;
|
|||
import net.sourceforge.filebot.WebServices;
|
||||
import net.sourceforge.filebot.similarity.CommonSequenceMatcher;
|
||||
import net.sourceforge.filebot.similarity.DateMatcher;
|
||||
import net.sourceforge.filebot.similarity.MetricAvg;
|
||||
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
|
||||
import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher;
|
||||
import net.sourceforge.filebot.similarity.SequenceMatchSimilarity;
|
||||
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
|
||||
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||
|
@ -331,7 +333,24 @@ public class MediaDetection {
|
|||
|
||||
// query by file / folder name
|
||||
if (queryLookupService != null) {
|
||||
options.addAll(queryMovieByFileName(terms, queryLookupService, locale));
|
||||
Collection<Movie> results = queryMovieByFileName(terms, queryLookupService, locale);
|
||||
|
||||
// try query without year as it sometimes messes up results if years don't match properly (movie release years vs dvd release year, etc)
|
||||
if (results.isEmpty() && !strict) {
|
||||
List<String> termsWithoutYear = new ArrayList<String>();
|
||||
Pattern yearPattern = Pattern.compile("(?:19|20)\\d{2}");
|
||||
for (String term : terms) {
|
||||
Matcher m = yearPattern.matcher(term);
|
||||
if (m.find()) {
|
||||
termsWithoutYear.add(m.replaceAll("").trim());
|
||||
}
|
||||
}
|
||||
if (termsWithoutYear.size() > 0) {
|
||||
results = queryMovieByFileName(termsWithoutYear, queryLookupService, locale);
|
||||
}
|
||||
}
|
||||
|
||||
options.addAll(results);
|
||||
}
|
||||
|
||||
// add local matching after online search
|
||||
|
@ -339,7 +358,7 @@ public class MediaDetection {
|
|||
|
||||
// sort by relevance
|
||||
List<Movie> optionsByRelevance = new ArrayList<Movie>(options);
|
||||
sort(optionsByRelevance, new SimilarityComparator(new NameSimilarityMetric(), stripReleaseInfo(terms, true).toArray()));
|
||||
sort(optionsByRelevance, new SimilarityComparator(new MetricAvg(new SequenceMatchSimilarity(), new NameSimilarityMetric()), stripReleaseInfo(terms, true).toArray()));
|
||||
return optionsByRelevance;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ public class ReleaseInfo {
|
|||
Pattern resolution = getResolutionPattern();
|
||||
Pattern queryBlacklist = getBlacklistPattern();
|
||||
|
||||
Pattern[] stopwords = new Pattern[] { getReleaseGroupPattern(true), languageTag, videoSource, videoFormat, resolution, languageSuffix };
|
||||
Pattern[] stopwords = new Pattern[] { languageTag, videoSource, videoFormat, resolution, languageSuffix };
|
||||
Pattern[] blacklist = new Pattern[] { clutterBracket, releaseGroup, languageTag, videoSource, videoFormat, resolution, languageSuffix, queryBlacklist };
|
||||
|
||||
List<String> output = new ArrayList<String>(items.size());
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
package net.sourceforge.filebot.similarity;
|
||||
|
||||
|
||||
public class MetricAvg implements SimilarityMetric {
|
||||
|
||||
private final SimilarityMetric[] metrics;
|
||||
|
||||
|
||||
public MetricAvg(SimilarityMetric... metrics) {
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public float getSimilarity(Object o1, Object o2) {
|
||||
float f = 0;
|
||||
for (SimilarityMetric metric : metrics) {
|
||||
f += metric.getSimilarity(o1, o2);
|
||||
}
|
||||
return f / metrics.length;
|
||||
}
|
||||
|
||||
}
|
|
@ -64,7 +64,7 @@ public class Movie extends SearchResult {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s (%d)", name, year);
|
||||
return String.format("%s (%04d)", name, year < 0 ? 0 : year);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ public class TMDbClient implements MovieIdentificationService {
|
|||
try {
|
||||
imdbid = new Scanner(getTextContent("imdb_id", node)).useDelimiter("\\D+").nextInt();
|
||||
} catch (RuntimeException e) {
|
||||
throw new IllegalArgumentException("Missing data: imdbid");
|
||||
// ignore
|
||||
}
|
||||
|
||||
result.add(new Movie(name, year, imdbid));
|
||||
|
|
Loading…
Reference in New Issue