bugfixed
This commit is contained in:
parent
e447c2a4e4
commit
5164803ad7
|
@ -1,7 +1,7 @@
|
||||||
//by @xeviff
|
//by @xeviff
|
||||||
/* HARDCODED */
|
/* HARDCODED */
|
||||||
def skipAudioCheck = true
|
def skipAudioCheck = true
|
||||||
def relocation = false
|
def relocation = true
|
||||||
/*************/
|
/*************/
|
||||||
/** RUTAS **/
|
/** RUTAS **/
|
||||||
def ubuntu_desktop=false
|
def ubuntu_desktop=false
|
||||||
|
@ -135,88 +135,64 @@ try { //empieza el script
|
||||||
/* RESULTADO MEDIAINFO */
|
/* RESULTADO MEDIAINFO */
|
||||||
def bloqueCalidadVideo = calidad + formato_distribucion
|
def bloqueCalidadVideo = calidad + formato_distribucion
|
||||||
def bloqueDescVideo = myBitrate + profundidadColor + myFps + hdr_info
|
def bloqueDescVideo = myBitrate + profundidadColor + myFps + hdr_info
|
||||||
|
def bloqueVideo = ' ['+codecVideo+' '+bloqueCalidadVideo+' '+bloqueDescVideo+']'
|
||||||
def bloqueVideo = ' ['+codecVideo+' '+bloqueCalidadVideo+'] ['+bloqueDescVideo+']'
|
|
||||||
|
|
||||||
|
|
||||||
/** Audio (ejecución) **/
|
/** AUDIO (ejecución) **/
|
||||||
def catalanAudios=[]
|
def bloqueAudio=''
|
||||||
def spanishAudios=[]
|
def audiosMap = [:]
|
||||||
def englishAudios=[]
|
for (aud in audio) {
|
||||||
def otherAudios=[]
|
def shortDesc = aud.Language_String3
|
||||||
def audioDeclUndefined=false
|
audiosMap[shortDesc] = audiosMap[shortDesc] ?: [:]
|
||||||
for (item in audio) {
|
audiosMap[shortDesc][aud.Format] = audiosMap[shortDesc][aud.Format] ?: []
|
||||||
def idioma
|
audiosMap[shortDesc][aud.Format] << aud
|
||||||
try {
|
}
|
||||||
idioma = item.Language_String
|
def groupedAudiosMap = [:]
|
||||||
if (idioma==null) otherAudios.add("audio_no_def") //throw new Exception("[idioma_audio_no_definido0]")
|
for (audioElms in audiosMap) {
|
||||||
if ("Catalan"==idioma) catalanAudios.add(item)
|
def k = audioElms.key
|
||||||
else if (idioma=~/(?i)(Spanish|Espa.ol)/) spanishAudios.add(item)
|
def v = audioElms.value
|
||||||
else if ("English"==idioma) englishAudios.add(item)
|
if (!k.contains('+') && countAudiosInMap(v)>1) k += '+'
|
||||||
else if ("Undefined"==idioma) audioDeclUndefined=true
|
def mQ = getMaxQuality(v)
|
||||||
else otherAudios.add(item)
|
def mQstr = (mQ==null || mQ.isEmpty()) ? 'und' : printAudio(mQ)
|
||||||
} catch (err) {
|
if (groupedAudiosMap.containsKey(mQstr)) groupedAudiosMap[mQstr].add(k)
|
||||||
if (idioma==null) {
|
else groupedAudiosMap[mQstr] = [k]
|
||||||
try { //si tampoco tiene item.Title
|
}
|
||||||
def audioTitle=item.Title
|
audiosMap=null
|
||||||
if (audioTitle!=null) {
|
def temp=''
|
||||||
if (any{audioTitle}{0} =~ /(?i)\bcat\b/)
|
for (audioGroup in groupedAudiosMap) {
|
||||||
catalanAudios.add(item)
|
def k = audioGroup.key
|
||||||
else if (any{audioTitle}{0} =~ /(?i)\bcast\b|\bspa\b/)
|
def v = audioGroup.value
|
||||||
spanishAudios.add(item)
|
def gS = v.size()
|
||||||
else if (any{audioTitle}{0} =~ /(?i)\bingl.es\b|\beng\b/)
|
def str=''
|
||||||
englishAudios.add(item)
|
for (int i=0; i<gS; i++) {
|
||||||
else otherAudios.add(item)
|
str += (v[i]!=null?v[i]:'und') +', '
|
||||||
}
|
if (i==gS-1) {
|
||||||
} catch (ex) {}
|
str = removeLastComa(str)+' '
|
||||||
} else if (!skipAudioCheck) throw err
|
str += k+', '
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
bloqueAudio += str
|
||||||
}
|
}
|
||||||
|
groupedAudiosMap=null
|
||||||
if (audioDeclUndefined || (catalanAudios.isEmpty() && spanishAudios.isEmpty() && englishAudios.isEmpty() && otherAudios.isEmpty()) ) {
|
bloqueAudio = '['+removeLastComa(bloqueAudio)
|
||||||
if (!skipAudioCheck) throw new Exception("[idioma_audio_no_definido]")
|
|
||||||
}
|
|
||||||
def tenimCat=false
|
|
||||||
if (!catalanAudios.isEmpty()) { //tenim català
|
|
||||||
tenimCat=true
|
|
||||||
def maxCat = getMaxQuality(catalanAudios)
|
|
||||||
def blocCat = printAudio(maxCat)
|
|
||||||
def tenimEsp = !spanishAudios.isEmpty()
|
|
||||||
def blocEsp=''
|
|
||||||
if (tenimEsp) {
|
|
||||||
def maxEsp = getMaxQuality(spanishAudios)
|
|
||||||
blocEsp = ', '+printAudio(maxEsp)
|
|
||||||
}
|
|
||||||
bloqueAudio = blocCat + blocEsp
|
|
||||||
} else if (!spanishAudios.isEmpty()) { //tenemos español
|
|
||||||
def maxEsp = getMaxQuality(spanishAudios)
|
|
||||||
bloqueAudio = printAudio(maxEsp)
|
|
||||||
} else if (!englishAudios.isEmpty()) { //tenemos español
|
|
||||||
if (!skipAudioCheck) throw new Exception("[idioma_audio_solo_ingles]")
|
|
||||||
} else if (!otherAudios.isEmpty()) { //tenemos español
|
|
||||||
if (!skipAudioCheck) throw new Exception("[idioma_audio_marginal]")
|
|
||||||
} else {
|
|
||||||
if (!skipAudioCheck) throw new Exception("[idioma_audio_no_encontrado]")
|
|
||||||
}
|
|
||||||
if (bloqueAudio==null) bloqueAudio = "[audio_no_def]"
|
|
||||||
else bloqueAudio = ' ['+bloqueAudio+']'
|
|
||||||
/***********/
|
|
||||||
|
|
||||||
|
|
||||||
/***** subtitulos *******/
|
/***** subtitulos *******/
|
||||||
def bloqueSubs
|
def bloqueSubs
|
||||||
try {
|
try {
|
||||||
def capturedSubs = [:]
|
def capturedSubs = [:]
|
||||||
bloqueSubs = ' [sub_ '
|
bloqueSubs = ']['
|
||||||
for (sub in text) handleSub(sub, capturedSubs)
|
for (sub in text) handleSub(sub, capturedSubs)
|
||||||
for (entry in capturedSubs) bloqueSubs += (entry.value!='null'?entry.value:'und')+', '
|
for (entry in capturedSubs) bloqueSubs += (entry.value!='null'?entry.value:'und')+', '
|
||||||
bloqueSubs = bloqueSubs.substring(0,bloqueSubs.size()-2)+']'
|
bloqueSubs = bloqueSubs.substring(0,bloqueSubs.size()-2)+']'
|
||||||
}catch(err){bloqueSubs=' [no sub]'}
|
}catch(err){bloqueSubs=''}
|
||||||
/************************/
|
/************************/
|
||||||
|
|
||||||
|
|
||||||
/**************************************/
|
/*************************************************************************************************************/
|
||||||
/**** Carpeta / tipo contenido *******/
|
/**** Carpeta / tipo contenido ******************************************************************************/
|
||||||
|
/*************************************************************************************************************/
|
||||||
|
|
||||||
def tipoYaSeteado=false
|
def tipoYaSeteado=false
|
||||||
|
|
||||||
//animacion (no concluyente)
|
//animacion (no concluyente)
|
||||||
|
@ -321,13 +297,13 @@ try { //empieza el script
|
||||||
|
|
||||||
/*** RESULTADO FINAL ***/
|
/*** RESULTADO FINAL ***/
|
||||||
def inicial = (ruta==rutaOK || ruta==ruta_retro) ? getInicial() : ''
|
def inicial = (ruta==rutaOK || ruta==ruta_retro) ? getInicial() : ''
|
||||||
def tmdb = " {tmdb-"+tmdbid+"}"
|
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 nomPrincipal = nombrePelicula_formatoPlex + bloqueVideo + bloqueAudio + bloqueSubs
|
||||||
def tracker = fn.find(/(?i)\bHDO(limpo)?\b|\bRedBits\b/)
|
def trackerCatch = fn.find(/(?i)\bHDO(limpo)?\b|\bRedBits\b/)
|
||||||
def extras = tracker != null ? ' ['+tracker.replace("HDOlimpo", "HDO")+']' : ''
|
def tracker = trackerCatch != null ? '['+trackerCatch.replace("HDOlimpo", "HDO")+']' : ''
|
||||||
|
|
||||||
return ruta + inicial + carpetaPeli + nomPrincipal + extras + tmdb
|
return ruta + inicial + carpetaPeli + nomPrincipal + tracker + tmdb
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
||||||
|
@ -377,15 +353,33 @@ try { //empieza el script
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
/********************************************************/
|
/********************************************************/
|
||||||
|
|
||||||
def getAudiosFromListByFormat (format, listAudios) {
|
|
||||||
def result=[]
|
/********* AUDIO *****************/
|
||||||
for (singleAudio in listAudios) {
|
def removeLastComa(txt) {
|
||||||
if (singleAudio.Format==format) {
|
return txt.substring(0, txt.size()-2)
|
||||||
result.add(singleAudio)
|
}
|
||||||
if ("EAC3"==format) hayEAC3=true
|
def getMaxQuality (mapAudioIndexedByFormat) {
|
||||||
}
|
def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"]
|
||||||
|
for (cFormat in formatSet) {
|
||||||
|
if (mapAudioIndexedByFormat.containsKey(cFormat)){
|
||||||
|
def difChannelsList = mapAudioIndexedByFormat[cFormat]
|
||||||
|
return difChannelsList.size()==1 ? difChannelsList[0] : getBestChannelFromList(difChannelsList)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result
|
return null
|
||||||
|
}
|
||||||
|
def printAudio (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 canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 8:'7.1')
|
||||||
|
return formato_audio + ' ' + canales
|
||||||
}
|
}
|
||||||
def getBestChannelFromList (audiosFormatFound) {
|
def getBestChannelFromList (audiosFormatFound) {
|
||||||
def bestChanel
|
def bestChanel
|
||||||
|
@ -398,37 +392,12 @@ def getBestChannelFromList (audiosFormatFound) {
|
||||||
}
|
}
|
||||||
return bestChanel
|
return bestChanel
|
||||||
}
|
}
|
||||||
def getMaxQuality (listOfLanguageAudio) {
|
def countAudiosInMap(audMap){
|
||||||
def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"]
|
int count=0
|
||||||
for (cFormat in formatSet) {
|
for (aud in audMap) count += aud.value.size()
|
||||||
def audiosFormatFound = getAudiosFromListByFormat(cFormat, listOfLanguageAudio);
|
return count
|
||||||
if (!audiosFormatFound.isEmpty()) {
|
|
||||||
return getBestChannelFromList(audiosFormatFound)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
/********* SUBS ***************/
|
||||||
def bloqueAudio
|
|
||||||
def printAudio (audio2Print) {
|
|
||||||
def idioma
|
|
||||||
def idiomaOrigin = audio2Print.Language_String
|
|
||||||
if (idiomaOrigin==null) {
|
|
||||||
idiomaOrigin = audio2Print.Title
|
|
||||||
if (idiomaOrigin =~ /(?i)\bcat\b/)
|
|
||||||
idioma = "Cat"
|
|
||||||
else if (idiomaOrigin =~ /(?i)\bcast\b|\bspa\b/)
|
|
||||||
idioma = "Es"
|
|
||||||
} else {
|
|
||||||
idioma = idiomaOrigin.replace("Catalan","Cat").replace("Espanol / Espanol", "Es").replaceFirst(/(?i)(spanish|espa.ol)/,"Es").replace("(ES)","")
|
|
||||||
}
|
|
||||||
def formato_audio = audio2Print.Format_Commercial.replace("Dolby Digital":"Dolby").replace(" Plus","+")
|
|
||||||
.replace("DTS-HD Master Audio","DTS-MA").replace("DTS-HD High Resolution Audio","DTS-HD-H")
|
|
||||||
.replace("MPEG Audio","MPEG").replace("HE-AAC","AAC+")
|
|
||||||
.replace(" with Dolby Atmos", "Atmos")
|
|
||||||
def canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 8:'7.1')
|
|
||||||
return idioma + ' ' + formato_audio + ' ' + canales
|
|
||||||
}
|
|
||||||
|
|
||||||
def handleSub(sub, capturedSubs) {
|
def handleSub(sub, capturedSubs) {
|
||||||
def lang = sub.Language_String != null ? sub.Language_String : sub.title
|
def lang = sub.Language_String != null ? sub.Language_String : sub.title
|
||||||
def lang3 = sub.Language_String3 != null ? sub.Language_String3 : sub.title
|
def lang3 = sub.Language_String3 != null ? sub.Language_String3 : sub.title
|
||||||
|
|
|
@ -128,13 +128,6 @@ def printAudio (audio2Print) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def bloqueAudio2=''
|
def bloqueAudio2=''
|
||||||
def audiosMap = [:]
|
def audiosMap = [:]
|
||||||
for (aud in audio) {
|
for (aud in audio) {
|
||||||
|
@ -148,13 +141,14 @@ def groupedAudiosMap = [:]
|
||||||
for (audioElms in audiosMap) {
|
for (audioElms in audiosMap) {
|
||||||
def k = audioElms.key
|
def k = audioElms.key
|
||||||
def v = audioElms.value
|
def v = audioElms.value
|
||||||
|
if (!k.contains('+') && countAudiosInMap(v)>1) k += '+'
|
||||||
def mQ = getMaxQuality2(v)
|
def mQ = getMaxQuality2(v)
|
||||||
if (v.size()>1 && !k.contains('+')) k += '+'
|
def mQstr = (mQ==null || mQ.isEmpty()) ? 'und' : printAudio2(mQ)
|
||||||
def mQstr = printAudio2(mQ)
|
|
||||||
if (groupedAudiosMap.containsKey(mQstr)) groupedAudiosMap[mQstr].add(k)
|
if (groupedAudiosMap.containsKey(mQstr)) groupedAudiosMap[mQstr].add(k)
|
||||||
else groupedAudiosMap[mQstr] = [k]
|
else groupedAudiosMap[mQstr] = [k]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
audiosMap=null
|
audiosMap=null
|
||||||
def temp=''
|
def temp=''
|
||||||
for (audioGroup in groupedAudiosMap) {
|
for (audioGroup in groupedAudiosMap) {
|
||||||
|
@ -183,30 +177,25 @@ def getMaxQuality2 (mapAudioIndexedByFormat) {
|
||||||
def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"]
|
def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"]
|
||||||
for (cFormat in formatSet) {
|
for (cFormat in formatSet) {
|
||||||
if (mapAudioIndexedByFormat.containsKey(cFormat)){
|
if (mapAudioIndexedByFormat.containsKey(cFormat)){
|
||||||
return getBestChannelFromList2(mapAudioIndexedByFormat[cFormat])
|
def difChannelsList = mapAudioIndexedByFormat[cFormat]
|
||||||
|
return difChannelsList.size()==1 ? difChannelsList[0] : getBestChannelFromList2(difChannelsList)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
def printAudio2 (audio2Print) {
|
def printAudio2 (audio2Print) {
|
||||||
def formato_audio = audio2Print.Format_Commercial.replace("Dolby Digital":"Dolby").replace(" Plus","+")
|
def formato_audio = audio2Print.Format_Commercial.replaceAll(/Dolby Digital/, 'Dolby')
|
||||||
.replace("DTS-HD Master Audio","DTS-MA").replace("DTS-HD High Resolution Audio","DTS-HD-H")
|
.replaceAll(/ Plus/, '+')
|
||||||
.replace("MPEG Audio","MPEG").replace("HE-AAC","AAC+")
|
.replaceAll(/DTS-HD Master Audio/, 'DTS-MA')
|
||||||
.replace(" with Dolby Atmos", "Atmos").replace("TrueHD", "HD")
|
.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 canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 8:'7.1')
|
def canales = audio2Print.Channels.replace(2:'2.0', 6:'5.1', 8:'7.1')
|
||||||
return formato_audio + ' ' + canales
|
return formato_audio + ' ' + canales
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def getAudiosFromListByFormat2 (format, listAudios) {
|
|
||||||
def result=[]
|
|
||||||
for (singleAudio in listAudios) {
|
|
||||||
if (singleAudio.Format==format) {
|
|
||||||
result.add(singleAudio)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
def getBestChannelFromList2 (audiosFormatFound) {
|
def getBestChannelFromList2 (audiosFormatFound) {
|
||||||
def bestChanel
|
def bestChanel
|
||||||
def currentValue=0
|
def currentValue=0
|
||||||
|
@ -218,7 +207,11 @@ def getBestChannelFromList2 (audiosFormatFound) {
|
||||||
}
|
}
|
||||||
return bestChanel
|
return bestChanel
|
||||||
}
|
}
|
||||||
|
def countAudiosInMap(audMap){
|
||||||
|
int count=0
|
||||||
|
for (aud in audMap) count += aud.value.size()
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue