From 9d60356ee5914e619a06e09a89c8d582d9abff8d Mon Sep 17 00:00:00 2001 From: xeviff <73612508+xeviff@users.noreply.github.com> Date: Tue, 9 May 2023 11:31:04 +0200 Subject: [PATCH] bona repassada --- .gitignore | 0 MaNGranA_Pelis.groovy | 387 +++++++++++++------------------- MaNGranA_Pelis_Organizer.groovy | 101 ++++----- 3 files changed, 199 insertions(+), 289 deletions(-) mode change 100644 => 100755 .gitignore diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/MaNGranA_Pelis.groovy b/MaNGranA_Pelis.groovy index d3cc3f5..29ce680 100755 --- a/MaNGranA_Pelis.groovy +++ b/MaNGranA_Pelis.groovy @@ -23,10 +23,6 @@ def rutaKO = root+"error/" def skipAudioCheck = true /*************/ -/* Excepciones */ - -/***************/ - /** Audio (definición) **/ def hayEAC3=false @@ -90,48 +86,6 @@ def printAudio (audio2Print) { } /***********/ /* otras funciones */ -def tieneGeneroAnimacion (generos) { - for (genero in generos) { - if (genero =~ /Anima[c|t]i\p{L}n/) - 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 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 ")) @@ -141,19 +95,13 @@ def getInicial () { def inicial = iniClear.replaceAll(/[0-9]/,'#')+'/' return inicial } - +/***********/ try { //empieza el script /** Tipo de archivo incorrecto **/ - def esFicheroMetadatos = false - def tipoMetadato - def nombreWbloqueMediainfo - if (ext=="jpg" || ext=="nfo" || ext=="png") { - esFicheroMetadatos = true - tipoMetadato = fn.find( //coge el contenido que encaja - /(?=\-[^-]+$)(.*)(? '' + /** Formato distribución **/ + formato_distribucion = + fn=~/(?i)\bblu.?ray\b/ ? 'BDRip' : + fn=~/(?i)\bdrip\b/ ? 'BDRip' : + fn=~/(?i)\bDVD.?RIP\b/ ? 'DVDRip' : + fn=~/(?i)\bHDiTunes\b/ ? 'HDiTunes' : + fn=~/(?i)\bTV.?RIP\b/ ? 'TVRip' : + fn=~/(?i)\bWEB.?Screener\b/ ? 'WEB-SRC' : + 'no_encontrado' + def plataforma + def esWEB_DL=false + if (formato_distribucion=='no_encontrado') { + esWEB_DL = fn=~/(?i)\bWEB.??(DL|RIP)\b/ //WEB-DL o WEB-RIP (todo junto o con punto/guión/etc) + + if (esWEB_DL) { + def web_x = fn=~/(?i)\bWEB.?DL\b/ ? 'WEB-DL' : 'WEB-RIP' //guardar el que es + plataforma = fn.find( //coge el contenido que encaja + /(?i)\bAMZN?\b|\bNF\b|\bHBO\b|\bHBO.?MAX\b|\bHMAX\b|\bHULU\b|\bA3P\b|\bDPLY\b|\bSTARZ\b|\bFILMIN\b|\bFLMN\b|\bNETFLIX\b|\bDSN.?\b|\bDSP+?\b|\bRTVE\b|\bFLIXOL.\b|\bM\+\b/ ) + if (plataforma!=null) plataforma = plataforma.replace("MVPLUS","MV+") + formato_distribucion = web_x+(plataforma!=null?(' '+plataforma.toUpperCase()):'') //web-dl/rip + plataforma(si hay) } else { - if (calidad=~/(?i)\remux\b/) { - formato_distribucion = - calidad=="4K-UHDRemux" ? "UHDRemux" : - calidad=="1080-BDRemux" ? "BDRemux" : - '' //no_encontrado -> '' - } - - } - if (formato_distribucion!='') formato_distribucion=' '+formato_distribucion - /**********************************/ - - /**** Nombre pelicula ****/ - def nombrePelicula_formatoPlex - def tieneQueUsarSpa=true - if (tenimCat) { - try { - if (primaryTitle!=localize.Catalan.n) { - tieneQueUsarSpa = false - nombrePelicula_formatoPlex = localize.Catalan.plex.name - } - } catch (err) { - tieneQueUsarSpa=true + if (hayEAC3) //por el audio también se determina que es web-dl + formato_distribucion = 'WEB-DL' + else { + def otrosFD = fn.find( /(?i)\bMTL\b |\bMUBI\b/ ) + if (otrosFD!= null && !otrosFD.isEmpty()) + formato_distribucion = otrosFD.toUpperCase() //si son estos, se setea } } - if (tieneQueUsarSpa) - nombrePelicula_formatoPlex = localize.Spanish.plex.name - /*************************/ + } + /**********/ - /**** HDR ********/ - def hdr_info='' - try{ - def mHDRCol = ["BT.709" : "NO", "BT.2020" : "YES"] - def hdr_info_old = (bitdepth >= 10 && mHDRCol.get(self.video[0].colourprimaries) == "YES" ) ? ' HDR' : '' + /** Formato distribución 2ª ronda**/ + //formato_distribucion = formato_distribucion=='no_encontrado'? '' : ' '+formato_distribucion + if (formato_distribucion=='no_encontrado') { + formato_distribucion = + calidad=="4K-UHDRemux" ? "UHDRemux" : + calidad=="4K-UHDRip" ? "UHDRip" : + calidad=="4K-MicroUHD" ? "UHDRip" : + calidad=="1080-BDRemux" ? "BDRemux" : + calidad=="1080-HD" ? "DBRip" : + calidad=="1080-MicroHD" ? "BDRip" : + '' //no_encontrado -> '' + } else { + if (calidad=~/(?i)\remux\b/) { + formato_distribucion = + calidad=="4K-UHDRemux" ? "UHDRemux" : + calidad=="1080-BDRemux" ? "BDRemux" : + '' //no_encontrado -> '' + } - def _HDRMap = [ - "HDR10": "HDR10", - "SMPTE ST 2086": "HDR10", - "SMPTE ST 2094 App 4": "HDR10+", - "Dolby Vision / SMPTE ST 2086": "Dolby Vision", - "Dolby Vision / HDR10": "Dolby Vision", - ] - def vid = video.first() - String _HDR - switch (bitdepth) { - case { it > 8 }: - _HDR = any - { vid["HDR_Format_Commercial"] } - { vid["HDR_Format"] } - { hdr } - { null } - break - default: - "$bitdepth-bit" + } + if (formato_distribucion!='') formato_distribucion=' '+formato_distribucion + /**********************************/ + + /**** HDR ********/ + def hdr_info='' + try{ + def mHDRCol = ["BT.709" : "NO", "BT.2020" : "YES"] + def hdr_info_old = (bitdepth >= 10 && mHDRCol.get(self.video[0].colourprimaries) == "YES" ) ? ' HDR' : '' + + def _HDRMap = [ + "HDR10": "HDR10", + "SMPTE ST 2086": "HDR10", + "SMPTE ST 2094 App 4": "HDR10+", + "Dolby Vision / SMPTE ST 2086": "Dolby Vision", + "Dolby Vision / HDR10": "Dolby Vision", + ] + def vid = video.first() + String _HDR + switch (bitdepth) { + case { it > 8 }: + _HDR = any + { vid["HDR_Format_Commercial"] } + { vid["HDR_Format"] } + { hdr } + { null } break - } - def hdr_info_ = _HDRMap.find { k, v -> - k =~ _HDR - }?.value - - if (hdr_info_!=null) hdr_info=' '+hdr_info_ - } catch (err) {} - /*****************/ + default: + "$bitdepth-bit" + break + } + def hdr_info_ = _HDRMap.find { k, v -> + k =~ _HDR + }?.value + + if (hdr_info_!=null) hdr_info=' '+hdr_info_ + } catch (err) {} + /*****************/ - /**** Profundidad de color */ - def profundidadColor='' - try{profundidadColor = bitdepth+"bits" } catch(err){} - /**************************/ + /**** Profundidad de color */ + def profundidadColor='' + try{profundidadColor = bitdepth+"bits" } catch(err){} + /**************************/ - /**** Profundidad vídeo ****/ - def myBitrate = 'noBRdef' - try{ myBitrate = mbps.replace(/.0/,'').replace(' ','') }catch(err){} - def myFps = ' FRvar' - try { myFps = ' '+fps.replace(/.0/,'').replace(' ','') }catch(err){} - /***************************/ + /**** Profundidad vídeo ****/ + def myBitrate = 'noBRdef' + try{ myBitrate = mbps.replace(/.0/,'').replace(' ','') }catch(err){} + def myFps = ' FRvar' + try { myFps = ' '+fps.replace(/.0/,'').replace(' ','') }catch(err){} + /***************************/ + + /* RESULTADO MEDIAINFO */ + def bloqueCalidadVideo = calidadF+formato_distribucion+hdr_info + def bloqueProfundidad = myBitrate+myFps + if (bloqueProfundidad!='' && profundidadColor!='') bloqueProfundidad=' '+bloqueProfundidad + + def bloqueMediainfo = ' ['+codecVideo+' '+bloqueCalidadVideo+']['+profundidadColor+bloqueProfundidad+']'+' ['+bloqueAudio+']' - /* RESULTADO MEDIAINFO */ - def bloqueCalidadVideo = calidadF+formato_distribucion+hdr_info - def bloqueProfundidad = myBitrate+myFps - if (bloqueProfundidad!='' && profundidadColor!='') bloqueProfundidad=' '+bloqueProfundidad - nombreWbloqueMediainfo = nombrePelicula_formatoPlex +' ['+codecVideo+' '+bloqueCalidadVideo+']['+profundidadColor+bloqueProfundidad+']'+' ['+bloqueAudio+']' - //+' {imdb-'+imdbid+'}' - //} /**************************************/ /**** Carpeta / tipo contenido *******/ - def generes - def errorNoGenero=false - try {generes=genres} catch (err) {errorNoGenero=true} - def numPaises = info.ProductionCountries.size() + def tipoYaSeteado=false - def tieneAnimacion = tieneGeneroAnimacion(generes) - def tieneFamiliar = tieneGeneroFamilia(generes) - - def esDocu = esDocumental(generes, localize.English.n) + //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/} && !(title =~ /Jackass/) + //anime def esAnime = false + def numPaises = info.ProductionCountries.size() if (tieneAnimacion && info.ProductionCountries.contains("JP")) { - esAnime = numPaises==1 || anime + esAnime = numPaises==1 || anime /*|| country=="JP"*/ } + tipoYaSeteado = esDocu || esAnime //*** 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 } })() - + def espanyola = false + if (!tipoYaSeteado && info.ProductionCountries.contains("ES")) { + espanyola= + (numPaises==1 || (numPaises==2 && info.ProductionCountries.contains("PT"))) + || { try { info.Network =~ /(?i)\bFLIXOL.\b|\b.?TVE\b/ } catch (e) { false } }() + || { try { info.ProductionCompanies.any{ it =~ /.?TVE|ESDIP|Canal Sur|Canal\+ España/ } } catch (e) { false } }() + || (info.Certifications.size()==1 && info.Certifications.ES!=null) + || { try { languages.size()==1 && languages.get(0).toString()=~/esp|spa/ } catch (e) { false } }() + || (movie.alternativeTitles.size()==1 && movie.alternativeTitles.ES!=null) + || { try { country=="ES" } catch (e){false} }() && { try { if(languages.size()==1) languages.get(0).toString()!="eng" } catch (e) { false } }() + tipoYaSeteado = espanyola + } //***** 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 + 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 + infantil = 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" } else { def titulosInfantiles = ['Bonnie bears', 'The Jungle Bunch'] if (titulosInfantiles.any { localize.English.n.toLowerCase()contains(it.toLowerCase()) }) @@ -450,25 +388,26 @@ try { //empieza el script esFamiliar = true //posem a familiar pelis de nens que no son animacio } } + tipoYaSeteado = esFamiliar || infantil } //asiaticas def asiatica = false - tipoYaSeteado = tipoYaSeteado & (infantil || espanyola) if (!tipoYaSeteado) { //asiaticas if (numPaises>0) { def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO"] + def languajAsia = ["zho", "kor", "thai", "vie", "jpn", "ind"] def matchP = paisesAsiaticos.intersect(info.ProductionCountries) - def allAsian = matchP.size()==numPaises - def probableAsian = matchP.size()>0 && englishAudios.isEmpty() && audio.size()>1 - if (allAsian || probableAsian/*en obseracion*/) asiatica=true + asiatica = matchP.size() == numPaises + || {try { languages.any{ languajAsia.contains(it.toString()) } } catch (err) {false} }() + //|| matchP.size()>0 && englishAudios.isEmpty() && audio.size()>1 /*en obseracion*/ + } } //es animacion - def esAnimacion = tieneAnimacion && !esFamiliar && !espanyola && !asiatica - + def esAnimacion = tieneAnimacion && !esFamiliar //tria if (esDocu) ruta = ruta_docu @@ -483,34 +422,30 @@ try { //empieza el script if (ruta==rutaOK && y>=2021) ruta = ruta_estrenos /********************************************/ /**************************************/ - - //if (errorNoGenero && ruta!=ruta_classic && ruta!=ruta_retro && !espanyola && !semiEsp && !infantil && ruta!=ruta_estrenos ) - // throw new Exception("[genero_no_especificado]") + + + /**** Nombre pelicula ****/ + def nombrePelicula_formatoPlex = {try { primaryTitle!=localize.Catalan.n ? localize.Catalan.plex.name : localize.Spanish.plex.name } catch (err) {localize.Spanish.plex.name} }() + /*************************/ + /*** RESULTADO FINAL ***/ - def inicial='' - - def inicialsRequerides = ruta==rutaOK || ruta==ruta_retro - if (inicialsRequerides) { - inicial = getInicial() - } + def inicial = (ruta==rutaOK || ruta==ruta_retro) ? getInicial() : '' def tmdb = " {tmdb-"+tmdbid+"}" - def nomPrincipal = esFicheroMetadatos ? nombreWbloqueMediainfo+tipoMetadato : nombreWbloqueMediainfo + def carpetaPeli = localize.Spanish.plex.name + tmdb + '/' + def nomPrincipal = nombrePelicula_formatoPlex + bloqueMediainfo def tracker = fn.find(/(?i)\bHDO(limpo)?\b/) def extras = tracker != null ? ' ['+tracker.replace("HDOlimpo", "HDO")+']' : '' - def resultado = ruta + //directorios - //nombre fichero - inicial + - localize.English.plex.name + '/' + nomPrincipal + extras + tmdb - //(esFicheroMetadatos ? localize.Spanish.plex.name+tipoMetadato : nombreWbloqueMediainfo) - return resultado + return ruta + inicial + carpetaPeli + nomPrincipal + extras + tmdb } catch (err) { - String str= err.getStackTrace().toString() - def pattern = ( str =~ /groovy.(\d+)./ ) - return " Error at line number = " + pattern[0][1] + ". more: "+str + if (ubuntu_desktop) { + String str= err.getStackTrace().toString() + def pattern = ( str =~ /groovy.(\d+)./ ) + return " Error at line number = " + pattern[0][1] + ". more: "+str + } def rutaMotivoErr def msgErr = err.getMessage() diff --git a/MaNGranA_Pelis_Organizer.groovy b/MaNGranA_Pelis_Organizer.groovy index dcb55cb..9bc237e 100755 --- a/MaNGranA_Pelis_Organizer.groovy +++ b/MaNGranA_Pelis_Organizer.groovy @@ -1,5 +1,5 @@ //by @xeviff -/** RUTAS **/ +/** RUTAS **/ def ubuntu_desktop=true def root = ubuntu_desktop ? '/mnt/mangrana_pelis/' : '/pelis/' @@ -21,44 +21,8 @@ def rutaKO = root+"error/" /* HARDCODED */ def skipAudioCheck = true -def infantilHardCoded = false /* otras funciones */ -def tieneGeneroAnimacion (generos) { - for (genero in generos) { - if (genero =~ /Anima[c|t]i\p{L}n/) - 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 esDocumental (generos, title) { - def noJackass = !(title =~ /Jackass/) - return (tieneGeneroDocumental(generos) || tieneGeneroReality(generos)) && noJackass -} -def fromEspPlatform () { - return fn.find(/(?i)\bFLIXOL.\b|\bRTVE\b/) != null -} /**/ def getInicial () { def nomIngles = localize.English.n @@ -91,6 +55,11 @@ try { //empieza el script } catch (e) { throw new Exception("[video_roto]") } + try { + genres + } catch (err) { + throw new Exception("[genero_no_especificado]") + } /********************************/ @@ -150,24 +119,35 @@ try { //empieza el script /**************************************/ /**** Carpeta / tipo contenido *******/ - def generes - def errorNoGenero=false - try {generes=genres} catch (err) {errorNoGenero=true} + def tipoYaSeteado=false - def tieneAnimacion = tieneGeneroAnimacion(generes) - def tieneFamiliar = tieneGeneroFamilia(generes) - - def esDocu = esDocumental(generes, localize.English.n) + //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.contains("Jackass") + //anime def esAnime = false + def numPaises = info.ProductionCountries.size() if (tieneAnimacion && info.ProductionCountries.contains("JP")) { - esAnime = info.ProductionCountries.size()==1 || anime + esAnime = numPaises==1 || anime /*|| country=="JP"*/ } - + tipoYaSeteado = esDocu || esAnime + + //*** española *** + def espanyola = tipoYaSeteado + || info.ProductionCountries.contains("ES") && (numPaises==1 || (numPaises==2 && info.ProductionCountries.contains("PT"))) + || { try { info.Network =~ /(?i)\bFLIXOL.\b|\b.?TVE\b/ } catch (e) { false } }() + || { try { info.ProductionCompanies.any{ it =~ /.?TVE|ESDIP|Canal Sur|Canal\+ España/ } } catch (e) { false } }() + || (info.Certifications.size()==1 && info.Certifications.ES!=null) + || { try { languages.size()==1 && languages.get(0).toString()=="esp" } catch (e) { false } }() || (movie.alternativeTitles.size()==1 && movie.alternativeTitles.ES!=null) + || { try { country=="ES" } catch (e){false} }() && { try { if(languages.size()==1) languages.get(0).toString()!="eng" } catch (e) { false } }() + tipoYaSeteado = tipoYaSeteado || espanyola + //***** familiar vs infantil **** def esFamiliar = tieneFamiliar def infantil = false - - def tipoYaSeteado=esDocu || esAnime if (!tipoYaSeteado) { def tieneCertificacion = info.Certifications!=null && info.Certifications.size()!=0 @@ -199,44 +179,39 @@ try { //empieza el script esFamiliar = true //posem a familiar pelis de nens que no son animacio } } + tipoYaSeteado = tipoYaSeteado || infantil } - //espanyoles & asiaticas - def espanyola = false + //asiaticas def asiatica = false - 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) { + if (numPaises>0) { def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO"] def matchP = paisesAsiaticos.intersect(info.ProductionCountries) - def allAsian = matchP.size()==info.ProductionCountries.size() + 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 + //tria if (esDocu) ruta = ruta_docu else if (esAnime) ruta = ruta_anime else if (infantil) ruta = ruta_infantil - else if (esFamiliar) 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 (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 /********************************************/ /**************************************/ - //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=''