From 093a7252c881745baf4ec4adb4c17d6ea7045c29 Mon Sep 17 00:00:00 2001 From: xeviff <73612508+xeviff@users.noreply.github.com> Date: Tue, 16 May 2023 15:48:43 +0200 Subject: [PATCH] lots of changes --- MaNGranA_Pelis.groovy | 196 ++++++++++-------- filter_latin.groovy | 7 + test/audio_format.groovy | 15 ++ test/infantil.groovy | 41 ++++ .../new audio test.groovy | 15 +- test/subs.groovy | 29 +++ 6 files changed, 208 insertions(+), 95 deletions(-) create mode 100755 filter_latin.groovy create mode 100755 test/audio_format.groovy create mode 100755 test/infantil.groovy rename new audio test.groovy => test/new audio test.groovy (90%) create mode 100755 test/subs.groovy diff --git a/MaNGranA_Pelis.groovy b/MaNGranA_Pelis.groovy index 5216071..22ea527 100755 --- a/MaNGranA_Pelis.groovy +++ b/MaNGranA_Pelis.groovy @@ -1,12 +1,13 @@ //by @xeviff /* HARDCODED */ -def skipAudioCheck = true +def ubuntu_desktop=true def relocation = true +def skipAudioCheck = true /*************/ /** RUTAS **/ -def ubuntu_desktop=false -def root = ubuntu_desktop ? '/mnt/mangrana_pelis/' : '/pelis/' + +def root = '/pelis/' def rutaOK = root+"Pelis/plain/" def ruta = rutaOK def ruta_docu = root+"Documentales/plain/" @@ -15,6 +16,7 @@ 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_latina = root+"Pelis_lat/" def ruta_cat = root+"Pelis_cat/" def ruta_retro = root+"Pelis_retro/plain/" def ruta_estrenos = root+"Pelis_estrenos/plain/" @@ -122,21 +124,16 @@ try { //empieza el script } 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){} + try{ myBitrate = mbps.replace(/.0/,'').replace(' Mbps','M') }catch(err){} def myFps = ' FRvar' - try { myFps = ' '+fps.replace(/.0/,'').replace(' ','') }catch(err){} + try { myFps = ' '+fps.replace(/.0/,'').replace(' fps','f') }catch(err){} /***************************/ /* BLOQUE VIDEO */ def bloqueCalidadVideo = calidad + formato_distribucion - def bloqueDescVideo = myBitrate + profundidadColor + myFps + hdr_info + def bloqueDescVideo = myBitrate + myFps + hdr_info def bloqueVideo = ' ['+codecVideo+' '+bloqueCalidadVideo+' '+bloqueDescVideo+']' /**********************************************************************************************************/ @@ -145,7 +142,8 @@ try { //empieza el script def audiosMap = [:] for (aud in audio) { def shortDesc = aud.Language_String3 !=null ? aud.Language_String3 - : (aud.Title=~/(?i).+spa.+/?'spa': aud.Title.substring(0,3).toLowerCase()) + : aud.Title!=null ? (aud.Title=~/(?i).+spa.+/?'spa': aud.Title.substring(0,3).toLowerCase()) : 'und' + if (aud.Title!=null && aud.Title=~/(?i).*latin.*/) shortDesc='lat' audiosMap[shortDesc] = audiosMap[shortDesc] ?: [:] audiosMap[shortDesc][aud.Format] = audiosMap[shortDesc][aud.Format] ?: [] audiosMap[shortDesc][aud.Format] << aud @@ -185,9 +183,16 @@ try { //empieza el script try { def capturedSubs = [:] bloqueSubs = '[' - for (sub in text) handleSub(sub, capturedSubs) - for (entry in capturedSubs) bloqueSubs += (entry.value!='null'?entry.value:'und')+', ' - bloqueSubs = bloqueSubs.substring(0,bloqueSubs.size()-2)+']' + for (int s; s10) break; + handleSub(text[s], capturedSubs); + } + def keysList = capturedSubs.keySet().toList() + for (index in 0..< keysList.size()) { + if (index>3){ bloqueSubs+='etc '; break; } + bloqueSubs += capturedSubs.get(keysList[index]).replace('null','und').replace(" F+","+F").replace("+ F","+F") + ', ' + } + bloqueSubs = removeLastComa(bloqueSubs)+']' }catch(err){bloqueSubs=''} /************************/ @@ -204,15 +209,57 @@ try { //empieza el script def tieneFamiliar = genres.any{ it =~ /Familia|Family/} //docu def esDocu = genres.any{ it =~ /Documental|Documentary|Reality/} && !(localize.English.n =~ /Jackass/) - //anime + //Anime ---------- (Animacion encara no es pot perquè depen del infantil) def esAnime = false def numPaises = info.ProductionCountries.size() - def llengu=[] - if (tieneAnimacion && info.ProductionCountries.contains("JP")) { - esAnime = numPaises==1 || anime /*|| country=="JP"*/ + def llengu = normalLang() + if (tieneAnimacion && info.ProductionCountries.contains("JP") && llengu.contains('jpn')) { + esAnime = (numPaises==1 || anime || country=="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 = info.Certifications!=null && info.Certifications.size()!=0 + + if (tieneFamiliar && tieneAnimacion) { + def noTanInfantil = info.Certifications.US ==~/PG-13/ && info.Certifications.ES!="7" + if (!noTanInfantil) infantil = true + } + else if (tieneAnimacion) { + if (tieneCertificacion) { + infantil = info.Certifications.US=="G" + || info.Certifications.ES==~/Ai|APTA/ + || info.Certifications.DE==~/0/ + || info.Certifications.IT=="T" + || info.Certifications.IE=="G" + || info.Certifications.LT=="V" || info.Certifications.RU ==~ /6.+/ + || info.Certifications.BR=="L" + || info.Certifications.NO=="A" + || info.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) { + if (tieneCertificacion && ( + info.Certifications.US=="G" + )) { + esFamiliar = true //posem a familiar pelis de nens que no son animacio + } + } + tipoYaSeteado = tipoYaSeteado || esFamiliar || infantil + } + + //animacion + def esAnimacion = tieneAnimacion && !infantil + tipoYaSeteado = tipoYaSeteado || esAnimacion + //*** española *** def espanyola = false def catalana = false @@ -222,67 +269,36 @@ try { //empieza el script || { 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 } }() || (info.Certifications.size()==1 && info.Certifications.ES!=null) - || { llengu=normalLang(llengu); llengu.size()==1 && llengu[0]=~/esp|spa/}() + || llengu.size()==1 && llengu[0]=~/esp|spa/ || (movie.alternativeTitles.size()==1 && movie.alternativeTitles.ES!=null) || (country=="ES" && (!llengu.isEmpty() ? llengu.size()==1 && llengu[0]!="eng" : true)) - if (espanyola) catalana = { llengu=normalLang(llengu); llengu.contains('cat') }() - tipoYaSeteado = espanyola - } - - //***** familiar vs infantil **** - def esFamiliar = tieneFamiliar - def infantil = false - - 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) { - 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()) }) - infantil = true - } - } else if (!esFamiliar) { - if (tieneCertificacion && ( - info.Certifications.US=="G" - )) { - esFamiliar = true //posem a familiar pelis de nens que no son animacio - } - } - tipoYaSeteado = esFamiliar || infantil + if (espanyola) catalana = llengu.contains('cat') + tipoYaSeteado = tipoYaSeteado || espanyola } //asiaticas def asiatica = false 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) - asiatica = matchP.size() == numPaises - //|| {try { languages.any{ languajAsia.contains(it.toString()) } } catch (err) {false} }() - || { llengu=normalLang(llengu); languajAsia.intersect(llengu).size() == languajAsia.size() }() - || { llengu.size()==1 && llengu[0]=~/esp|spa/}() - //|| matchP.size()>0 && englishAudios.isEmpty() && audio.size()>1 /*en obseracion*/ - - } + def paisesAsiaticos = ["CN", "HK", "JP", "KP", "KR", "TH", "NP", "TW", "PH", "MO"] + def paisesIntersec=0 + def languajAsia = ["zho", "kor", "thai", "vie", "jpn", "ind"] + asiatica = (numPaises != 0 && {((paisesIntersec=paisesAsiaticos.intersect(info.ProductionCountries).size()) == numPaises || (/*en observacion*/paisesIntersec!=0 && !llengu.contains('eng')) ) }()) + || languajAsia.intersect(llengu).size() == languajAsia.size() + //|| {try { languages.any{ languajAsia.contains(it.toString()) } } catch (err) {false} }() + //|| matchP.size()>0 && englishAudios.isEmpty() && audio.size()>1 /*en obseracion*/ + tipoYaSeteado = tipoYaSeteado || asiatica } - //es animacion - def esAnimacion = tieneAnimacion && !esFamiliar + //*** latina *** + def latina = false + if (!tipoYaSeteado) { + def paisesLatinos = ["MX", "AR"] + latina = {try {paisesLatinos.contains(country)} catch (e) {false}}() + || (numPaises != 0 && paisesLatinos.intersect(info.ProductionCountries).size() == numPaises) + || info.productionCompanies.any{it=~/Corazón Films/} + } + ////////////////////////////////////////////// //tria if (esDocu) ruta = ruta_docu else if (esAnime) ruta = ruta_anime @@ -290,6 +306,7 @@ try { //empieza el script 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 (esFamiliar) ruta = ruta_familiar else if (asiatica) ruta = ruta_asiaticas else if (y<1980) ruta = ruta_classic @@ -301,7 +318,7 @@ try { //empieza el script def nombrePelicula_formatoPlex = {try { catalana ? localize.Catalan.n : localize.Spanish.plex.name } catch (err) {localize.Spanish.plex.name} }() def inicial = (ruta==rutaOK || ruta==ruta_retro) ? getInicial() : '' def tmdb = "{tmdb-"+tmdbid+"}" - def carpetaPeli = localize.Spanish.plex.name + tmdb + '/' + def carpetaPeli = localize.Spanish.plex.name + ' ' + tmdb + '/' 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")+']' : '' @@ -309,15 +326,16 @@ try { //empieza el script return ruta + inicial + carpetaPeli + nomPrincipal + tracker + tmdb /////////////////////////////////////////////////////////////////////////// } catch (err) { + def msgErr = err.getMessage() if (ubuntu_desktop) { String str= err.getStackTrace().toString() def pattern = ( str =~ /groovy.(\d+)./ ) - return " Error at line number = " + pattern[0][1] + ". more: "+str + return " Error at line number = " + pattern[0][1] + ". more: "+msgErr } def rutaMotivoErr - def msgErr = err.getMessage() + if (msgErr=="[formato_fichero_noestarndar]" || msgErr=="[video_roto]") rutaMotivoErr="/fichero/" else if (msgErr=="[genero_no_especificado]" || msgErr=="[certificado_edad_no_especificado]") { @@ -372,17 +390,20 @@ def getMaxQuality (mapAudioIndexedByFormat) { return null } def printAudio (audio2Print) { - def formato_audio = audio2Print.Format_Commercial - .replaceAll(/Dolby Digital/, 'Dolby') - .replaceAll(/ Plus/, 'P') - .replaceAll(/DTS-HD Master Audio/, 'DTS-MA') - .replaceAll(/DTS-HD High Resolution Audio/, 'DTS-HR') - .replaceAll(/MPEG Audio/, 'MPEG') - .replaceAll(/HE-AAC/, 'hAAC') - .replaceAll(/ with Dolby Atmos/, 'Atmos') - .replaceAll(/TrueHD/, 'tHD') - def canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 8:'7.1') - return formato_audio + ' ' + canales + def format = audio2Print.Format + def fCom = audio2Print.Format_Commercial + switch (format) { + case "AC-3" -> fCom = "DD" + case "E-AC-3" -> fCom = "DD+" + case "MPEG Audio" -> fCom = "MPEG" + case "DTS" -> { if (fCom.contains("Master Audio")) fCom="DTS_MA" + else if (fCom.contains("DTS-HD High Resolution Audio")) fCom="DTS_HRA" + else if (fCom.contains("DTS-ES")) fCom="DTS-ES" + } + 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') + return fCom + ' ' + canales } def getBestChannelFromList (audiosFormatFound) { def bestChanel @@ -413,7 +434,7 @@ def handleSub(sub, capturedSubs) { def newTxt=''+existing if (!existing.contains('+')) newTxt += '+' if (forced && !existing.contains('F')) newTxt += ' F' - capturedSubs[lang]=newTxt.replace(" F+","+F") + capturedSubs[lang]=newTxt } } @@ -428,8 +449,9 @@ def getInicial () { def inicial = iniClear.replaceAll(/[0-9]/,'#')+'/' return inicial } -def normalLang(langs) { - return langs.isEmpty() ? {try { for (lan in languages) langs.add(lan.toString()); return langs } catch(err) {langs}}() : langs +def normalLang() { + def langs=[] + return {try { for (lan in languages) langs.add(lan.toString()); return langs } catch(err) {langs}}() } def sanityCheck(newId) { def oldId = fn.find(/\{tmdb-\d+\}/)?.find(/\d+/) diff --git a/filter_latin.groovy b/filter_latin.groovy new file mode 100755 index 0000000..fb57bc5 --- /dev/null +++ b/filter_latin.groovy @@ -0,0 +1,7 @@ +def countries = info.ProductionCountries +def numPaises = countries.size() +def paisesLatinos = ["MX", "AR"] +def latina = (numPaises != 0 && paisesLatinos.intersect(countries).size() == numPaises) + || {try {paisesLatinos.contains(country)} catch (e) {false}}() + || info.productionCompanies.any{it=~/Corazón Films/} +return latina \ No newline at end of file diff --git a/test/audio_format.groovy b/test/audio_format.groovy new file mode 100755 index 0000000..6144020 --- /dev/null +++ b/test/audio_format.groovy @@ -0,0 +1,15 @@ +def str='' +for (aud in audio) { + def shortD = aud.Format + def res = aud.Format_Commercial + switch (shortD) { + case "AC-3" -> res = "DD" + case "E-AC-3" -> res = "DD+" + case "MPEG Audio" -> res = "MPEG" + case "DTS" -> { if (res.contains("Master Audio")) res="DTS_MA" + else if (res.contains("DTS-HD High Resolution Audio")) res="DTS_HRA"} + case "MLP FBA" -> {def tmp = "D_HD"; if (res.contains("Atmos")) tmp+="_Atmos"; res = tmp} + } + str += shortD + ': ' +res+', ' +} +str \ No newline at end of file diff --git a/test/infantil.groovy b/test/infantil.groovy new file mode 100755 index 0000000..df5f445 --- /dev/null +++ b/test/infantil.groovy @@ -0,0 +1,41 @@ +//animacion (no concluyente) +def tieneAnimacion = genres.any{ it =~ /Anima.i.n/} +//familiar (no conclud) +def tieneFamiliar = genres.any{ it =~ /Familia|Family/} + +//***** familiar vs infantil **** +def esFamiliar = tieneFamiliar +def infantil = false + +def tieneCertificacion = info.Certifications!=null && info.Certifications.size()!=0 + +if (tieneFamiliar && tieneAnimacion) { + def noTanInfantil = info.Certifications.US ==~/PG-13/ && info.Certifications.ES==~/7/ + if (!noTanInfantil) infantil = true +} +else if (tieneAnimacion) { + if (tieneCertificacion) { + infantil = info.Certifications.US=="G" + || info.Certifications.ES=~/Ai|APTA/ + || info.Certifications.DE==~/0/ + || info.Certifications.IT=="T" + || info.Certifications.IE=="G" + || info.Certifications.LT=="V" || info.Certifications.RU ==~ /6.+/ + || info.Certifications.BR=="L" + } else { + return 'Bonnie bears'.toLowerCase() + ' - ' + localize.English.n.toLowerCase() + ' - result: '+localize.English.n.toLowerCase().contains('Bonnie bears') + + def titulosInfantiles = ['Boonie 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 + } +} + +def res = 'result: '+infantil + '. '+info.certifications + ' - ' + genres + diff --git a/new audio test.groovy b/test/new audio test.groovy similarity index 90% rename from new audio test.groovy rename to test/new audio test.groovy index 214835c..0aa2a95 100755 --- a/new audio test.groovy +++ b/test/new audio test.groovy @@ -186,14 +186,13 @@ def getMaxQuality2 (mapAudioIndexedByFormat) { } def printAudio2 (audio2Print) { - def formato_audio = audio2Print.Format_Commercial.replaceAll(/Dolby Digital/, 'Dolby') - .replaceAll(/ Plus/, '+') - .replaceAll(/DTS-HD Master Audio/, 'DTS-MA') - .replaceAll(/DTS-HD High Resolution Audio/, 'DTS-HD-H') - .replaceAll(/MPEG Audio/, 'MPEG') - .replaceAll(/HE-AAC/, 'AAC+') - .replaceAll(/ with Dolby Atmos/, 'Atmos') - .replaceAll(/TrueHD/, 'HD') + def formato_audio = audio2Print.Format + switch (formato_audio) { + case "AC-3" -> formato_audio = "DD" + case "E-AC-3" -> formato_audio = "DD+" + case "MPEG Audio" -> formato_audio = "MPEG" + case "DTS" -> {if(audio2Print.Format_Commercial.contains("Master Audio")) formato_audio="DTS-MA"} + } def canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 8:'7.1') return formato_audio + ' ' + canales } diff --git a/test/subs.groovy b/test/subs.groovy new file mode 100755 index 0000000..13f0f56 --- /dev/null +++ b/test/subs.groovy @@ -0,0 +1,29 @@ +def bloqueSubs + try { + def capturedSubs = [:] + bloqueSubs = '[' + for (int s; s10) break; handleSub(text[s], capturedSubs); } + for (index in 0..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 \ No newline at end of file