-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathanimeFormat.groovy.j2
121 lines (117 loc) · 3.94 KB
/
animeFormat.groovy.j2
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{
// \u201C = “
// \u201D = ”
// \u201E = „
// \u201F = “
def normTV = {
it.replaceAll(/[`´‘’ʻ""“”“„‟]/, "'")
.replaceAll(/[|]/, ' - ')
.replaceAll(/[?]/, '\uFE56') // '﹖' Small Question Mark
.replaceAll(/[\*]/, '\u204E') // '⁎' low asterisk
.replaceAll(/[*\p{Zs}]+/, ' ')
.replaceAll(/\b[IiVvXx]+\b/, { it.upper() })
.replaceAll(/\b[0-9](?i:th|nd|rd)\b/, { it.lower() })
}
Boolean isEng = any{ audio.language.any{ it ==~ /en/ } }{ audio.language ==~ /en/ }{true}
Boolean isJpn = any{ languages.first().ISO2 ==~ /ja/ }{ audio.language.first() ==~ /ja/ }{ false }
// WARNING: any db.{AniDB,TMDb,TheTVDB} binding requires FileBot 4.8.6 or above
String mainTitle = any{ db.TMDb.n }{ db.TheTVDB.n }{ normTV(n).colon(' - ').replaceTrailingBrackets() }
String primTitle = normTV(primaryTitle).colon(' - ').replaceTrailingBrackets()
String.metaClass.surround { l = '(', r = ')' ->
l + delegate + r
}
allOf
{ 'Anime' }
{
allOf
{ mainTitle }
{ db.TMDb.y.toString().surround() }
.join(' ')
}
{
// TODO: possibly replace with db.TMDb.special
if (episode.special) { // else { if (sc > 0) "Season $s" }
'Specials'
} else {
allOf
{ ['Season', db.TMDb.s].join(' ') }
{ if (mainTitle.getSimilarity(primTitle) < 0.95) primTitle.surround('[', ']') }
{ db.TMDb.sy.bounds().join('-').surround() }
.join(' ')
}
}
{
allOf
{
allOf
{ include '{{ scriptDir }}/partials/groupPart.groovy' }
{ mainTitle }
.join(' ')
}
{ // EPISODE NUMBERING
// String _absolute = 'EP' + db.TMDb.absolute.pad(2)
if (episode.special) {
"S$special"
} else {
any
{
allOf
/*
{ if (db.TMDb.sc > 1) db.TMDb.s00e00 }
{ db.TMDb.sc > 1 ? _absolute.surround('(', ')') : _absolute }
*/
{ db.TMDb.sxe }
{ db.TMDb.absolute.pad(2).surround() }
.join(' ')
}
{ absolute.pad(2) }
}
}
{
allOf
{ // EPISODE NAME
def trLang = any{ if (isJpn) 'x-jat' }{ if (isEng) 'eng' }{ audio.language.first() }{'eng'}
def epName = any{ db.TMDb.t }{t}
// ╱ is the replacement for slash
switch (trLang) {
case { it == 'x-jat' }:
allOf
{ normTV(localize."$trLang".t).colon('\u2236').slash('\u2571') }
{ normTV(epName).colon('\u2236').slash('\u2571').surround('[', ']') }
.join(' ')
break
case { it == 'eng' }:
normTV(epName).colon('\u2236').slash('\u2571')
break
default:
normTV(localize."$trLang".t).colon('\u2236').slash('\u2571')
}
}
{ tags.join(', ').replaceAll(/^/, ' - ') }
{ "PT $pi" }
{
allOf
{ allOf
{ // Video
// net.filebot.media.VideoFormat.DEFAULT_GROUPS.guessFormat(dim[0], dim[1])
allOf
{ vf }
{ vc }
{ include '{{ scriptDir }}/partials/hdrPart.groovy' }
.join(' ')
}
{ include '{{ scriptDir }}/partials/audioPart.groovy' }
{ include '{{ scriptDir }}/partials/extraSource.groovy' }
.join(' - ').surround('[', ']')
}
{ "[$crc32]" }
{ include '{{ scriptDir }}/partials/repackPart.groovy' }
{subt}
.join('')
}
.join(' ')
}
.join(' - ')
}
.join('/')
}