161 lines
6.3 KiB
Groovy
Executable File
161 lines
6.3 KiB
Groovy
Executable File
/*************************************************************************************************************/
|
|
/**** Carpeta / tipo contenido ******************************************************************************/
|
|
/*************************************************************************************************************/
|
|
|
|
//inits
|
|
def tipoYaSeteado=false
|
|
def prodCountries=info.ProductionCountries
|
|
def certifications=info.Certifications
|
|
def pais = {try{country} catch (err) {null}}()
|
|
def numPaises = prodCountries.size()
|
|
def llengu = {try {def langs=[]; for (lan in languages) langs.add(lan.toString()); return langs } catch(err) {[]}}()
|
|
def audioLlengu = {try {def langs=[]; for (lan in audioLanguages) langs.add(lan.toString()); return langs } catch(err) {[]}}()
|
|
|
|
//animacion (no concluyente)
|
|
def tieneAnimacion = genres.any{ it =~ /Anima.i.n/}
|
|
//familiar (no conclud)
|
|
def tieneFamiliar = genres.any{ it =~ /Familia|Family/}
|
|
//docu
|
|
def esDocu = genres.any{ it =~ /Documental|Documentary|Reality/} && !(localize.English.n =~ /Jackass/)
|
|
//Anime ---------- (Animacion encara no es pot perquè depen del infantil)
|
|
def esAnime = false
|
|
if (tieneAnimacion && prodCountries.contains("JP") && (!llengu.isEmpty() ? llengu.contains('jpn') : true)) {
|
|
esAnime = (numPaises==1 || anime || pais=="JP")
|
|
&& ["nemo"].any{!localize.English.n.toLowerCase().contains(it)}
|
|
}
|
|
tipoYaSeteado = esDocu || esAnime
|
|
|
|
//***** familiar vs infantil ****
|
|
def esFamiliar = tieneFamiliar
|
|
def infantil = false
|
|
|
|
if (!tipoYaSeteado) {
|
|
def tieneCertificacion = certifications!=null && certifications.size()!=0
|
|
|
|
if (tieneFamiliar && tieneAnimacion) {
|
|
def noTanInfantil = certifications.US ==~/PG-13/ && certifications.ES!="7"
|
|
if (!noTanInfantil) infantil = true
|
|
}
|
|
else if (tieneAnimacion) {
|
|
if (tieneCertificacion) {
|
|
infantil = certifications.US=="G"
|
|
|| certifications.ES==~/Ai|APTA/
|
|
|| certifications.DE==~/0/
|
|
|| certifications.IT=="T"
|
|
|| certifications.IE=="G"
|
|
|| certifications.LT=="V" || certifications.RU ==~ /6.+/
|
|
|| certifications.BR=="L"
|
|
|| certifications.NO=="A"
|
|
|| certifications.FR=="U"
|
|
} else {
|
|
def titulosInfantiles = ['boonie bears', 'the jungle bunch']
|
|
if (titulosInfantiles.any { localize.English.n.toLowerCase().contains(it) })
|
|
infantil = true
|
|
}
|
|
} else if (!esFamiliar && false) { //em posa pelicules que no toquen
|
|
if (tieneCertificacion && (
|
|
certifications.US=="G"
|
|
)) {
|
|
esFamiliar = true //posem a familiar pelis de nens que no son animacio
|
|
}
|
|
}
|
|
tipoYaSeteado = tipoYaSeteado || infantil
|
|
}
|
|
|
|
//animacion
|
|
def esAnimacion = tieneAnimacion && !infantil
|
|
tipoYaSeteado = tipoYaSeteado || esAnimacion
|
|
|
|
//*** española / catalana ***
|
|
def catalana = false
|
|
def espanyola = false
|
|
if (!tipoYaSeteado && prodCountries.contains("ES")) {
|
|
espanyola=
|
|
(numPaises==1 || (numPaises==2 && prodCountries.any{ it=~/AR|PT/ }))
|
|
|| { try { info.Network =~ /(?i)\bFLIXOL.\b|\b.?TVE\b/ } catch (e) { false } }()
|
|
|| ({ try { info.ProductionCompanies.any{it =~ /.?TVE|ESDIP|Canal Sur|Canal\+|Telecinco/}}catch(e){false}}() && (llengu.size()==1?llengu[0]=="spa":true))
|
|
|| (certifications.size()==1 && certifications.ES!=null)
|
|
|| (llengu.size()==1 && llengu[0]=="spa")
|
|
|| (movie.alternativeTitles.size()==1 && movie.alternativeTitles.ES!=null)
|
|
|| (pais=="ES" && (!llengu.isEmpty() ? llengu.size()==1 && llengu[0]=="spa" : true))
|
|
|
|
catalana = llengu.contains('cat')
|
|
|
|
tipoYaSeteado = tipoYaSeteado || espanyola || catalana
|
|
}
|
|
|
|
//asiaticas
|
|
def asiatica = false
|
|
if (!tipoYaSeteado) {
|
|
def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO", "SU"]
|
|
def paisesIntersec=0
|
|
def languajAsia = ["zho", "kor", "thai", "vie", "jpn", "ind", "rus"]
|
|
def machingLanguages = languajAsia.intersect(llengu).size()
|
|
asiatica = machingLanguages == languajAsia.size()
|
|
|| paisesAsiaticos.any{ pais==it }
|
|
|| (numPaises != 0 && {((paisesIntersec=paisesAsiaticos.intersect(prodCountries).size()) == numPaises || (/*en observacion*/paisesIntersec!=0 && !llengu.contains('eng')) ) }())
|
|
|| (languajAsia.any{audioLlengu.contains(it)} && prodCountries.any{paisesAsiaticos.contains(it)} && llengu.any{languajAsia.contains(it)} )
|
|
|| {try {director.contains("Takeshi Kitano")} catch (e) {false}}()
|
|
|| (machingLanguages > 0 && primaryTitle!=null && localize.English.n!=primaryTitle)
|
|
|
|
tipoYaSeteado = tipoYaSeteado || asiatica
|
|
}
|
|
|
|
|
|
//*** latina ***
|
|
def latina = false
|
|
if (!tipoYaSeteado) {
|
|
def paisesLatinos = ["MX", "AR"]
|
|
latina = {try {paisesLatinos.contains(pais)} catch (e) {false}}()
|
|
|| (numPaises != 0 && paisesLatinos.intersect(prodCountries).size() == numPaises)
|
|
|| prodCountries.any{it=~/Corazón Films/}
|
|
}
|
|
|
|
//////////////////////////////////////////////
|
|
//tria
|
|
if (esDocu) ruta = ruta_docu
|
|
else if (esAnime) ruta = ruta_anime
|
|
else if (infantil) ruta = ruta_infantil
|
|
else if (esAnimacion) ruta = ruta_animacion
|
|
else if (catalana) ruta = ruta_cat
|
|
else if (espanyola) ruta = ruta_esp
|
|
else if (latina) ruta = ruta_latina
|
|
else if (asiatica) ruta = ruta_asiaticas
|
|
else if (esFamiliar && y>1970) ruta = ruta_familiar
|
|
else if (y<1980) ruta = ruta_classic
|
|
else if (y<2000) ruta = ruta_retro
|
|
if (ruta==ruta2000) {
|
|
if (y>=2021) ruta = ruta_estrenos
|
|
else if (y>=2010) ruta += "2010-2020/"
|
|
else ruta += "2000-2010/"
|
|
}
|
|
/********************************************/
|
|
|
|
//----------------------------
|
|
//Relocation possible failures
|
|
if (relocation && {try {relocationFrom!=null} catch (err) {false}}()) {
|
|
if (!ruta.contains(relocationFrom)) {
|
|
ruta = root + relocationFrom + "to_observe/"
|
|
}
|
|
}
|
|
//----------------------------
|
|
|
|
/*** RESULTADO FINAL ***/
|
|
def inicial = (ruta==ruta_retro) ? getInicial() : ''
|
|
def tmdb = "{tmdb-"+tmdbid+"}"
|
|
def carpetaPeli = localize.Spanish.plex.name + ' ' + tmdb + '/'
|
|
|
|
def file
|
|
if ({try {only_relocate} catch (err) {false}}()) {
|
|
file = fn
|
|
} else {
|
|
def nombrePelicula_formatoPlex = {try { catalana ? localize.Catalan.n : localize.Spanish.plex.name } catch (err) {localize.Spanish.plex.name} }()
|
|
def nomPrincipal = nombrePelicula_formatoPlex + bloqueVideo + bloqueAudio + bloqueSubs
|
|
def trackerCatch = fn.find(/(?i)\bHDO(limpo)?\b|\bRedBits\b/)
|
|
def tracker = trackerCatch != null ? '['+trackerCatch.replace("HDOlimpo", "HDO")+']' : ''
|
|
|
|
file = nomPrincipal + tracker + tmdb
|
|
}
|
|
|
|
return ruta + inicial + carpetaPeli + file
|
|
/////////////////////////////////////////////////////////////////////////// |