* beautify sample-script

This commit is contained in:
Reinhard Pointner 2011-11-02 08:26:25 +00:00
parent 9c805d5b2a
commit 6b8e47d531
1 changed files with 5 additions and 3 deletions

View File

@ -1,20 +1,22 @@
// filebot -script "http://filebot.sourceforge.net/data/shell/rsam.groovy" <folder>
import net.sourceforge.filebot.similarity.* import net.sourceforge.filebot.similarity.*
def lang = Locale.ENGLISH
def isMatch(a, b) { new NameSimilarityMetric().getSimilarity(a, b) > 0.9 } def isMatch(a, b) { new NameSimilarityMetric().getSimilarity(a, b) > 0.9 }
/* /*
* Rename anime, tv shows or movies (assuming each folder represents one item) * Rename anime, tv shows or movies (assuming each folder represents one item)
*/ */
args.eachMediaFolder { dir -> args.eachMediaFolder { dir ->
def n = dir.getName() def n = dir.name
def lang = Locale.ENGLISH
[ [db:anidb, query:{ anidb.search(n, lang).find{ isMatch(it, n) } }], [ [db:anidb, query:{ anidb.search(n, lang).find{ isMatch(it, n) } }],
[db:thetvdb, query:{ thetvdb.search(n, lang).find{ isMatch(it, n) } }], [db:thetvdb, query:{ thetvdb.search(n, lang).find{ isMatch(it, n) } }],
[db:themoviedb, query:{ themoviedb.searchMovie(n, lang).find{ isMatch(it, n) } }] [db:themoviedb, query:{ themoviedb.searchMovie(n, lang).find{ isMatch(it, n) } }]
].find { ].find {
def match = it.query() def match = it.query()
if (match) { rename(folder:dir, db:it.db.getName(), query:match.getName()) } if (match) { rename(folder:dir, db:it.db.name, query:match.name) }
return match return match
} }
} }