-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmovieFormat.groovy.j2
91 lines (85 loc) · 3.15 KB
/
movieFormat.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
{
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
def sub = include('{{ scriptDir }}//partials/stdPart.groovy')
def normMovie = {
it.replaceTrailingBrackets()
// .upperInitial().lowerTrail()
.replaceAll(/[`´‘’ʻ""“”]/, "'")
.replaceAll(/[:|]/, " - ")
// .replaceAll(/[:]/, "\u2236") // "∶" Ratio symbol
// .replaceAll(/[:]/, "\uFF1A") // ":" Fullwidth Colon
// .replaceAll(/[:]/, "\uFE55") // "﹕" Small Colon
// .replaceAll("/", "\u29F8") // "⧸" Big Solidus
// .replaceAll("/", "\u2215") // "∕" Division Slash
// .replaceAll("/", "\u2044") // "⁄" Fraction Slash
// .replaceAll(/[?]/, "\uFF1F") // "?" Fullwidth Question Mark
.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() })
}
Closure<Boolean> isLatin = {
java.text.Normalizer.normalize(it, java.text.Normalizer.Form.NFD)
.replaceAll(/\p{InCombiningDiacriticalMarks}+/, '') ==~ /^\p{InBasicLatin}+$/
}
def translJap = {
/* rate limited to 100 per day I believe, please be careful */
Object url = new URL('https://api.kuroshiro.org/convert')
Map requestHeaders = [:]
Map postBody = [:]
postBody.str = it
postBody.to = 'romaji'
postBody.mode = 'spaced'
postBody.romajiSystem = 'hepburn'
def postResponse = url.post(JsonOutput.toJson(postBody).getBytes('UTF-8'), 'application/json', requestHeaders)
Object json = new JsonSlurper().parseText(postResponse.text)
return json.result
}
def transl = {
(languages.first().iso_639_2B == 'jpn') ? translJap(it) : it.transliterate('Any-Latin; NFD; NFC; Title')
}
allOf
{
if ((media.OverallBitRate.toInteger() / 1000 < 3000 && vf.minus("p").toInteger() >= 720)
|| vf.minus("p").toInteger() < 720) {
return "LQ_Movies"
} else {
return "Movies"
}
}
// Movies directory
{ def film_directors = info.directors.sort().join(", ")
n.colon("\u2236 ") + " ($y) [$film_directors]" }
// File name
{
allOf
{ isLatin(primaryTitle) ? primaryTitle.colon("\u2236 ") : transl(primaryTitle).colon("\u2236 ") }
{" ($y)"}
// tags + a few more variants
{ include '{{ scriptDir }}/partials/extraTags.groovy' }
{" PT $pi"}
{" ["}
{
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(" - ")
}
{"]"}
{ include '{{ scriptDir }}/partials/repackPart.groovy' }
{ include '{{ scriptDir }}/partials/groupPart.groovy' }
{ subt }
.join("")
}
.join("/")
}