From e447c2a4e46d488fa4eb6fb4d5169b9cdea07362 Mon Sep 17 00:00:00 2001 From: Xavier Fontanet Date: Thu, 11 May 2023 19:11:48 +0200 Subject: [PATCH] bona jugada --- new audio test.groovy | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/new audio test.groovy b/new audio test.groovy index 262a4d3..4d003d5 100755 --- a/new audio test.groovy +++ b/new audio test.groovy @@ -122,13 +122,28 @@ def printAudio (audio2Print) { /***********/ /*********************************************************/ + + + + + + + + + + + + + def bloqueAudio2='' def audiosMap = [:] for (aud in audio) { def shortDesc = aud.Language_String3 - if (audiosMap.containsKey(shortDesc)) audiosMap[shortDesc].add(aud) - else audiosMap[shortDesc] = [aud] + audiosMap[shortDesc] = audiosMap[shortDesc] ?: [:] + audiosMap[shortDesc][aud.Format] = audiosMap[shortDesc][aud.Format] ?: [] + audiosMap[shortDesc][aud.Format] << aud } + def groupedAudiosMap = [:] for (audioElms in audiosMap) { def k = audioElms.key @@ -139,6 +154,7 @@ for (audioElms in audiosMap) { if (groupedAudiosMap.containsKey(mQstr)) groupedAudiosMap[mQstr].add(k) else groupedAudiosMap[mQstr] = [k] } + audiosMap=null def temp='' for (audioGroup in groupedAudiosMap) { @@ -163,13 +179,12 @@ bloqueAudio2 = removeLastComa(bloqueAudio2) def removeLastComa(txt) { return txt.substring(0, txt.size()-2) } -def getMaxQuality2 (listOfLanguageAudio) { - def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"] +def getMaxQuality2 (mapAudioIndexedByFormat) { + def formatSet = ["PCM", "MLP FBA" ,"DTS", "FLAC", "AC-3", "E-AC-3", "EAC3", "AAC", "MPEG Audio", "MP3"] for (cFormat in formatSet) { - def audiosFormatFound = getAudiosFromListByFormat2(cFormat, listOfLanguageAudio); - if (!audiosFormatFound.isEmpty()) { - return getBestChannelFromList2(audiosFormatFound) - } + if (mapAudioIndexedByFormat.containsKey(cFormat)){ + return getBestChannelFromList2(mapAudioIndexedByFormat[cFormat]) + } } } @@ -205,4 +220,9 @@ def getBestChannelFromList2 (audiosFormatFound) { } + + + + +/************************/ return bloqueAudio + ' vs [' + bloqueAudio2 + ']' \ No newline at end of file