From bff47228c0bf2ca9dea13b485fe5deffec767033 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Thu, 6 Mar 2014 14:28:46 +0000 Subject: [PATCH] * xattr 1st class by default if possible --- .../filebot/cli/ScriptShell.lib.groovy | 18 ++++++++++++++++-- .../filebot/media/MediaDetection.java | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index 76d5b9e1..dcc18fbd 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -237,8 +237,22 @@ def detectSeriesName(files, boolean useSeriesIndex = true, boolean useAnimeIndex } def detectMovie(File file, strict = true, queryLookupService = TheMovieDB, hashLookupService = OpenSubtitles, locale = Locale.ENGLISH) { - def movies = MediaDetection.matchMovieName(file.listPath(4, true).findResults{ it.name ?: null }, true, 0) ?: MediaDetection.detectMovie(file, hashLookupService, queryLookupService, locale, strict) - return movies == null || movies.isEmpty() ? null : movies.toList()[0] + // 1. xattr + def m = tryQuietly{ file.metadata.object as Movie } + if (m != null) + return m + + // 2. perfect filename match + m = MediaDetection.matchMovieName(file.listPath(4, true).findResults{ it.name ?: null }, true, 0) + if (m != null && m.size() > 0) + return m[0] + + // 3. run full-fledged movie detection + m = MediaDetection.detectMovie(file, hashLookupService, queryLookupService, locale, strict) + if (m != null && m.size() > 0) + return m[0] + + return null } def matchMovie(String filename, strict = true, maxStartIndex = 0) { diff --git a/source/net/sourceforge/filebot/media/MediaDetection.java b/source/net/sourceforge/filebot/media/MediaDetection.java index 1fb3c845..dee7e789 100644 --- a/source/net/sourceforge/filebot/media/MediaDetection.java +++ b/source/net/sourceforge/filebot/media/MediaDetection.java @@ -521,7 +521,7 @@ public class MediaDetection { return seriesList; } - public static Collection detectMovie(File movieFile, MovieIdentificationService hashLookupService, MovieIdentificationService queryLookupService, Locale locale, boolean strict) throws Exception { + public static List detectMovie(File movieFile, MovieIdentificationService hashLookupService, MovieIdentificationService queryLookupService, Locale locale, boolean strict) throws Exception { Set options = new LinkedHashSet(); // try xattr metadata if enabled