Skip to content

Commit

Permalink
Choose audio stream with highest quality
Browse files Browse the repository at this point in the history
  • Loading branch information
0xf4b1 committed Aug 6, 2023
1 parent 0d746ca commit b3ca612
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/main/kotlin/sources/Youtube.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,7 @@ class Youtube : ISource {
private fun getAudioStream(url: String): String {
val extractor = ServiceList.YouTube.getStreamExtractor("https://www.youtube.com/watch?v=$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.filter { it.format!!.name == "m4a" }.maxBy { it.averageBitrate }.content
}

class Downloader : org.schabi.newpipe.extractor.downloader.Downloader() {
Expand Down

0 comments on commit b3ca612

Please sign in to comment.