mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-16 06:15:02 -05:00
* fine-tune movie/tvshow differentiation
This commit is contained in:
parent
ba1b3f5026
commit
98fb65e088
@ -56,6 +56,8 @@ String.metaClass.validateFilePath = { validateFilePath(delegate) }
|
||||
// helper for enforcing filename length limits, e.g. truncate filename but keep extension
|
||||
String.metaClass.truncateFileName = { int limit = 255 -> def ext = getExtension(delegate); def name = getNameWithoutExtension(delegate); return name.substring(0, Math.min(limit - (ext ? 1+ext.length() : 0), name.length())) + (ext ? '.'+ext : '') }
|
||||
|
||||
// helper for simplifying strings
|
||||
String.metaClass.normalizePunctuation = { net.sourceforge.filebot.similarity.Normalization.normalizePunctuation(delegate) }
|
||||
|
||||
// Parallel helper
|
||||
import java.util.concurrent.*
|
||||
@ -223,11 +225,11 @@ def detectMovie(File movieFile, strict = true, queryLookupService = TheMovieDB,
|
||||
return movies == null || movies.isEmpty() ? null : movies.toList()[0]
|
||||
}
|
||||
|
||||
def matchMovie(movieFile, strict = false) { // same as detectMovie() using only the local movie index making it VERY FAST
|
||||
return detectMovie(movieFile, strict, Locale.ENGLISH, null, null)
|
||||
def matchMovie(String filename, strict = true, maxStartIndex = 0) {
|
||||
def movies = MediaDetection.matchMovieName([filename], strict, maxStartIndex)
|
||||
return movies == null || movies.isEmpty() ? null : movies.toList()[0]
|
||||
}
|
||||
|
||||
|
||||
def similarity(o1, o2) {
|
||||
return new NameSimilarityMetric().getSimilarity(o1, o2)
|
||||
}
|
||||
|
@ -122,14 +122,14 @@ def groups = input.groupBy{ f ->
|
||||
|
||||
// DECIDE EPISODE VS MOVIE (IF NOT CLEAR)
|
||||
if (tvs && mov) {
|
||||
def norm = { s -> s.ascii().lower().space(' ') }
|
||||
def norm = { s -> s.ascii().normalizePunctuation().lower().space(' ') }
|
||||
def dn = norm(guessMovieFolder(f)?.name ?: '')
|
||||
def fn = norm(f.nameWithoutExtension)
|
||||
def sn = norm(tvs)
|
||||
def mn = norm(mov.name)
|
||||
|
||||
// S00E00 | 2012.07.21 | One Piece 217 | Firefly - Serenity | [Taken 1, Taken 2, Taken 3, Taken 4, ..., Taken 10]
|
||||
if (parseEpisodeNumber(fn, true) || parseDate(fn) || (fn =~ sn && parseEpisodeNumber(fn.after(sn), false) && !matchMovie(f, true)) || (fn.after(sn) ==~ /.{0,3} - .+/ && !matchMovie(f, true)) || f.dir.listFiles{ it.isVideo() && norm(it.name) =~ sn && it.name =~ /\b\d{1,3}\b/}.size() >= 10) {
|
||||
if (parseEpisodeNumber(fn, true) || parseDate(fn) || (fn =~ sn && (parseEpisodeNumber(fn.after(sn), false) || fn.after(sn) =~ /\d{1,2}\D+\d{1,2}/) && matchMovie(fn, true) == null) || (fn.after(sn) ==~ /.{0,3} - .+/ && matchMovie(fn, true) == null) || f.dir.listFiles{ it.isVideo() && norm(it.name) =~ sn && it.name =~ /\b\d{1,3}\b/}.size() >= 10) {
|
||||
_log.fine("Exclude Movie: $mov")
|
||||
mov = null
|
||||
} else if ((detectMovie(f, true) && [dn, fn].find{ it =~ /(19|20)\d{2}/ }) || [dn, fn].find{ it =~ mn && !(it.after(mn) =~ /\b\d{1,3}\b/) }) {
|
||||
|
Loading…
Reference in New Issue
Block a user