-
Notifications
You must be signed in to change notification settings - Fork 140
/
explain.groovy
executable file
·58 lines (50 loc) · 1.3 KB
/
explain.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
50
51
52
53
54
55
56
57
58
#!/usr/bin/env -S filebot -script
/*
* Print match metrics (if a file argument is passed along)
*/
if (args) {
args.getFiles{ it.isVideo() }.each{ f ->
println ' File / Object / Media '.center(80, '-')
println 'File: ' + f
println 'Object: ' + f.xattr['net.filebot.metadata']
println 'Media: ' + any{ f.mediaCharacteristics }{ null }
if (f.metadata) {
println ' Episode Metrics '.center(80, '-')
EpisodeMetrics.defaultSequence(false).each{ m ->
println String.format('%-20s % 1.1f', m, m.getSimilarity(f, f.metadata))
}
}
}
}
/*
* Print local index matches (if the --q option is passed along)
*/
if (_args.query) {
def q = _args.query
// search series index
WebServices.episodeListProviders.each{ db ->
db.index.each{ s ->
s.effectiveNames.each{ n ->
if (n.findWordMatch(q) || s.id ==~ q) {
println "$n [$db.identifier::$s.id]"
}
}
}
}
// search movie index
WebServices.movieLookupServices.each{ db ->
db.index.each{ m ->
m.effectiveNames.each{ n ->
if (n.findWordMatch(q) || m.id ==~ q) {
println "$n [$db.identifier::$m.id]"
}
}
}
}
// search anime mappings
WebServices.AnimeList.model.anime.each{ m ->
if (m.name.findWordMatch(q) || m.tvdbname.findWordMatch(q) || m.anidbid ==~ q || m.tvdbid ==~ q) {
println m
}
}
}