-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathxattr.groovy
36 lines (29 loc) · 886 Bytes
/
xattr.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
#!/usr/bin/env filebot -script
args.getFiles{ f -> f.xattr.size() > 0 }.each{ f ->
log.finest "$f"
f.xattr.each{ k, v ->
log.info "\t$k: $v"
}
// clear xattr mode
if (_args.action == 'clear') {
f.xattr.clear()
log.finest '*** CLEARED ***'
}
// import xattr metadata into Mac OS X Finder tags (UAYOR)
if (_args.action == 'import') {
def xkey = 'com.apple.metadata:_kMDItemUserTags'
def info = getMediaInfo(f, '''{if (movie) 'Movie'};{if (episode) 'Episode'};{source};{vf};{sdhd}''')
def tags = info.split(';')*.trim().findAll{ it.length() > 0 }
def plist = '''<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\n''' + XML{
plist(version:'1.0') {
array {
tags.each{
string(it)
}
}
}
}
log.info "*** Write tag plist to xattr [$xkey]: $tags ***"
f.xattr[xkey] = plist
}
}