From c68c5adb3a2cba08270f90f8df4c8dcd38356a41 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 24 May 2015 22:54:59 +0000 Subject: [PATCH] * include movie alias titles in osdb index --- build-data/BuildData.groovy | 70 +++++++++++-------- source/net/filebot/media/ReleaseInfo.java | 14 ++-- .../net/filebot/web/SubtitleSearchResult.java | 2 +- 3 files changed, 50 insertions(+), 36 deletions(-) diff --git a/build-data/BuildData.groovy b/build-data/BuildData.groovy index c25be62c..fe90a1f5 100755 --- a/build-data/BuildData.groovy +++ b/build-data/BuildData.groovy @@ -111,35 +111,6 @@ def csv(f, delim, keyIndex, valueIndex) { /* ------------------------------------------------------------------------- */ -// BUILD osdb index -def osdb = [] - -new File('osdb.txt').eachLine('UTF-8'){ - def fields = it.split(/\t/)*.trim() - - // 0 IDMovie, 1 IDMovieImdb, 2 MovieName, 3 MovieYear, 4 MovieKind, 5 MoviePriority - if (fields.size() == 6 && fields[1] ==~ /\d+/ && fields[3] ==~ /\d{4}/) { - if (fields[4] ==~ /movie|tv.series/ && isValidMovieName(fields[2]) && (fields[3] as int) >= 1970 && (fields[5] as int) >= 100) { - // 0 imdbid, 1 name, 2 year, 3 kind, 4 priority - osdb << [fields[1] as int, fields[2], fields[3] as int, fields[4] == /movie/ ? 'm' : fields[4] == /tv series/ ? 's' : '?', fields[5] as int] - } - } -} - -// sort reverse by score -osdb.sort{ a, b -> b[4] <=> a[4] } - -// reset score/priority because it's currently not used -osdb*.set(4, 0) - -// sanity check -if (osdb.size() < 30000) { die('OSDB index sanity failed:' + osdb.size()) } -pack(osdb_out, osdb*.join('\t')) - - -/* ------------------------------------------------------------------------- */ - - // BUILD moviedb index def omdb = [] new File('omdbMovies.txt').eachLine('Windows-1252'){ @@ -349,3 +320,44 @@ def anidb_txt = anidb_index.findResults{ row -> row.join('\t') }.sort().unique() // sanity check if (anidb_txt.size() < 8000) { die('AniDB index sanity failed:' + anidb_txt.size()) } pack(anidb_out, anidb_txt) + + +/* ------------------------------------------------------------------------- */ + + +// BUILD osdb index +def osdb = [] + +new File('osdb.txt').eachLine('UTF-8'){ + def fields = it.split(/\t/)*.trim() + + // 0 IDMovie, 1 IDMovieImdb, 2 MovieName, 3 MovieYear, 4 MovieKind, 5 MoviePriority + if (fields.size() == 6 && fields[1] ==~ /\d+/ && fields[3] ==~ /\d{4}/) { + if (fields[4] ==~ /movie|tv.series/ && isValidMovieName(fields[2]) && (fields[3] as int) >= 1970 && (fields[5] as int) >= 100) { + // 0 imdbid, 1 name, 2 year, 3 kind, 4 priority + osdb << [fields[1] as int, fields[2], fields[3] as int, fields[4] == /movie/ ? 'm' : fields[4] == /tv series/ ? 's' : '?', fields[5] as int] + } + } +} + +// sort reverse by score +osdb.sort{ a, b -> b[4] <=> a[4] } + +// reset score/priority because it's currently not used +osdb*.set(4, 0) + +// collect final output data +osdb = osdb.findResults{ + def names = [it[1]] + if (it[3] == 'm') { + def tmdb_entry = tmdb_index[it[0].pad(7)] + if (tmdb_entry != null) { + names += tmdb_entry[4..-1] + } + } + return [it[3], it[4], it[0], it[2]] + names.unique() +} + +// sanity check +if (osdb.size() < 30000) { die('OSDB index sanity failed:' + osdb.size()) } +pack(osdb_out, osdb*.join('\t')) diff --git a/source/net/filebot/media/ReleaseInfo.java b/source/net/filebot/media/ReleaseInfo.java index 6183de21..0529f4c5 100644 --- a/source/net/filebot/media/ReleaseInfo.java +++ b/source/net/filebot/media/ReleaseInfo.java @@ -38,6 +38,7 @@ import net.filebot.web.CachedResource; import net.filebot.web.Movie; import net.filebot.web.SubtitleSearchResult; import net.filebot.web.TheTVDBSearchResult; +import net.filebot.web.SubtitleSearchResult.Kind; import org.tukaani.xz.XZInputStream; @@ -451,12 +452,13 @@ public class ReleaseInfo { List result = new ArrayList(rows.size()); for (String[] row : rows) { - int imdbid = parseInt(row[0]); - String name = row[1]; - int year = parseInt(row[2]); - String kind = row[3]; - int score = parseInt(row[4]); - result.add(new SubtitleSearchResult(imdbid, name, year, kind, score)); + String kind = row[0]; + int score = parseInt(row[1]); + int imdbId = parseInt(row[2]); + int year = parseInt(row[3]); + String name = row[4]; + String[] aliasNames = copyOfRange(row, 5, row.length); + result.add(new SubtitleSearchResult(name, aliasNames, year, imdbId, -1, Locale.ENGLISH, SubtitleSearchResult.Kind.forName(kind), score)); } return result.toArray(new SubtitleSearchResult[0]); diff --git a/source/net/filebot/web/SubtitleSearchResult.java b/source/net/filebot/web/SubtitleSearchResult.java index 818fdf6a..68ad7a90 100644 --- a/source/net/filebot/web/SubtitleSearchResult.java +++ b/source/net/filebot/web/SubtitleSearchResult.java @@ -5,7 +5,7 @@ import java.util.Locale; public class SubtitleSearchResult extends Movie { - enum Kind { + public enum Kind { Movie, Series, Other, Unkown; public static Kind forName(String s) {