From 8591c1058e5810cbed657ce09de69811234ac947 Mon Sep 17 00:00:00 2001 From: tiefensuche <10889432+tiefensuche@users.noreply.github.com> Date: Sat, 23 Dec 2023 16:00:29 +0100 Subject: [PATCH] Choose audio stream with highest quality --- .../com/tiefensuche/soundcrowd/plugins/youtube/Plugin.kt | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/youtube/src/main/java/com/tiefensuche/soundcrowd/plugins/youtube/Plugin.kt b/youtube/src/main/java/com/tiefensuche/soundcrowd/plugins/youtube/Plugin.kt index 625c87e..fc69a19 100644 --- a/youtube/src/main/java/com/tiefensuche/soundcrowd/plugins/youtube/Plugin.kt +++ b/youtube/src/main/java/com/tiefensuche/soundcrowd/plugins/youtube/Plugin.kt @@ -117,12 +117,7 @@ class Plugin(appContext: Context, context: Context) : IPlugin { private fun getAudioStream(url: String): String { val extractor = YouTube.getStreamExtractor(url) extractor.fetchPage() - for (stream in extractor.audioStreams) { - if (stream.format!!.getName() == "m4a") { - return stream.content.replace("signature", "sig") - } - } - throw IllegalStateException("no audio stream") + return extractor.audioStreams.maxBy { it.averageBitrate }.content } override fun getIcon(): Bitmap = icon