2011-11-02 12:21:09 +00:00
|
|
|
// filebot -script "http://filebot.sourceforge.net/data/shell/rsam.groovy" <options> <folder>
|
2011-11-02 08:26:25 +00:00
|
|
|
|
2011-10-30 16:55:32 +00:00
|
|
|
import net.sourceforge.filebot.similarity.*
|
|
|
|
|
|
|
|
def isMatch(a, b) { new NameSimilarityMetric().getSimilarity(a, b) > 0.9 }
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Rename anime, tv shows or movies (assuming each folder represents one item)
|
|
|
|
*/
|
|
|
|
args.eachMediaFolder { dir ->
|
2011-11-02 08:26:25 +00:00
|
|
|
def n = dir.name
|
|
|
|
def lang = Locale.ENGLISH
|
2011-10-30 16:55:32 +00:00
|
|
|
|
|
|
|
[ [db:anidb, query:{ anidb.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) } }]
|
|
|
|
].find {
|
|
|
|
def match = it.query()
|
2011-11-02 08:26:25 +00:00
|
|
|
if (match) { rename(folder:dir, db:it.db.name, query:match.name) }
|
2011-10-30 16:55:32 +00:00
|
|
|
return match
|
|
|
|
}
|
|
|
|
}
|