1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* added basic support for cross-referencing series names from local series index

This commit is contained in:
Reinhard Pointner 2012-02-13 03:33:26 +00:00
parent 49271e2eee
commit 9ca4074cac
2 changed files with 62 additions and 1 deletions

View File

@ -8,7 +8,6 @@ import static net.sourceforge.filebot.similarity.Normalization.*;
import static net.sourceforge.tuned.FileUtilities.*;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@ -39,6 +38,7 @@ import net.sourceforge.filebot.similarity.NameSimilarityMetric;
import net.sourceforge.filebot.similarity.SeriesNameMatcher;
import net.sourceforge.filebot.similarity.SimilarityComparator;
import net.sourceforge.filebot.similarity.SimilarityMetric;
import net.sourceforge.filebot.web.AnidbClient.AnidbSearchResult;
import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.MovieIdentificationService;
import net.sourceforge.filebot.web.SearchResult;
@ -158,6 +158,67 @@ public class MediaDetection {
}
public static Collection<TheTVDBSearchResult> detectSeriesByName(String... names) throws Exception {
final HighPerformanceMatcher nameMatcher = new HighPerformanceMatcher();
final Map<TheTVDBSearchResult, String> matchMap = new HashMap<TheTVDBSearchResult, String>();
for (final TheTVDBSearchResult entry : releaseInfo.getSeriesList()) {
for (String name : names) {
String identifier = nameMatcher.normalize(entry.getName());
String commonName = nameMatcher.matchByFirstCommonWordSequence(name, identifier);
if (commonName != null && commonName.length() >= identifier.length()) {
matchMap.put(entry, commonName);
}
}
}
// sort by length of name match (descending)
List<TheTVDBSearchResult> results = new ArrayList<TheTVDBSearchResult>(matchMap.keySet());
sort(results, new Comparator<TheTVDBSearchResult>() {
@Override
public int compare(TheTVDBSearchResult a, TheTVDBSearchResult b) {
return Integer.compare(matchMap.get(b).length(), matchMap.get(a).length());
}
});
return results;
}
public static Collection<AnidbSearchResult> detectAnimeByName(String... names) throws Exception {
final HighPerformanceMatcher nameMatcher = new HighPerformanceMatcher();
final Map<AnidbSearchResult, String> matchMap = new HashMap<AnidbSearchResult, String>();
for (final AnidbSearchResult entry : WebServices.AniDB.getAnimeTitles()) {
for (String name : names) {
for (String identifier : new String[] { entry.getPrimaryTitle(), entry.getOfficialTitle("en") }) {
if (identifier == null || identifier.isEmpty())
continue;
identifier = nameMatcher.normalize(entry.getName());
String commonName = nameMatcher.matchByFirstCommonWordSequence(name, identifier);
if (commonName != null && commonName.length() >= identifier.length()) {
matchMap.put(entry, commonName);
}
}
}
}
// sort by length of name match (descending)
List<AnidbSearchResult> results = new ArrayList<AnidbSearchResult>(matchMap.keySet());
sort(results, new Comparator<AnidbSearchResult>() {
@Override
public int compare(AnidbSearchResult a, AnidbSearchResult b) {
return Integer.compare(matchMap.get(b).length(), matchMap.get(a).length());
}
});
return results;
}
public static Collection<Movie> detectMovie(File movieFile, MovieIdentificationService hashLookupService, MovieIdentificationService queryLookupService, Locale locale, boolean strict) throws Exception {
Set<Movie> options = new LinkedHashSet<Movie>();

BIN
website/data/tvshows.txt.gz Normal file

Binary file not shown.