Media Index TSV - but info from NFO

All your suggestions, requests and ideas for future development
Post Reply
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Media Index TSV - but info from NFO

Post by kim »

pls make a script that can collect info/data from e.g. the movie.nfo and then write to csv/tsv file
like this, but info from NFO:
viewtopic.php?f=4&t=5#p53

To be used as a database for all your stuff
the Media Index TSV scans too slow and NFO has better info/data I think

btw: I tried to make it myself, but NOT going well :(
by combining the mi.groovy with this:

Code: Select all

args.getFiles{ it.extension == 'nfo' }.each{ nfo ->
	log.finest "Links from NFO: $nfo"
	def xml = new XmlSlurper().parse(nfo)
	['imdb', 'tmdb', 'tvdb'].each{ db ->
		def url = xml."$db".text()
		if (url) {
			def urlFile = new File(nfo.dir, "${db}.url")
			def content = "[InternetShortcut]\nURL=${url}\n"
			content.saveAs(urlFile)
			log.finest "Url File: [$urlFile] / [$url]"
		}
	}
}
the problem is I cant get the e.g. "xml.fileinfo.streamdetails.video.codec" part to work only the 1st level e.g. title

Code: Select all

{def model = [
	'id': 'id',
	'title': 'title',
	'originaltitle': 'originaltitle',
	'year': 'year',
	'runtime': 'runtime',
	'rating': 'rating',
	'video codec': 'fileinfo.streamdetails.video.codec',
	'video width': 'fileinfo.streamdetails.video.width',
	'video height': 'fileinfo.streamdetails.video.height',
	'audio codec': 'fileinfo.streamdetails.audio.codec',
	'audio channels': 'fileinfo.streamdetails.audio.channels'
];
def xml = new XmlSlurper().parse(folder/'movie'+'.nfo');
	model.values().each{db ->
		def info = xml."$db".text()
		println db +': '+ info;
	}
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Media Index TSV - but info from NFO

Post by kim »

This was the best I could do :(
BUT it works :)

PLS update it if you can make it better

Code: Select all

def model = [
	'IMDB id','Title','Original Title','Year','Runtime','Rating','FileSize','Overall Bitrate','Checksum','Video Codec','DurationInSeconds','Video Width','Video Height','Audio Codec','Audio Channels'
]
def separator = ';'
def header = model.join(separator)

// open output file
def outputFile = any{ _args.output }{ 'NFO_MediaIndex.csv' }.toFile().getCanonicalFile()

outputFile.withWriter('UTF-8'){ output ->
		// print to console
		println "Writing CSV file [$outputFile]"
		log.config header

		// print header
		output.println(header)
		// args.getFiles{ it.extension == 'nfo' }.each{ nfo ->
		args.getFiles{ it.name == 'movie.nfo' }.each{ nfo ->
			def xml = new XmlSlurper().parse(nfo)
			def info = xml.findResult{[
				it.id.text(),
				it.title.text(),
				it.originaltitle.text(),
				it.year.text(),
				it.runtime.text(),
				it.rating.text(),
				it.fileinfo.streamdetails.general.filesize.join(' / '),
				it.fileinfo.streamdetails.general.overallbitrate.join(' / '),
				it.fileinfo.streamdetails.general.checksum.join(' / '),
				it.fileinfo.streamdetails.video.codec.join(' / '),
				it.fileinfo.streamdetails.video.durationinseconds.join(' / '),
				it.fileinfo.streamdetails.video.width.join(' / '),
				it.fileinfo.streamdetails.video.height.join(' / '),
				it.fileinfo.streamdetails.audio.codec.join(' / '),
				it.fileinfo.streamdetails.audio.channels.join(' / ')]
			}

			def list = info.join(separator)

			// print to console
			log.info list

			// append to file
			output.println(list)
		}
}
btw: some of this may not be in your movie.nfo
Post Reply