[Script] Generate custom NFO files

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
User avatar
rednoah
The Source
Posts: 23908
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[Script] Generate custom NFO files

Post by rednoah »

This post-processing script for Plain File Mode will generate custom NFO files:

Groovy: Select all

{ source, target ->
	XML(target.dir / target.nameWithoutExtension + '.xml') {
		nfo {
			title(target.nameWithoutExtension)
			originaltitle(source.nameWithoutExtension)
			aired(d)
			runtime(minutes)
			fileinfo {
				streamdetails {
					target.mediaInfo.Video.each{ v ->
						video {
							codec(v.'Encoded_Library/Name' ?: v.'CodecID/Hint' ?: v.'Format')
							aspect(v.'DisplayAspectRatio')
							width(v.'Width')
							height(v.'Height')
						}
					}
					target.mediaInfo.Audio.each{ a ->
						audio {
							codec(a.'CodecID/Hint' ?: a.'Format')
							language(a.'Language/String3')
							channels(a.'Channel(s)_Original' ?: a.'Channel(s)')
						}
					}
				}
			}
		}
	}
}

Console Output: Select all

$ ls
REC_2016-10-03_01.mp4
REC_2016-10-03_01.xml

xml: Select all

<nfo>
  <title>REC_2016-10-03_01</title>
  <originaltitle>GH010104</originaltitle>
  <aired>2016-10-03</aired>
  <runtime>5</runtime>
  <fileinfo>
    <streamdetails>
      <video>
        <codec>AVC</codec>
        <aspect>1.778</aspect>
        <width>1920</width>
        <height>1080</height>
      </video>
      <audio>
        <codec>AAC</codec>
        <language>eng</language>
        <channels>2</channels>
      </audio>
    </streamdetails>
  </fileinfo>
</nfo>
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23908
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

[Script] Generate *-mediainfo.xml files

Post by rednoah »

This post-processing script for Plain File Mode will use the mediainfo command-line tool to generate a *-mediainfo.xml file for each video file:

Groovy: Select all

{ source, target ->
    if (target.video) {
        system 'mediainfo', target, "--LogFile=${target.dir / target.nameWithoutExtension}-mediainfo.xml", '--Output=XML'    
    }
}

Console Output: Select all

$ ls
Avatar.mp4
Avatar-mediainfo.xml
:idea: Please read the FAQ and How to Request Help.
Post Reply