29 lines
1.1 KiB
Groovy
Executable File
29 lines
1.1 KiB
Groovy
Executable File
def bloqueSubs
|
|
try {
|
|
def capturedSubs = [:]
|
|
bloqueSubs = '['
|
|
for (int s; s<text.size(); s++){ if (text[s]==null || s>10) break; handleSub(text[s], capturedSubs); }
|
|
for (index in 0..<capturedSubs.size()) {
|
|
if (index>3){ bloqueSubs+='etc '; break; }
|
|
bloqueSubs += capturedSubs.get(capturedSubs.keySet().toList()[index]).replace('null','und')+', '
|
|
}
|
|
bloqueSubs = bloqueSubs.substring(0,bloqueSubs.size()-2)+']'
|
|
}catch(err){bloqueSubs=''}
|
|
|
|
def handleSub(sub, capturedSubs) {
|
|
def lang = sub.Language_String3 !=null ? sub.Language_String3
|
|
: (sub.Title=~/(?i).+spa.+/?'spa': sub.Title.substring(0,3).toLowerCase())
|
|
if (sub.Title!=null && sub.Title=~/(?i).*latin.*/) lang='lat'
|
|
def forced = sub.title!=null ? sub.title.toLowerCase().contains("forzado") : false
|
|
if (!capturedSubs.containsKey(lang)) {
|
|
capturedSubs[lang] = lang+(forced?' F':'')
|
|
} else {
|
|
def existing=capturedSubs[lang]
|
|
def newTxt=''+existing
|
|
if (!existing.contains('+')) newTxt += '+'
|
|
if (forced && !existing.contains('F')) newTxt += ' F'
|
|
capturedSubs[lang]=newTxt.replace(" F+","+F")
|
|
}
|
|
}
|
|
|
|
bloqueSubs |