* added support for batch downloading all movie backdrops

This commit is contained in:
Reinhard Pointner 2012-12-16 13:26:39 +00:00
parent 9944693316
commit 8052c400cd
4 changed files with 25 additions and 3 deletions

View File

@ -1482,6 +1482,7 @@ UNTOUCHED
UNVEiL
USELESS
UTOPiA
UTW-Mazui
UVall
VaAr3
VALiOMEDiA
@ -1527,6 +1528,7 @@ WANKAZ
WASABi
WASTE
WastedTime
Wasurenai
WAT
WATBATH
WATCHABLE

View File

@ -38,7 +38,7 @@ args.eachMediaFolder { dir ->
println "$dir => $movie"
try {
fetchMovieArtworkAndNfo(dir, movie, dir.getFiles{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it } )
fetchMovieArtworkAndNfo(dir, movie, dir.getFiles{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it }, true)
} catch(e) {
println "${e.class.simpleName}: ${e.message}"
}

View File

@ -130,6 +130,21 @@ def fetchMovieArtwork(outputFile, movieInfo, category, language) {
return selection.url.saveAs(outputFile)
}
def fetchAllMovieArtwork(outputFolder, movieInfo, category, language) {
// select and fetch artwork
def artwork = TheMovieDB.getArtwork(movieInfo.id as String)
def selection = [language, 'en', null].findResults{ l -> artwork.findAll{ (l == it.language || l == null) && it.category == category } }.flatten().unique()
if (selection == null) {
println "Artwork not found: $outputFolder"
return null
}
selection.eachWithIndex{ s, i ->
def outputFile = new File(outputFolder, "$category-${(i+1).pad(2)}.jpg")
println "Fetching $outputFile => $s"
s.url.saveAs(outputFile)
}
}
def fetchMovieFanart(outputFile, movieInfo, type, diskType, locale) {
def fanart = [locale, null].findResult{ lang -> FanartTV.getMovieArtwork(movieInfo.id).find{ type == it.type && (diskType == null || diskType == it.diskType) && (lang == null || lang == it.language) }}
if (fanart == null) {
@ -209,7 +224,7 @@ def fetchMovieNfo(outputFile, movieInfo, movieFile) {
.saveAs(outputFile)
}
def fetchMovieArtworkAndNfo(movieDir, movie, movieFile = null, locale = _args.locale) {
def fetchMovieArtworkAndNfo(movieDir, movie, movieFile = null, fetchAll = false, locale = _args.locale) {
_guarded {
def movieInfo = TheMovieDB.getMovieInfo(movie, locale)
@ -223,5 +238,9 @@ def fetchMovieArtworkAndNfo(movieDir, movie, movieFile = null, locale = _args.lo
fetchMovieFanart(movieDir['clearart.png'], movieInfo, 'movieart', null, locale)
fetchMovieFanart(movieDir['logo.png'], movieInfo, 'movielogo', null, locale)
['bluray', 'dvd', null].findResult { diskType -> fetchMovieFanart(movieDir['disc.png'], movieInfo, 'moviedisc', diskType, locale) }
if (fetchAll) {
fetchAllMovieArtwork(movieDir['backdrops'], movieInfo, 'backdrops', locale.language)
}
}
}

View File

@ -14,6 +14,7 @@ if (tryQuietly{ ut_state != ut_state_allow }) {
// enable/disable features as specified via --def parameters
def subtitles = tryQuietly{ subtitles.toBoolean() }
def artwork = tryQuietly{ artwork.toBoolean() }
def backdrops = tryQuietly{ backdrops.toBoolean() }
// array of xbmc/plex hosts
def xbmc = tryQuietly{ xbmc.split(/[ ,|]+/) }
@ -176,7 +177,7 @@ groups.each{ group, files ->
if (dest && artwork) {
dest.mapByFolder().each{ dir, fs ->
println "Fetching artwork for $dir from TheMovieDB"
fetchMovieArtworkAndNfo(dir, group.mov, fs.findAll{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it })
fetchMovieArtworkAndNfo(dir, group.mov, fs.findAll{ it.isVideo() }.sort{ it.length() }.reverse().findResult{ it }, backdrops)
}
}
if (dest == null && failOnError) {