1
0
Fork 0

I'm starting refactor to include series

This commit is contained in:
xeviff 2023-05-24 14:12:15 +02:00
parent ad567c9785
commit 5670e73e68
19 changed files with 323 additions and 102 deletions

View File

@ -1,8 +1,10 @@
{ {
def only_relocate=true def only_relocate=true
@split/init_relocate.groovy //def relocationFrom="Pelis_familiar/"
@split/root_folders.groovy @movies/init_relocate.groovy
@split/folder_file.groovy @common/classification.groovy
@split/catch.groovy @movies/root_folders.groovy
@split/functions.groovy @movies/folder_file.groovy
@movies/catch.groovy
@movies/functions.groovy
} }

View File

@ -1,12 +1,13 @@
{ {
def relocationFrom="Pelis/" def relocationFrom="Pelis_estrenos/"
@split/init_relocate.groovy @movies/init_relocate.groovy
@split/root_folders.groovy @movies/root_folders.groovy
@split/validations.groovy @movies/validations.groovy
@split/video.groovy @movies/video.groovy
@split/audio.groovy @movies/audio.groovy
@split/subs.groovy @movies/subs.groovy
@split/folder_file.groovy @common/classification.groovy
@split/catch.groovy @movies/folder_file.groovy
@split/functions.groovy @movies/catch.groovy
@movies/functions.groovy
} }

View File

@ -1,11 +1,12 @@
{ {
@split/init_newMovies.groovy @movies/init_newMovies.groovy
@split/root_folders.groovy @movies/root_folders.groovy
@split/validations.groovy @movies/validations.groovy
@split/video.groovy @movies/video.groovy
@split/audio.groovy @movies/audio.groovy
@split/subs.groovy @movies/subs.groovy
@split/folder_file.groovy @common/classification.groovy
@split/catch.groovy @movies/folder_file.groovy
@split/functions.groovy @movies/catch.groovy
@movies/functions.groovy
} }

11
Series_Rename.groovy Executable file
View File

@ -0,0 +1,11 @@
{
def relocation=false
@series/root_folders.groovy
@split/validations.groovy
@split/video.groovy
@split/audio.groovy
@split/subs.groovy
@split/folder_file.groovy
@split/catch.groovy
@split/functions.groovy
}

View File

