bugfixed
This commit is contained in:
parent
e447c2a4e4
commit
5164803ad7
|
@ -1,7 +1,7 @@
|
|||
//by @xeviff
|
||||
/* HARDCODED */
|
||||
def skipAudioCheck = true
|
||||
def relocation = false
|
||||
def relocation = true
|
||||
/*************/
|
||||
/** RUTAS **/
|
||||
def ubuntu_desktop=false
|
||||
|
@ -135,88 +135,64 @@ try { //empieza el script
|
|||
/* RESULTADO MEDIAINFO */
|
||||
def bloqueCalidadVideo = calidad + formato_distribucion
|
||||
def bloqueDescVideo = myBitrate + profundidadColor + myFps + hdr_info
|
||||
|
||||
def bloqueVideo = ' ['+codecVideo+' '+bloqueCalidadVideo+'] ['+bloqueDescVideo+']'
|
||||
def bloqueVideo = ' ['+codecVideo+' '+bloqueCalidadVideo+' '+bloqueDescVideo+']'
|
||||
|
||||
|
||||
/** Audio (ejecución) **/
|
||||
def catalanAudios=[]
|
||||
def spanishAudios=[]
|
||||
def englishAudios=[]
|
||||
def otherAudios=[]
|
||||
def audioDeclUndefined=false
|
||||
for (item in audio) {
|
||||
def idioma
|
||||
try {
|
||||
idioma = item.Language_String
|
||||
if (idioma==null) otherAudios.add("audio_no_def") //throw new Exception("[idioma_audio_no_definido0]")
|
||||
if ("Catalan"==idioma) catalanAudios.add(item)
|
||||
else if (idioma=~/(?i)(Spanish|Espa.ol)/) spanishAudios.add(item)
|
||||
else if ("English"==idioma) englishAudios.add(item)
|
||||
else if ("Undefined"==idioma) audioDeclUndefined=true
|
||||
else otherAudios.add(item)
|
||||
} catch (err) {
|
||||
if (idioma==null) {
|
||||
try { //si tampoco tiene item.Title
|
||||
def audioTitle=item.Title
|
||||
if (audioTitle!=null) {
|
||||
if (any{audioTitle}{0} =~ /(?i)\bcat\b/)
|
||||
catalanAudios.add(item)
|
||||
else if (any{audioTitle}{0} =~ /(?i)\bcast\b|\bspa\b/)
|
||||
spanishAudios.add(item)
|
||||
else if (any{audioTitle}{0} =~ /(?i)\bingl.es\b|\beng\b/)
|
||||
englishAudios.add(item)
|
||||
else otherAudios.add(item)
|
||||
/** AUDIO (ejecución) **/
|
||||
def bloqueAudio=''
|
||||
def audiosMap = [:]
|
||||
for (aud in audio) {
|
||||
def shortDesc = aud.Language_String3
|
||||
audiosMap[shortDesc] = audiosMap[shortDesc] ?: [:]
|
||||
audiosMap[shortDesc][aud.Format] = audiosMap[shortDesc][aud.Format] ?: []
|
||||
audiosMap[shortDesc][aud.Format] << aud
|
||||
}
|
||||
} catch (ex) {}
|
||||
} else if (!skipAudioCheck) throw err
|
||||
def groupedAudiosMap = [:]
|
||||
for (audioElms in audiosMap) {
|
||||
def k = audioElms.key
|
||||
def v = audioElms.value
|
||||
if (!k.contains('+') && countAudiosInMap(v)>1) k += '+'
|
||||
def mQ = getMaxQuality(v)
|
||||
def mQstr = (mQ==null || mQ.isEmpty()) ? 'und' : printAudio(mQ)
|
||||
if (groupedAudiosMap.containsKey(mQstr)) groupedAudiosMap[mQstr].add(k)
|
||||
else groupedAudiosMap[mQstr] = [k]
|
||||
}
|
||||
audiosMap=null
|
||||
def temp=''
|
||||
for (audioGroup in groupedAudiosMap) {
|
||||
def k = audioGroup.key
|
||||
def v = audioGroup.value
|
||||
def gS = v.size()
|
||||
def str=''
|
||||
for (int i=0; i<gS; i++) {
|
||||
str += (v[i]!=null?v[i]:'und') +', '
|
||||
if (i==gS-1) {
|
||||
str = removeLastComa(str)+' '
|
||||
str += k+', '
|
||||
}
|
||||
}
|
||||
|
||||
if (audioDeclUndefined || (catalanAudios.isEmpty() && spanishAudios.isEmpty() && englishAudios.isEmpty() && otherAudios.isEmpty()) ) {
|
||||
if (!skipAudioCheck) throw new Exception("[idioma_audio_no_definido]")
|
||||
bloqueAudio += str
|
||||
}
|
||||
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+']'
|
||||
/***********/
|
||||
groupedAudiosMap=null
|
||||
bloqueAudio = '['+removeLastComa(bloqueAudio)
|
||||
|
||||
|
||||
/***** subtitulos *******/
|
||||
def bloqueSubs
|
||||
try {
|
||||
def capturedSubs = [:]
|
||||
bloqueSubs = ' [sub_ '
|
||||
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)+']'
|
||||
}catch(err){bloqueSubs=' [no sub]'}
|
||||
}catch(err){bloqueSubs=''}
|
||||
/************************/
|
||||
|
||||
|
||||
/**************************************/
|
||||
/**** Carpeta / tipo contenido *******/
|
||||
/*************************************************************************************************************/
|
||||
/**** Carpeta / tipo contenido ******************************************************************************/
|
||||
/*************************************************************************************************************/
|
||||
|
||||
def tipoYaSeteado=false
|
||||
|
||||
//animacion (no concluyente)
|
||||
|
@ -324,10 +300,10 @@ try { //empieza el script
|
|||
def tmdb = "{tmdb-"+tmdbid+"}"
|
||||
def carpetaPeli = localize.Spanish.plex.name + tmdb + '/'
|
||||
def nomPrincipal = nombrePelicula_formatoPlex + bloqueVideo + bloqueAudio + bloqueSubs
|
||||
def tracker = fn.find(/(?i)\bHDO(limpo)?\b|\bRedBits\b/)
|
||||
def extras = tracker != null ? ' ['+tracker.replace("HDOlimpo", "HDO")+']' : ''
|
||||
def trackerCatch = fn.find(/(?i)\bHDO(limpo)?\b|\bRedBits\b/)
|
||||
def tracker = trackerCatch != null ? '['+trackerCatch.replace("HDOlimpo", "HDO")+']' : ''
|
||||
|
||||
return ruta + inicial + carpetaPeli + nomPrincipal + extras + tmdb
|
||||
return ruta + inicial + carpetaPeli + nomPrincipal + tracker + tmdb
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
} catch (err) {
|
||||
|
||||
|
@ -377,15 +353,33 @@ try { //empieza el script
|
|||
/********************************************************/
|
||||
/********************************************************/
|
||||
|
||||
def getAudiosFromListByFormat (format, listAudios) {
|
||||
def result=[]
|
||||
for (singleAudio in listAudios) {
|
||||
if (singleAudio.Format==format) {
|
||||
result.add(singleAudio)
|
||||
if ("EAC3"==format) hayEAC3=true
|
||||
|
||||
/********* AUDIO *****************/
|
||||
def removeLastComa(txt) {
|
||||
return txt.substring(0, txt.size()-2)
|
||||
}
|
||||
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 bestChanel
|
||||
|
@ -398,37 +392,12 @@ def getBestChannelFromList (audiosFormatFound) {
|
|||
}
|
||||
return bestChanel
|
||||
}
|
||||
def getMaxQuality (listOfLanguageAudio) {
|
||||
def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"]
|
||||
for (cFormat in formatSet) {
|
||||
def audiosFormatFound = getAudiosFromListByFormat(cFormat, listOfLanguageAudio);
|
||||
if (!audiosFormatFound.isEmpty()) {
|
||||
return getBestChannelFromList(audiosFormatFound)
|
||||
def countAudiosInMap(audMap){
|
||||
int count=0
|
||||
for (aud in audMap) count += aud.value.size()
|
||||
return count
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
/********* SUBS ***************/
|
||||
def handleSub(sub, capturedSubs) {
|
||||
def lang = sub.Language_String != null ? sub.Language_String : sub.title
|
||||
def lang3 = sub.Language_String3 != null ? sub.Language_String3 : sub.title
|
||||
|
|
|
@ -128,13 +128,6 @@ def printAudio (audio2Print) {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def bloqueAudio2=''
|
||||
def audiosMap = [:]
|
||||
for (aud in audio) {
|
||||
|
@ -148,13 +141,14 @@ def groupedAudiosMap = [:]
|
|||
for (audioElms in audiosMap) {
|
||||
def k = audioElms.key
|
||||
def v = audioElms.value
|
||||
if (!k.contains('+') && countAudiosInMap(v)>1) k += '+'
|
||||
def mQ = getMaxQuality2(v)
|
||||
if (v.size()>1 && !k.contains('+')) k += '+'
|
||||
def mQstr = printAudio2(mQ)
|
||||
def mQstr = (mQ==null || mQ.isEmpty()) ? 'und' : printAudio2(mQ)
|
||||
if (groupedAudiosMap.containsKey(mQstr)) groupedAudiosMap[mQstr].add(k)
|
||||
else groupedAudiosMap[mQstr] = [k]
|
||||
}
|
||||
|
||||
|
||||
audiosMap=null
|
||||
def temp=''
|
||||
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"]
|
||||
for (cFormat in formatSet) {
|
||||
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 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").replace("TrueHD", "HD")
|
||||
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 getAudiosFromListByFormat2 (format, listAudios) {
|
||||
def result=[]
|
||||
for (singleAudio in listAudios) {
|
||||
if (singleAudio.Format==format) {
|
||||
result.add(singleAudio)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
def getBestChannelFromList2 (audiosFormatFound) {
|
||||
def bestChanel
|
||||
def currentValue=0
|
||||
|
@ -218,7 +207,11 @@ def getBestChannelFromList2 (audiosFormatFound) {
|
|||
}
|
||||
return bestChanel
|
||||
}
|
||||
|
||||
def countAudiosInMap(audMap){
|
||||
int count=0
|
||||
for (aud in audMap) count += aud.value.size()
|
||||
return count
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue