2011-12-20 13:00:38 +00:00
|
|
|
// filebot -script "http://filebot.sourceforge.net/data/shell/banners.groovy" -trust-script /path/to/media/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch series and season banners for all tv shows
|
|
|
|
*/
|
|
|
|
import static net.sourceforge.filebot.WebServices.*
|
|
|
|
|
|
|
|
|
2011-12-21 02:39:25 +00:00
|
|
|
def fetchBanner(outputDir, outputName, series, bannerType, bannerType2, season = null) {
|
2011-12-20 13:00:38 +00:00
|
|
|
// select and fetch banner
|
|
|
|
def banner = TheTVDB.getBanner(series, bannerType, bannerType2, season, Locale.ENGLISH)
|
|
|
|
if (banner == null) {
|
2011-12-21 02:39:25 +00:00
|
|
|
println "Banner not found: $outputName"
|
|
|
|
return null
|
2011-12-20 13:00:38 +00:00
|
|
|
}
|
|
|
|
|
2011-12-21 02:39:25 +00:00
|
|
|
def output = new File(outputDir, outputName + "." + banner.extension)
|
|
|
|
println "SaveAs $output"
|
|
|
|
return banner.url.saveAs(output)
|
2011-12-20 13:00:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def fetchSeriesBanners(dir, series, seasons) {
|
|
|
|
println "Fetch banners for $series / Season $seasons"
|
|
|
|
|
2011-12-21 02:39:25 +00:00
|
|
|
// fetch series banner, fanart, posters, etc
|
|
|
|
fetchBanner(dir, "folder", series, "poster", "680x1000")
|
|
|
|
fetchBanner(dir, "banner", series, "series", "graphical")
|
|
|
|
|
|
|
|
// fetch highest resolution fanart
|
|
|
|
["1920x1080", "1280x720"].findResult{ bannerType2 -> fetchBanner(dir, "fanart", series, "fanart", bannerType2) }
|
2011-12-20 13:00:38 +00:00
|
|
|
|
|
|
|
// fetch season banners
|
|
|
|
seasons.each { s ->
|
2011-12-21 02:39:25 +00:00
|
|
|
fetchBanner(dir, "folder-S${s.pad(2)}", series, "season", "season", s)
|
|
|
|
fetchBanner(dir, "banner-S${s.pad(2)}", series, "season", "seasonwide", s)
|
2011-12-20 13:00:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
args.eachMediaFolder() { dir ->
|
|
|
|
println "Processing $dir"
|
|
|
|
def videoFiles = dir.listFiles{ it.isVideo() }
|
|
|
|
|
|
|
|
def seriesName = detectSeriesName(videoFiles)
|
|
|
|
def seasons = videoFiles.findResults { guessEpisodeNumber(it)?.season }.unique()
|
|
|
|
|
2011-12-21 02:39:25 +00:00
|
|
|
if (seriesName == null) {
|
|
|
|
println "Failed to detect series name from files -> Query by ${dir.name} instead"
|
|
|
|
seriesName = dir.name
|
|
|
|
}
|
|
|
|
|
2011-12-20 13:00:38 +00:00
|
|
|
def options = TheTVDB.search(seriesName)
|
|
|
|
if (options.isEmpty()) {
|
2011-12-20 14:07:12 +00:00
|
|
|
println "TV Series not found: $seriesName"
|
2011-12-20 13:00:38 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fetchSeriesBanners(dir, options[0], seasons)
|
|
|
|
}
|