forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mi.groovy
49 lines (40 loc) · 1.06 KB
/
mi.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env filebot -script
/*
* Print media info of all video files to TSV file
*/
def model = [
'Name': 'fn',
'Container': 'cf',
'Resolution': 'resolution',
'Video Codec': 'vc',
'Video Format': 'vf',
'Audio Codec': 'ac',
'Audio Channels': 'channels',
'Audio Languages': 'audioLanguages',
'Subtitle Languages': 'textLanguages',
'Duration': 'hours',
'File Size': 'megabytes',
'Path': 'f.canonicalPath',
'Original Name': 'original',
'Extended Attributes': 'json'
]
def separator = '\t'
def header = model.keySet().join(separator)
def format = model.values().collect{ "{$it}" }.join(separator)
// open output file
def outputFile = any{ _args.output }{ 'MediaIndex.tsv' }.toFile().getCanonicalFile()
outputFile.withWriter('UTF-8'){ output ->
// print to console
log.finest "Writing TSV file [$outputFile]"
log.config header
// print header
output.println(header)
// print info for each video file
args.getFiles{ it.isVideo() }.each{
def mi = getMediaInfo(it, format)
// print to console
log.info mi
// append to file
output.println(mi)
}
}