* load ExpressionFormat convenience functions into script environment
* change media info sample into "write media info csv table"
This commit is contained in:
parent
397e7c5d38
commit
c37c38c2c7
|
@ -27,6 +27,7 @@ import org.codehaus.groovy.jsr223.GroovyScriptEngineFactory;
|
|||
|
||||
import net.sourceforge.filebot.MediaTypes;
|
||||
import net.sourceforge.filebot.WebServices;
|
||||
import net.sourceforge.filebot.format.ExpressionFormat;
|
||||
import net.sourceforge.filebot.format.PrivilegedInvocation;
|
||||
import net.sourceforge.filebot.web.EpisodeListProvider;
|
||||
import net.sourceforge.filebot.web.MovieIdentificationService;
|
||||
|
@ -47,6 +48,7 @@ class ScriptShell {
|
|||
engine.setContext(context);
|
||||
|
||||
// import additional functions into the shell environment
|
||||
engine.eval(new InputStreamReader(ExpressionFormat.class.getResourceAsStream("ExpressionFormat.lib.groovy")));
|
||||
engine.eval(new InputStreamReader(ScriptShell.class.getResourceAsStream("ScriptShell.lib.groovy")));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
// filebot -script "http://filebot.sourceforge.net/data/shell/mi.groovy" <folder>
|
||||
// filebot -script "http://filebot.sourceforge.net/data/shell/mi.groovy" -trust-script /path/to/media/ "MediaIndex.csv"
|
||||
|
||||
/*
|
||||
* Print media info for all video files using given or default format pattern
|
||||
* Print media info of all video files to CSV file
|
||||
*/
|
||||
args.getFiles()
|
||||
.findAll { it.isVideo() }
|
||||
.sort { a, b -> a.name.compareTo(b.name) }
|
||||
.each { println getMediaInfo(file:it, format:"{fn} [{resolution} {af} {vc} {ac}]") }
|
||||
def model = 'Name;Container;Resolution;Video Codec;Video Format;Audio Codec;Audio Format;Audio Language(s);Duration;File Size;Path'
|
||||
def template = '{fn};{cf};{resolution};{vc};{vf};{ac};{af};{media.AudioLanguageList};{media.DurationString3};{file.length()};{file.getCanonicalPath()}'
|
||||
|
||||
// open destination file (writing files requires -trust-script)
|
||||
args[1].withWriter{ output ->
|
||||
// print header
|
||||
output.writeLine(model)
|
||||
|
||||
// print info for each video file (sorted by filename)
|
||||
args[0].getFiles{ it.isVideo() }.sort{ a, b -> a.name.compareToIgnoreCase(b.name) }.each{
|
||||
def mi = getMediaInfo(file:it, format:template)
|
||||
|
||||
// print to console
|
||||
println mi
|
||||
|
||||
// append to file
|
||||
output.writeLine(mi)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue