I'm hacking together a couple of scripts here and stuck on a way to put <streamdetails> into an nfo. I have a snippet below that I scooped. It does not return anything though. Any ideas what I might be doing wrong?
Code: Select all
import groovy.xml.*
import net.sourceforge.filebot.mediainfo.*
import net.sourceforge.filebot.mediainfo.MediaInfo
import static net.sourceforge.filebot.WebServices.*
import static groovy.json.StringEscapeUtils.*
import static net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind.*
def fetchMovieNfo(outputFile, movieInfo, movieFile, override) {
def i = movieInfo
def mi = _guarded{ movieFile ? MediaInfo.snapshot(movieFile) : null }
XML {
movie {
title(i.name)
originaltitle(i.originalName)
rating(i.rating)
year(i.released?.year)
votes(i.votes)
plot(i.overview)
tagline(i.tagline)
runtime(i.runtime)
mpaa(i.certification)
genre(i.genres?.size() > 0 ? i.genres[0] : null)
director(i.director)
//Studio()
//Trailer(link to youtube trailer from tmdb)
fileinfo {
streamdetails {
mi?.each { kind, streams ->
def section = kind.toString().toLowerCase()
streams.each { s ->
if (section == 'video') {
video {
codec((s.'Encoded_Library/Name' ?: s.'CodecID/Hint' ?: s.'Format').replaceAll(/[ ].+/, '').trim())
aspect(s.'DisplayAspectRatio')
width(s.'Width')
height(s.'Height')
//durationinseconds
}
}
if (section == 'audio') {
audio {
codec((s.'CodecID/Hint' ?: s.'Format').replaceAll(/\p{Punct}/, '').trim())
language(s.'Language/String3')
channels(s.'Channel(s)')
}
}
if (section == 'text') {
subtitle {
language(s.'Language/String3')
}
}
}
}
}
}
i.cast?.each{ a ->
actor {
name(a.name)
role(a.character)
//thumb(link to actor pic)
}
}
imdbid("tt" + (i.imdbId ?: 0).pad(7))
tmdbid(i.id)
}
}
.saveAs(outputFile)
}
<fileinfo>
<streamdetails></streamdetails>
</fileinfo>
You'll also notice some commented pieces, I'd like to pull 'Studio Information' (i.studio)? and 'Trailer' (i.trailers)? from tmdb and durationinseconds for the streamdetails section.
Mind pointing me in the right direction?! Thanks!