From a15ee1dd98fa87e4bccb68f884fc066f79af653c Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sat, 21 Jul 2012 14:32:55 +0000 Subject: [PATCH] * updated episode/movie detection (esp. for {n} {e} pattern) --- .../filebot/cli/ScriptShell.lib.groovy | 5 +++++ website/data/query-blacklist.txt | 1 + website/scripts/sorteps.groovy | 12 ------------ website/scripts/sortivo.groovy | 17 ++++++++--------- website/scripts/utorrent-postprocess.groovy | 17 ++++++++--------- 5 files changed, 22 insertions(+), 30 deletions(-) delete mode 100644 website/scripts/sorteps.groovy diff --git a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy index 6e3f6221..5dacfd23 100644 --- a/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy +++ b/source/net/sourceforge/filebot/cli/ScriptShell.lib.groovy @@ -163,6 +163,11 @@ def getRenameLog(complete = false) { import net.sourceforge.filebot.media.* import net.sourceforge.filebot.similarity.* +def isEpisode(path, strict = true) { + def input = path instanceof File ? path.name : path.toString() + return MediaDetection.isEpisode(input, strict) +} + def parseEpisodeNumber(path, strict = true) { def input = path instanceof File ? path.name : path.toString() def sxe = MediaDetection.parseEpisodeNumber(input, strict) diff --git a/website/data/query-blacklist.txt b/website/data/query-blacklist.txt index baea22ca..e14c69e8 100644 --- a/website/data/query-blacklist.txt +++ b/website/data/query-blacklist.txt @@ -24,6 +24,7 @@ ^new$ ^other$ ^Season.[0-9]+ +^storage$ ^Torrents[s]? ^Tracker ^Trailer diff --git a/website/scripts/sorteps.groovy b/website/scripts/sorteps.groovy deleted file mode 100644 index 95a451e2..00000000 --- a/website/scripts/sorteps.groovy +++ /dev/null @@ -1,12 +0,0 @@ -def dir = 'E:/Downloads' - -// extract files from archives and delete archives afterwards -extract(folder:dir, output:dir) && dir.listFiles{ it =~ /rar$/ }*.delete() - -getMissingSubtitles(folder:dir, lang:'de', strict:false) -getMissingSubtitles(folder:dir, lang:'en', strict:false) - -// rename each file individually in strict mode -dir.listFiles().each { - rename(file:it, format:"E:/Series/{n}/{n.space('.')}.{s00e00}.{t.space('.')}", strict:true) -} diff --git a/website/scripts/sortivo.groovy b/website/scripts/sortivo.groovy index 940d2b54..47f80444 100644 --- a/website/scripts/sortivo.groovy +++ b/website/scripts/sortivo.groovy @@ -19,17 +19,16 @@ def groups = input.groupBy{ f -> // DECIDE EPISODE VS MOVIE (IF NOT CLEAR) if (tvs && mov) { - def fn = f.nameWithoutExtension.space(' ') - if (fn =~ "(?i:$tvs - .+)" || parseEpisodeNumber(fn, true) || parseDate(fn)) { + def norm = { s -> s.lower().space(' ') } + 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)) || fn.after(sn) =~ / - .+/ || f.dir.listFiles{ it.isVideo() && norm(it.name) =~ sn && it.name =~ /\b\d{1,3}\b/}.size() >= 10) { println "Exclude Movie: $mov" mov = null - } else if (detectMovie(f, true) && (fn =~ /(19|20)\d{2}/ || !(tvs =~ "(?i:$mov.name)"))) { - println "Exclude Series: $tvs" - tvs = null - } else if (fn =~ "(?i:$tvs)" && parseEpisodeNumber(fn.after(tvs), false)) { - println "Exclude Movie: $mov" - mov = null - } else if (fn =~ "(?i:$mov.name)" && !parseEpisodeNumber(fn.after(mov.name), false)) { + } else if ((detectMovie(f, true) && fn =~ /(19|20)\d{2}/) || (fn =~ mn && !(fn.after(mn) =~ /\b\d{1,3}\b/))) { println "Exclude Series: $tvs" tvs = null } diff --git a/website/scripts/utorrent-postprocess.groovy b/website/scripts/utorrent-postprocess.groovy index 55e6f84b..028d555f 100644 --- a/website/scripts/utorrent-postprocess.groovy +++ b/website/scripts/utorrent-postprocess.groovy @@ -40,17 +40,16 @@ def groups = input.groupBy{ f -> // DECIDE EPISODE VS MOVIE (IF NOT CLEAR) if (tvs && mov) { - def fn = f.nameWithoutExtension.space(' ') - if (fn =~ "(?i:$tvs - .+)" || parseEpisodeNumber(fn, true) || parseDate(fn)) { + def norm = { s -> s.lower().space(' ') } + 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)) || fn.after(sn) =~ / - .+/ || f.dir.listFiles{ it.isVideo() && norm(it.name) =~ sn && it.name =~ /\b\d{1,3}\b/}.size() >= 10) { println "Exclude Movie: $mov" mov = null - } else if (detectMovie(f, true) && (fn =~ /(19|20)\d{2}/ || !(tvs =~ "(?i:$mov.name)"))) { - println "Exclude Series: $tvs" - tvs = null - } else if (fn =~ "(?i:$tvs)" && parseEpisodeNumber(fn.after(tvs), false)) { - println "Exclude Movie: $mov" - mov = null - } else if (fn =~ "(?i:$mov.name)" && !parseEpisodeNumber(fn.after(mov.name), false)) { + } else if ((detectMovie(f, true) && fn =~ /(19|20)\d{2}/) || (fn =~ mn && !(fn.after(mn) =~ /\b\d{1,3}\b/))) { println "Exclude Series: $tvs" tvs = null }