* improved movie results sort order
This commit is contained in:
parent
3e45873ce3
commit
c106bcea4e
|
@ -2,7 +2,6 @@
|
||||||
package net.sourceforge.filebot.media;
|
package net.sourceforge.filebot.media;
|
||||||
|
|
||||||
|
|
||||||
import static java.util.Arrays.*;
|
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
import static net.sourceforge.tuned.FileUtilities.*;
|
import static net.sourceforge.tuned.FileUtilities.*;
|
||||||
|
@ -13,6 +12,7 @@ import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -31,8 +31,9 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.sourceforge.filebot.MediaTypes;
|
import net.sourceforge.filebot.MediaTypes;
|
||||||
import net.sourceforge.filebot.WebServices;
|
import net.sourceforge.filebot.WebServices;
|
||||||
|
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
|
||||||
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
|
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
|
||||||
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||||
import net.sourceforge.filebot.web.Movie;
|
import net.sourceforge.filebot.web.Movie;
|
||||||
import net.sourceforge.filebot.web.MovieIdentificationService;
|
import net.sourceforge.filebot.web.MovieIdentificationService;
|
||||||
import net.sourceforge.filebot.web.SearchResult;
|
import net.sourceforge.filebot.web.SearchResult;
|
||||||
|
@ -156,6 +157,7 @@ public class MediaDetection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strict && options.isEmpty()) {
|
||||||
// search by file name or folder name
|
// search by file name or folder name
|
||||||
Collection<String> searchQueries = new LinkedHashSet<String>();
|
Collection<String> searchQueries = new LinkedHashSet<String>();
|
||||||
searchQueries.add(getName(movieFile));
|
searchQueries.add(getName(movieFile));
|
||||||
|
@ -164,14 +166,27 @@ public class MediaDetection {
|
||||||
// remove blacklisted terms
|
// remove blacklisted terms
|
||||||
searchQueries = stripReleaseInfo(searchQueries);
|
searchQueries = stripReleaseInfo(searchQueries);
|
||||||
|
|
||||||
if (!strict && options.isEmpty()) {
|
final SimilarityMetric metric = new NameSimilarityMetric();
|
||||||
|
final Map<Movie, Float> probabilityMap = new LinkedHashMap<Movie, Float>();
|
||||||
for (String query : searchQueries) {
|
for (String query : searchQueries) {
|
||||||
Movie[] results = service.searchMovie(query, locale).toArray(new Movie[0]);
|
for (Movie movie : service.searchMovie(query, locale)) {
|
||||||
sort(results, new SimilarityComparator(query)); // sort by similarity to original query
|
probabilityMap.put(movie, metric.getSimilarity(query, movie));
|
||||||
addAll(options, results);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sort by similarity to original query (descending)
|
||||||
|
List<Movie> results = new ArrayList<Movie>(probabilityMap.keySet());
|
||||||
|
sort(results, new Comparator<Movie>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(Movie a, Movie b) {
|
||||||
|
return probabilityMap.get(b).compareTo(probabilityMap.get(a));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
options.addAll(results);
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
pattern.video.source: CAMRip|CAM|TS|TELESYNC|PDVD|TS|TELESYNC|PDVD|PPV|PPVRip|Screener|SCR|SCREENER|DVDSCR|DVDSCREENER|BDSCR|R5|R5LINE|DVDRip|DVDR|TVRip|DSR|PDTV|HDTV|DVBRip|DTHRip|VODRip|VODR|BDRip|BRRip|BluRay|BDR
|
pattern.video.source: CAMRip|CAM|TS|TELESYNC|PDVD|TS|TELESYNC|PDVD|PPV|PPVRip|Screener|SCR|SCREENER|DVDSCR|DVDSCREENER|BDSCR|R5|R5LINE|DVDRip|DVDR|TVRip|DSR|PDTV|HDTV|DVBRip|DTHRip|VODRip|VODR|BDRip|BRRip|BluRay|BDR
|
||||||
|
|
||||||
# additional release info patterns
|
# additional release info patterns
|
||||||
pattern.codec: DivX|Xvid|AVC|x264|h264|3ivx|mpeg|mpeg4|mp3|aac|2ch|6ch|720p|1080p
|
pattern.codec: DivX|Xvid|AVC|x264|h264|3ivx|mpeg|mpeg4|mp3|aac|ac3|2ch|6ch|720p|1080p
|
||||||
|
|
||||||
# group names mostly copied from [http://scenelingo.wordpress.com/list-of-scene-release-groups]
|
# group names mostly copied from [http://scenelingo.wordpress.com/list-of-scene-release-groups]
|
||||||
url.release-groups: http://filebot.sourceforge.net/data/release-groups.txt
|
url.release-groups: http://filebot.sourceforge.net/data/release-groups.txt
|
||||||
|
|
Loading…
Reference in New Issue