forked from filebot/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
miss.groovy
57 lines (39 loc) · 1.02 KB
/
miss.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
#!/usr/bin/env filebot -script
// sanity checks
if (args.size() == 0) {
die "Illegal usage: no input"
}
def episodes = []
def shows = [] as LinkedHashSet
args.getFiles().each{ f ->
if (f.isVideo()) {
def episode = f.metadata
def seriesInfo = any{ episode.seriesInfo }{ null }
if (episode instanceof Episode && seriesInfo instanceof SeriesInfo) {
log.finest "$seriesInfo | $episode | $f"
shows += seriesInfo
if (episode instanceof MultiEpisode) {
episodes += episode.episodes as List
} else {
episodes += episode
}
}
}
}
if (episodes.size() == 0) {
die "No xattr tagged files"
}
def episodeList = shows.collectMany{
def db = getService(it.database)
def el = db.getEpisodeList(it.id, it.order as SortOrder, it.language as Locale)
// ignore special episodes
return el.findAll{ it.regular }
} as LinkedHashSet
// print missing episodes
def missingEpisodes = episodeList - episodes
if (missingEpisodes.size() == 0) {
log.finest "No missing episodes"
}
missingEpisodes.each{
println it
}