1
0
Fork 0

intensive afternoon

This commit is contained in:
xeviff 2023-05-08 12:40:32 +02:00
parent a0f2540003
commit 68997fc469
4 changed files with 173 additions and 136 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
._.DS_Store
._MaNGranA_Pelis_Organizer.groovy
.DS_Store

View File

@ -1,7 +1,8 @@
//by @xeviff
/** RUTAS **/
def inicialsActivades=true
def root = '/pelis/'
def ubuntu_desktop=false
def root = ubuntu_desktop ? '/mnt/mangrana_pelis/' : '/pelis/'
def rutaOK = root+"Pelis/plain/"
def ruta = rutaOK
def ruta_docu = root+"Documentales/plain/"
@ -10,7 +11,6 @@ def ruta_animacion = root+"Pelis_animacion/"
def ruta_infantil = root+"Pelis_infantiles/"
def ruta_familiar = root+"Pelis_familiar/"
def ruta_esp = root+"Pelis_esp/plain/"
def ruta_semiesp = root+"Pelis_esp/posible_esp/"
def ruta_retro = root+"Pelis_retro/plain/"
def ruta_estrenos = root+"Pelis_estrenos/plain/"
def ruta_classic = root+"Pelis_classic/"
@ -19,25 +19,8 @@ def ruta_asiaticas = root+"Pelis_asiaticas/"
def rutaKO = root+"error/"
/**********/
/*TEST*/
/*def x = (certification =='PG.7' || certification =='G')
return certification + genres +x*/
//resultado = info.ProductionCountries
//return certification
//return genres+genres.contains('Animación')//+anime
//return genres.contains('Comedia')
//return genres.contains('Familia')
//return tieneGeneroFamilia(genres)
//return (genres[1]=~ /Animaci\p{L}n/).find()
//return tmdbid
//return localize.cat.n
//return primaryTitle+' cat: '+localize.cat.n+' esp:'+localize.Spanish.n
//return primaryTitle+' '+localize.Catalan.plex.name
/**/
/* HARDCODED */
def skipAudioCheck = true
def infantilHardCoded = false
/*************/
/* Excepciones */
@ -139,20 +122,26 @@ def esDocumental (generos, title) {
def noJackass = !(title =~ /Jackass/)
return (tieneGeneroDocumental(generos) || tieneGeneroReality(generos)) && noJackass
}
def fromEspPlatform () {
def platformES = false
try { platformES =
info.Network =~ /(?i)\bFLIXOL.\b|\b.?TVE\b/ } catch (ex) {}
def companyEs = false
try { companyEs =
info.ProductionCompanies =~ /.?TVE|ESDIP/ } catch (ex) {}
return platformES || companyEs
}
/**/
def getInicial () {
def nomIngles = localize.English.n
if (nomIngles.startsWith("The ") || nomIngles.startsWith("A "))
nomIngles = nomIngles.replaceFirst("The ",'').replaceFirst("A ",'')
def ini0 = nomIngles[0].toUpperCase()
def ini1 = nomIngles[1].toUpperCase()
def iniClear = ini0.replaceAll(/[¡¿'#*\(]/,ini1)
def iniClear = nomIngles.size()>1 ? ini0.replaceAll(/[¡¿'#*\(]/,nomIngles[1].toUpperCase()) : ini0
def inicial = iniClear.replaceAll(/[0-9]/,'#')+'/'
return inicial
}
def fromEspPlatform (plataforma) {
return plataforma =~ /(?i)\bFLIXOL.\b|\bRTVE\b/
}
try { //empieza el script
@ -408,86 +397,87 @@ try { //empieza el script
def generes
def errorNoGenero=false
try {generes=genres} catch (err) {errorNoGenero=true}
def numPaises = info.ProductionCountries.size()
def tieneAnimacion = tieneGeneroAnimacion(generes)
def tieneFamiliar = tieneGeneroFamilia(generes)
def esDocu = esDocumental(generes, localize.English.n)
def esAnime = anime || (tieneAnimacion && info.ProductionCountries.contains("JP"))
if (esAnime) {
def noAnimeListEx = [351460]
if (noAnimeListEx.contains(tmdbid)) esAnime=false
def esAnime = false
if (tieneAnimacion && info.ProductionCountries.contains("JP")) {
esAnime = numPaises==1 || anime
}
if (tieneAnimacion) {
def noAnimacionListEx = [554377, 708962, 35114]
if (noAnimacionListEx.contains(tmdbid)) tieneAnimacion=false
}
//*** española ***
def hispanico = info.ProductionCountries.contains("ES") && (numPaises==1 || (numPaises==2 && info.ProductionCountries.contains("PT")))
def espanyola = hispanico || fromEspPlatform() || (info.Certifications.size()==1 && info.Certifications.ES!=null)
//|| ({ try { languages.size()==1 && languages.get(0)=="esp" } catch (Exception e) { null } })()
//infantil
//***** familiar vs infantil ****
def esFamiliar = tieneFamiliar
def infantil = false
def tipoYaSeteado=esDocu || esAnime
if (!tipoYaSeteado) {
def tieneCertificacion = info.Certifications!=null && info.Certifications.size()!=0
if (tieneFamiliar && tieneAnimacion) {
infantil=true
} /*else {
def certificacio
try {certificacio=certification} catch (err) {
certificacio = info.certifications.ES
if (certificacio==null)
certificacio = info.certifications.DE
}
if (certificacio!=null) {
def familyCert = ['A', 'G', 'APTA', 'TP']
if (familyCert.contains(certificacio))
def noTanInfantil = info.Certifications.US ==~/PG-13/
if (!noTanInfantil)
infantil = true
}
def certsMap = info.certifications
if (certsMap.size()>0) {
def noNens=false
certsMap.each { key, val ->
def num = val.findAll( /\d+/ )*.toInteger()
if (num!=null && num[0]!=null) {
try{
if (num[0]<8 && num[0]>1) {
else if (tieneAnimacion) {
if (tieneCertificacion) {
if ( info.Certifications.US=="G"
|| info.Certifications.ES==~/Ai|APTA/
|| info.Certifications.DE==~/0|6/
|| info.Certifications.IT=="T"
|| info.Certifications.LT=="V" || info.Certifications.RU ==~ /6.+/
|| info.Certifications.BR=="L"
)
infantil=true
} else {
def titulosInfantiles = ['Bonnie bears', 'The Jungle Bunch']
if (titulosInfantiles.any { localize.English.n.toLowerCase()contains(it.toLowerCase()) })
infantil = true
} else if (num[0]>8) {
noNens=true
}
}catch (err) {}
} else if (!esFamiliar) {
if (tieneCertificacion && (
info.Certifications.US=="G"
)) {
esFamiliar = true //posem a familiar pelis de nens que no son animacio
}
}
if (infantil && noNens) infantil=false
}
}*/
//excepcions espanyoles
def semiEsp
def probablEsp = info.ProductionCountries.contains("ES")
def espanyola = fromEspPlatform(plataforma) || (probablEsp && info.ProductionCountries.size()==1)
if (probablEsp && info.ProductionCountries.size()>1) semiEsp = true
def espListEx = [401545, 584427, 589203, 655187, 441614, 517327, 516856, 351097, 267579, 573150, 437036, 56812, 11429, 127864, 510318, 209251, 443585, 33273, 8881, 351809, 499547, 351145, 684471]
def noEspListEx = [290859, 1562, 530915, 329718, 248842, 353979, 34186, 2395, 735129, 421792, 335984, 591789, 429, 26388, 18898, 266396, 85872, 352161, 43020, 339967, 446696, 38031]
if (noEspListEx.contains(tmdbid)) {
semiEsp=false
espanyola=false
} else if (espListEx.contains(tmdbid)) espanyola=true
//asiaticas
def asiatica = false
if (info.ProductionCountries.size()>0) {
tipoYaSeteado = tipoYaSeteado & (infantil || espanyola)
if (!tipoYaSeteado) {
//asiaticas
if (numPaises>0) {
def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO"]
def matchP = paisesAsiaticos.intersect(info.ProductionCountries)
if (matchP.size()==info.ProductionCountries.size()) asiatica=true
def allAsian = matchP.size()==numPaises
def probableAsian = matchP.size()>0 && englishAudios.isEmpty() && audio.size()>1
if (allAsian || probableAsian/*en obseracion*/) asiatica=true
}
}
//es animacion
def esAnimacion = tieneAnimacion && !esFamiliar && !espanyola && !asiatica
//tria
if (esDocu) ruta = ruta_docu
else if (esAnime) ruta = ruta_anime
else if (infantil) ruta = ruta_infantil
else if (tieneFamiliar) ruta = ruta_familiar
else if (tieneAnimacion) ruta = ruta_animacion
else if (asiatica) ruta = ruta_asiaticas
else if (esAnimacion) ruta = ruta_animacion
else if (espanyola) ruta = ruta_esp
else if (semiEsp) ruta = ruta_semiesp
else if (esFamiliar) ruta = ruta_familiar
else if (asiatica) ruta = ruta_asiaticas
else if (y<1980) ruta = ruta_classic
else if (y<2000) ruta = ruta_retro
if (ruta==rutaOK && y>=2021) ruta = ruta_estrenos
@ -501,7 +491,7 @@ try { //empieza el script
def inicial=''
def inicialsRequerides = ruta==rutaOK || ruta==ruta_retro
if (inicialsActivades && inicialsRequerides) {
if (inicialsRequerides) {
inicial = getInicial()
}
def tmdb = " {tmdb-"+tmdbid+"}"

View File

@ -1,7 +1,8 @@
//by @xeviff
/** RUTAS **/
def inicialsActivades=true
def root = '/pelis/'
def ubuntu_desktop=true
def root = ubuntu_desktop ? '/mnt/mangrana_pelis/' : '/pelis/'
def rutaOK = root+"Pelis/plain/"
def ruta = rutaOK
def ruta_docu = root+"Documentales/plain/"
@ -10,7 +11,6 @@ def ruta_animacion = root+"Pelis_animacion/"
def ruta_infantil = root+"Pelis_infantiles/"
def ruta_familiar = root+"Pelis_familiar/"
def ruta_esp = root+"Pelis_esp/plain/"
def ruta_semiesp = root+"Pelis_esp/posible_esp/"
def ruta_retro = root+"Pelis_retro/plain/"
def ruta_estrenos = root+"Pelis_estrenos/plain/"
def ruta_classic = root+"Pelis_classic/"
@ -54,7 +54,7 @@ def tieneGeneroReality (generos) {
}
def esDocumental (generos, title) {
def noJackass = !(title =~ /Jackass/)
return tieneGeneroDocumental(generos) && noJackass
return (tieneGeneroDocumental(generos) || tieneGeneroReality(generos)) && noJackass
}
def fromEspPlatform () {
return fn.find(/(?i)\bFLIXOL.\b|\bRTVE\b/) != null
@ -65,14 +65,26 @@ def getInicial () {
if (nomIngles.startsWith("The ") || nomIngles.startsWith("A "))
nomIngles = nomIngles.replaceFirst("The ",'').replaceFirst("A ",'')
def ini0 = nomIngles[0].toUpperCase()
def ini1 = nomIngles[1].toUpperCase()
def iniClear = ini0.replaceAll(/[¡¿'#*\(]/,ini1)
def iniClear = nomIngles.size()>1 ? ini0.replaceAll(/[¡¿'#*\(]/,nomIngles[1].toUpperCase()) : ini0
def inicial = iniClear.replaceAll(/[0-9]/,'#')+'/'
return inicial
}
def sanityCheck() {
def clearCurrentName = fn.replaceAll(/\s|-|:||\./,'')
def clearPlexName = plex.name.replaceAll(/\s|-|:||\./,'')
if (clearCurrentName.substring(0, clearCurrentName.size()-6)!=clearPlexName.substring(0, clearPlexName.size()-6))
return false
def yearOldName = clearCurrentName.substring(clearCurrentName.size()-5, clearCurrentName.size()-1) as int
def yearNewName = clearPlexName.substring(clearPlexName.size()-5, clearPlexName.size()-1) as int
return Math.abs(yearOldName - yearNewName) < 2
}
//*****************************************************************************************/
//*****************************************************************************************/
//*****************************************************************************************/
try { //empieza el script
//sanity check
if (!sanityCheck()) return '@@@@@@ Names Sanity Check KO @@@@@@@ --> New name: '+plex.name
try {
video
@ -93,7 +105,7 @@ try { //empieza el script
def idioma
try {
idioma = item.Language_String
if (idioma==null) throw new Exception("[idioma_audio_no_definido0]")
if (idioma==null) otherAudios.add("audio_no_def")
if ("Catalan"==idioma) catalanAudios.add(item)
else if (idioma=~/(?i)(Spanish|Espa.ol)/) spanishAudios.add(item)
else if ("English"==idioma) englishAudios.add(item)
@ -127,11 +139,11 @@ try { //empieza el script
} else if (!spanishAudios.isEmpty()) { //tenemos español
} else if (!englishAudios.isEmpty()) {
throw new Exception("[idioma_audio_solo_ingles]")
if (!skipAudioCheck) throw new Exception("[idioma_audio_solo_ingles]")
} else if (!otherAudios.isEmpty()) {
throw new Exception("[idioma_audio_marginal]")
if (!skipAudioCheck) throw new Exception("[idioma_audio_marginal]")
} else {
throw new Exception("[idioma_audio_no_encontrado]")
if (!skipAudioCheck) throw new Exception("[idioma_audio_no_encontrado]")
}
/***********/
@ -146,63 +158,90 @@ try { //empieza el script
def tieneFamiliar = tieneGeneroFamilia(generes)
def esDocu = esDocumental(generes, localize.English.n)
def esAnime = anime || (tieneAnimacion && info.ProductionCountries.contains("JP"))
if (esAnime) {
def noAnimeListEx = [351460]
if (noAnimeListEx.contains(tmdbid)) esAnime=false
def esAnime = false
if (tieneAnimacion && info.ProductionCountries.contains("JP")) {
esAnime = info.ProductionCountries.size()==1 || anime
}
if (tieneAnimacion) {
def noAnimacionListEx = [554377, 708962, 35114]
if (noAnimacionListEx.contains(tmdbid)) tieneAnimacion=false
//***** familiar vs infantil ****
def esFamiliar = tieneFamiliar
def infantil = false
def tipoYaSeteado=esDocu || esAnime
if (!tipoYaSeteado) {
def tieneCertificacion = info.Certifications!=null && info.Certifications.size()!=0
if (tieneFamiliar && tieneAnimacion) {
def noTanInfantil = info.Certifications.US ==~/PG-13/
if (!noTanInfantil)
infantil = true
}
else if (tieneAnimacion) {
if (tieneCertificacion) {
if ( info.Certifications.US=="G"
|| info.Certifications.ES==~/Ai|APTA/
|| info.Certifications.DE==~/0|6/
|| info.Certifications.IT=="T"
|| info.Certifications.LT=="V" || info.Certifications.RU ==~ /6.+/
|| info.Certifications.BR=="L"
)
infantil=true
} else {
def titulosInfantiles = ['Bonnie bears', 'The Jungle Bunch']
if (titulosInfantiles.any { localize.English.n.toLowerCase()contains(it.toLowerCase()) })
infantil = true
}
} else if (!esFamiliar) {
if (tieneCertificacion && (
info.Certifications.US=="G"
)) {
esFamiliar = true //posem a familiar pelis de nens que no son animacio
}
}
}
//infantil
def infantil= tieneFamiliar && tieneAnimacion
//excepcions espanyoles
def semiEsp
def probablEsp = info.ProductionCountries.contains("ES")
def espanyola = fromEspPlatform() || (probablEsp && info.ProductionCountries.size()==1)
if (probablEsp && info.ProductionCountries.size()>1) semiEsp = true
def espListEx = [401545, 584427, 589203, 655187, 441614, 517327, 516856, 351097, 267579, 573150, 437036, 56812, 11429, 127864, 510318, 209251, 443585, 33273, 8881, 351809, 499547, 351145, 684471]
def noEspListEx = [290859, 1562, 530915, 329718, 248842, 353979, 34186, 2395, 735129, 421792, 335984, 591789, 429, 26388, 18898, 266396, 85872, 352161, 43020, 339967, 446696, 38031]
if (noEspListEx.contains(tmdbid)) {
semiEsp=false
espanyola=false
} else if (espListEx.contains(tmdbid)) espanyola=true
//asiaticas
//espanyoles & asiaticas
def espanyola = false
def asiatica = false
if (info.ProductionCountries.size()>0) {
tipoYaSeteado=esDocu || esAnime || esFamiliar || infantil
if (!tipoYaSeteado) {
def segurEsp = info.ProductionCountries.contains("ES") && info.ProductionCountries.size()==1
espanyola = fromEspPlatform() || segurEsp
//asiaticas
if (!espanyola && info.ProductionCountries.size()>0) {
def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO"]
def matchP = paisesAsiaticos.intersect(info.ProductionCountries)
if (matchP.size()==info.ProductionCountries.size()) asiatica=true
def allAsian = matchP.size()==info.ProductionCountries.size()
def probableAsian = matchP.size()>0 && englishAudios.isEmpty() && audio.size()>1
if (allAsian || probableAsian/*en obseracion*/) asiatica=true
}
}
//tria
if (esDocu) ruta = ruta_docu
else if (esAnime) ruta = ruta_anime
else if (infantil) ruta = ruta_infantil
else if (tieneFamiliar) ruta = ruta_familiar
else if (esFamiliar) ruta = ruta_familiar
else if (tieneAnimacion) ruta = ruta_animacion
else if (asiatica) ruta = ruta_asiaticas
else if (espanyola) ruta = ruta_esp
else if (semiEsp) ruta = ruta_semiesp
else if (y<1980) ruta = ruta_classic
else if (y<2000) ruta = ruta_retro
if (ruta==rutaOK && y>=2021) ruta = ruta_estrenos
/********************************************/
/**************************************/
if (errorNoGenero && ruta!=ruta_classic && ruta!=ruta_retro && !espanyola && !semiEsp && !infantil && ruta!=ruta_esp_retro && ruta!=ruta_esp_classic && ruta!=ruta_estrenos )
throw new Exception("[genero_no_especificado]")
//if (errorNoGenero && ruta!=ruta_classic && ruta!=ruta_retro && !espanyola && !semiEsp && !infantil && ruta!=ruta_esp_retro && ruta!=ruta_esp_classic && ruta!=ruta_estrenos )
// throw new Exception("[genero_no_especificado]")
/*** RESULTADO FINAL ***/
def inicial=''
def inicialsRequerides = ruta==rutaOK || ruta==ruta_retro
if (inicialsActivades && inicialsRequerides) {
if (inicialsRequerides) {
inicial = getInicial()
}
def tracker = fn.find(/(?i)\bHDO(limpo)?\b/)

View File

@ -51,6 +51,9 @@ def tieneGeneroReality (generos) {
}
return false
}
def normalitzarText(txt) {
return txt.replaceAll(':','.').replaceAll('\\?','¿').replaceAll('\\"','-')
}
/**/
@ -77,8 +80,9 @@ try { //empieza el script
def esReality = tieneGeneroReality(generes)
//esp?
def esEsp=false
def spanishNetwork = info.Network.find(/(?i)\bTVE\b|\bmovistar\b|\bAtresmedia\b|\bcanal 9\b|\bPlayz\b|\bATRES\b|\bETB1\b|\bTV3\b|\btelecinco\b|\bcanal+\b|\bgalicia\b|\bfox españa\b|\blasexta\b|\bantena 3\b/ )
if (spanishNetwork!=null) esEsp=true
def spanishNetwork
try{ spanishNetwork = info.Network.find(/(?i)\bTVE\b|\bmovistar\b|\bAtresmedia\b|\bcanal 9\b|\bPlayz\b|\bATRES\b|\bETB1\b|\bTV3\b|\btelecinco\b|\bcanal+\b|\bgalicia\b|\bfox españa\b|\blasexta\b|\bantena 3\b/ )} catch(e){}
if (spanishNetwork!=null || Country=='esp') esEsp=true
//tria
/*if (tenimCat) ruta = ruta_cat
else */if (esDocu) ruta = ruta_docu
@ -94,8 +98,8 @@ try { //empieza el script
/****************************/
/**** Nombre de fichero *******/
def nombreSerie = '/' + localize.English.ny + '/'
def cuaTvdb = " {tvdb-"+id+"}"
def nombreSerie = '/' + normalitzarText(localize.English.ny) + cuaTvdb + '/'
def temporada = episode.special ?
'Specials'+'/' :
'Temporada '+ s.pad(2) + '/'
@ -109,11 +113,11 @@ try { //empieza el script
} catch (err) {
/*
String str= err.getStackTrace().toString()
def pattern = ( str =~ /groovy.(\d+)./ )
return " Error at line number = " + pattern[0][1]
*/
def rutaMotivoErr
def msgErr = err.getMessage()