@ -10,9 +10,11 @@ def pais = {try{country} catch (err) {null}}()
def numPaises = prodCountries.size() def numPaises = prodCountries.size()
def llengu = {try {def langs=[]; for (lan in languages) langs.add(lan.toString()); return langs } catch(err) {[]}}() 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) {[]}}() def audioLlengu = {try {def langs=[]; for (lan in audioLanguages) langs.add(lan.toString()); return langs } catch(err) {[]}}()
def soloLangIngles = llengu.size()==1 && llengu[0]=="eng"
//animacion (no concluyente) //animacion (no concluyente)
def tieneAnimacion = genres.any{ it =~ /Anima.i.n/} def fakeAnimacionList = ["blue & malone", "cool world"]
def tieneAnimacion = genres.any{ it =~ /Anima.i.n/} && !fakeAnimacionList.any{localize.English.n.toLowerCase().contains(it)}
//familiar (no conclud) //familiar (no conclud)
def tieneFamiliar = genres.any{ it =~ /Familia|Family/} def tieneFamiliar = genres.any{ it =~ /Familia|Family/}
//docu //docu
@ -31,14 +33,16 @@ def infantil = false
if (!tipoYaSeteado) { if (!tipoYaSeteado) {
def tieneCertificacion = certifications!=null && certifications.size()!=0 def tieneCertificacion = certifications!=null && certifications.size()!=0
def detectadoNoInfantil = tieneCertificacion && (
(certifications.US!=null && certifications.US==~/PG-13|R/)
|| (certifications.ES!=null && certifications.ES==~/16|18/))
if (tieneFamiliar && tieneAnimacion) { if (detectadoNoInfantil) infantil=false
def noTanInfantil = certifications.US ==~/PG-13/ && certifications.ES!="7" else if (tieneFamiliar && tieneAnimacion) infantil=true
if (!noTanInfantil) infantil = true
}
else if (tieneAnimacion) { else if (tieneAnimacion) {
if (tieneCertificacion) { if (tieneCertificacion) {
infantil = certifications.US=="G" infantil = (certifications.US!=null ? certifications.US!="R" : true) &&
(certifications.US=="G"
|| certifications.ES==~/Ai|APTA/ || certifications.ES==~/Ai|APTA/
|| certifications.DE==~/0/ || certifications.DE==~/0/
|| certifications.IT=="T" || certifications.IT=="T"
@ -46,7 +50,7 @@ if (!tipoYaSeteado) {
|| certifications.LT=="V" || certifications.RU ==~ /6.+/ || certifications.LT=="V" || certifications.RU ==~ /6.+/
|| certifications.BR=="L" || certifications.BR=="L"
|| certifications.NO=="A" || certifications.NO=="A"
|| certifications.FR=="U" || certifications.FR=="U")
} else { } else {
def titulosInfantiles = ['boonie bears', 'the jungle bunch'] def titulosInfantiles = ['boonie bears', 'the jungle bunch']
if (titulosInfantiles.any { localize.English.n.toLowerCase().contains(it) }) if (titulosInfantiles.any { localize.English.n.toLowerCase().contains(it) })
@ -69,24 +73,24 @@ tipoYaSeteado = tipoYaSeteado || esAnimacion
//*** española / catalana *** //*** española / catalana ***
def catalana = false def catalana = false
def espanyola = false def espanyola = false
if (!tipoYaSeteado && prodCountries.contains("ES")) { if (!tipoYaSeteado && (numPaises>0 ? prodCountries.contains("ES") : true)) {
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') catalana = llengu.contains('cat')
if (!catalana) {
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") || (llengu.size()==2 && llengu.contains("spa")))
|| (movie.alternativeTitles.size()==1 && movie.alternativeTitles.ES!=null)
|| (pais=="ES" && (!llengu.isEmpty() ? llengu.size()==1 && llengu[0]=="spa" : true))
}
tipoYaSeteado = tipoYaSeteado || espanyola || catalana tipoYaSeteado = tipoYaSeteado || espanyola || catalana
} }
//asiaticas //asiaticas
def asiatica = false def asiatica = false
if (!tipoYaSeteado) { if (!tipoYaSeteado && !soloLangIngles) {
def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO", "SU"] def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO", "SU"]
def paisesIntersec=0 def paisesIntersec=0
def languajAsia = ["zho", "kor", "thai", "vie", "jpn", "ind", "rus"] def languajAsia = ["zho", "kor", "thai", "vie", "jpn", "ind", "rus"]
@ -104,58 +108,9 @@ if (!tipoYaSeteado) {
//*** latina *** //*** latina ***
def latina = false def latina = false
if (!tipoYaSeteado) { if (!tipoYaSeteado && !soloLangIngles) {
def paisesLatinos = ["MX", "AR"] def paisesLatinos = ["MX", "AR"]
latina = {try {paisesLatinos.contains(pais)} catch (e) {false}}() latina = {try {paisesLatinos.contains(pais)} catch (e) {false}}()
|| (numPaises != 0 && paisesLatinos.intersect(prodCountries).size() == numPaises) || (numPaises != 0 && paisesLatinos.intersect(prodCountries).size() == numPaises)
|| prodCountries.any{it=~/Corazón Films/} || info.ProductionCompanies.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
///////////////////////////////////////////////////////////////////////////

View File

@ -34,7 +34,7 @@
} }
} }
def resultado = rutaKO + rutaMotivoErr + msgErr + '/' + localize.English.plex.name + '/' + fn def resultado = rutaKO + rutaMotivoErr + msgErr + '/' + localize.Spanish.plex.name + '/' + fn
return resultado return resultado
} }

58
movies/folder_file.groovy Executable file
View File

@ -0,0 +1,58 @@
//////////////////////////////////////////////
//tria
if (esDocu) ruta = ruta_docu + "main/"
else if (esAnime) ruta = ruta_anime + "main/"
else if (infantil) ruta = ruta_infantil + "main/"
else if (esAnimacion) ruta = ruta_animacion + "main/"
else if (catalana) ruta = ruta_cat + "main/"
else if (espanyola) {
ruta = ruta_esp
if (y>2000) ruta += "sXXI/"
else ruta += "sXX/"
} else if (latina) ruta = ruta_latina + "main/"
else if (asiatica) ruta = ruta_asiaticas + "main/"
else if (esFamiliar && y>1970) ruta = ruta_familiar + "main/"
else if (y<1980) {
ruta = ruta_classic
if (y>1970) ruta += "70s/"
else ruta += "old/"
} else if (y<2000) {
ruta = ruta_retro
if (y>=1990) ruta += "90s/"
else ruta += "80s/"
}
if (ruta==ruta2000) {
if (y>=2021) ruta = ruta_estrenos + "20s/"
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
///////////////////////////////////////////////////////////////////////////

View File

@ -33,7 +33,7 @@ def printAudio (audio2Print) {
} }
case "MLP FBA" -> {def tmp = "D_HD"; if (fCom.contains("Atmos")) tmp+="_Atmos"; fCom = tmp} case "MLP FBA" -> {def tmp = "D_HD"; if (fCom.contains("Atmos")) tmp+="_Atmos"; fCom = tmp}
} }
def canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 7:'6.1', 8:'7.1') def canales = audio2Print.Channels.replace(2:'2.0', 3:'2.1', 6:'5.1', 7:'6.1', 8:'7.1')
return fCom + ' ' + canales return fCom + ' ' + canales
} }
def getBestChannelFromList (audiosFormatFound) { def getBestChannelFromList (audiosFormatFound) {

View File

@ -2,16 +2,16 @@
def root = '/pelis/' def root = '/pelis/'
def ruta2000 = root+"Pelis/" def ruta2000 = root+"Pelis/"
def ruta = ruta2000 def ruta = ruta2000
def ruta_docu = root+"Documentales/plain/" def ruta_docu = root+"Documentales/"
def ruta_anime = root+"Pelis_anime/" def ruta_anime = root+"Pelis_anime/"
def ruta_animacion = root+"Pelis_animacion/" def ruta_animacion = root+"Pelis_animacion/"
def ruta_infantil = root+"Pelis_infantiles/" def ruta_infantil = root+"Pelis_infantiles/"
def ruta_familiar = root+"Pelis_familiar/" def ruta_familiar = root+"Pelis_familiar/"
def ruta_esp = root+"Pelis_esp/plain/" def ruta_esp = root+"Pelis_esp/"
def ruta_latina = root+"Pelis_lat/" def ruta_latina = root+"Pelis_lat/"
def ruta_cat = root+"Pelis_cat/" def ruta_cat = root+"Pelis_cat/"
def ruta_retro = root+"Pelis_retro/plain/" def ruta_retro = root+"Pelis_retro/"
def ruta_estrenos = root+"Pelis_estrenos/plain/" def ruta_estrenos = root+"Pelis_estrenos/"
def ruta_classic = root+"Pelis_classic/" def ruta_classic = root+"Pelis_classic/"
def ruta_asiaticas = root+"Pelis_asiaticas/" def ruta_asiaticas = root+"Pelis_asiaticas/"
def rutaKO = root+"error/" def rutaKO = root+"error/"

View File

@ -23,10 +23,10 @@ def peso = bytes.toString().before(' ').toDouble()
def numericBps = (mbps.toString().before(' ').toDouble()*1000000).round() def numericBps = (mbps.toString().before(' ').toDouble()*1000000).round()
def es1080 = vf ==~ '1080.' def es1080 = vf ==~ '1080.'
def es1080Remux = peso > 15 && numericBps >= 18000000 def es1080Remux = peso > 15 && numericBps >= 18000000
if (vf ==~ '2160.' || (es1080 && es1080Remux)) return "/pelis/to_transcode/"+fn if (vf ==~ '2160.' || (es1080 && es1080Remux)) return root+"to_transcode/" + localize.Spanish.plex.name + '/' + fn
/* SANITY CHECK */ /* SANITY CHECK */
if (relocation && !sanityCheck(tmdbid)) if (relocation && !sanityCheck(tmdbid))
return root + relocationFrom + "to_check_name/" return root + relocationFrom + "to_check_name/" + localize.Spanish.plex.name + '/' + fn
//return '@@@@@@ Names Sanity Check KO @@@@@@@ --> New name: '+localize.Spanish.n+' with tmdb='+tmdbid //return '@@@@@@ Names Sanity Check KO @@@@@@@ --> New name: '+localize.Spanish.n+' with tmdb='+tmdbid
/********************************/ /********************************/

153
old/Mangrana_Series.groovy Executable file
View File

@ -0,0 +1,153 @@
def server=true
def root = '/series/'
def rutaSeries = root+'NSeries/'
def ruta_docu = root+'Series_docu/'
def ruta_animacion = root+'Series_animacion/'
def ruta_anime = root+'Series_anime/'
def ruta_antiguas = root+'Series_antiguas/'
def ruta_esp = root+'Series_esp'
def ruta_teen = root+'Series_familiar'
def ruta_infantil = root+'Series_infantil'
def ruta_programastv = root+'programas_tv'
def rutaKO = root+'error/'
def ruta = rutaSeries
/* otras funciones */
def tieneGeneroAnimacion (generos) {
for (genero in generos) {
if (genero =~ /Anima[c|t]i\p{L}n/)
return true
}
return false
}
def tieneGeneroAnime (generos) {
for (genero in generos) {
if (genero =~ /Anime/)
return true
}
return false
}
def tieneGeneroFamilia (generos) {
for (genero in generos) {
if (genero =~ /Familia|Family/)
return true
}
return false
}
def tieneGeneroDocumental (generos) {
for (genero in generos) {
if (genero =~ /Documental|Documentary/)
return true
}
return false
}
def tieneGeneroReality (generos) {
for (genero in generos) {
if (genero =~ /Reality/)
return true
}
return false
}
def normalitzarText(txt) {
return txt.replaceAll(':','.').replaceAll('\\?','¿').replaceAll('\\"','-')
}
/**/
try { //empieza el script
try{
media
} catch (err) {throw new Exception("[no_media]")}
/**************************************/
/**** Carpeta / tipo contenido *******/
def generes
def errorNoGenero=false
try {generes=genres} catch (err) {errorNoGenero=true}
def certificacio
try {certificacio=certification} catch (err) {}
def esDocu = tieneGeneroDocumental(generes)
def esAnime = anime || tieneGeneroAnime(generes)
def esAnimacion = tieneGeneroAnimacion(generes)
def esTeen = tieneGeneroFamilia(generes) && (certificacio==null || certificacio =~ /TV-14|TV-P?G/)
//return certificacio + " - " + generes + " - so: " + esTeen
def esInfantil = esAnimacion && certificacio =~ /TV-Y|TV-Y7|TV-P?G/
def esReality = tieneGeneroReality(generes)
//esp?
def esEsp=false
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
else if (esReality) ruta = ruta_programastv
else if (esAnime) ruta = ruta_anime
else if (esInfantil) ruta = ruta_infantil
else if (esAnimacion) ruta = ruta_animacion
else if (esEsp) ruta = ruta_esp
else if (y < 1990) ruta = ruta_antiguas
else if (esTeen) ruta = ruta_teen
/****************************************/
/****************************************/
/****************************/
/**** Nombre de fichero *******/
def cuaTvdb = " {tvdb-"+id+"}"
def nombreSerie = '/' + normalitzarText(localize.English.ny) + cuaTvdb + '/'
def temporada = episode.special ?
'Specials'+'/' :
'Temporada '+ s.pad(2) + '/'
/****************************/
/**** RUTA FINAL *******/
def resultado = ruta + nombreSerie + temporada + fn
return resultado
} 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()
if (msgErr=="[formato_fichero_noestarndar]" || msgErr=="[video_roto]" || msgErr=="[no_media]")
rutaMotivoErr="/fichero/"
else if (msgErr=="[genero_no_especificado]" || msgErr=="[certificado_edad_no_especificado]") {
rutaMotivoErr="/themoviedb/"
} else if (msgErr.startsWith("[idioma_audio")) {
rutaMotivoErr="/audio/"
} else if (msgErr.startsWith("[bitrate_demasiado_alto]")) {
rutaMotivoErr="/bitrate/"
} else {
def errSplitted = msgErr.split("\\-")
if (errSplitted==null) {
rutaMotivoErr="/error_desconocido/"
} else {
return msgErr
def errType = errSplitted[0]
if (errType=="[formato_audio_no_encontrado")
rutaMotivoErr="/audio/"
else if (errType.startsWith("[idioma_audio"))
rutaMotivoErr="/idioma/"
else {
rutaMotivoErr="/error_desconocido/"
msgErr = "[error_inesperado]"
}
}
}
def resultado = rutaKO + rutaMotivoErr + msgErr + '/' + fn
return resultado
}

13
series/root_folders.groovy Executable file
View File

@ -0,0 +1,13 @@
def root = '/series/'
def rutaSeries = root+'NSeries/'
def ruta_docu = root+'Series_docu/'
def ruta_animacion = root+'Series_animacion/'
def ruta_anime = root+'Series_anime/'
def ruta_antiguas = root+'Series_antiguas/'
def ruta_esp = root+'Series_esp'
def ruta_teen = root+'Series_familiar'
def ruta_infantil = root+'Series_infantil'
def ruta_programastv = root+'programas_tv'
def rutaKO = root+'error/'
def ruta = rutaSeries

27
test/spanish.groovy Executable file
View File

@ -0,0 +1,27 @@
def prodCountries=info.ProductionCountries
def numPaises = prodCountries.size()
def llengu = {try {def langs=[]; for (lan in languages) langs.add(lan.toString()); return langs } catch(err) {[]}}()
def certifications=info.Certifications
def pais = {try{country} catch (err) {null}}()
def catalana = false
def espanyola = false
if (numPaises>0 ? prodCountries.contains("ES") : true) {
catalana = llengu.contains('cat')
if (!catalana) {
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))
}
}
res =espanyola
return res