|
|
|
@ -27,7 +27,7 @@ class FormatUtil(private var context: Context) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("RestrictedApi")
|
|
|
|
@SuppressLint("RestrictedApi")
|
|
|
|
fun getAudioFormatImportance() : List<String> {
|
|
|
|
fun getAudioFormatImportance(forVideoDownload: Boolean) : List<String> {
|
|
|
|
val preferredFormatSize = sharedPreferences.getString("preferred_format_size", "")
|
|
|
|
val preferredFormatSize = sharedPreferences.getString("preferred_format_size", "")
|
|
|
|
|
|
|
|
|
|
|
|
if (sharedPreferences.getBoolean("use_format_sorting", false)) {
|
|
|
|
if (sharedPreferences.getBoolean("use_format_sorting", false)) {
|
|
|
|
@ -39,9 +39,11 @@ class FormatUtil(private var context: Context) {
|
|
|
|
orderPreferences.add(0,"smallsize")
|
|
|
|
orderPreferences.add(0,"smallsize")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val preferContainerOverCodec = sharedPreferences.getBoolean("prefer_container_over_codec_audio", false)
|
|
|
|
if(!forVideoDownload) {
|
|
|
|
if(preferContainerOverCodec) {
|
|
|
|
val preferContainerOverCodec = sharedPreferences.getBoolean("prefer_container_over_codec_audio", false)
|
|
|
|
orderPreferences.remove("codec")
|
|
|
|
if(preferContainerOverCodec) {
|
|
|
|
|
|
|
|
orderPreferences.remove("codec")
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return orderPreferences
|
|
|
|
return orderPreferences
|
|
|
|
@ -95,8 +97,8 @@ class FormatUtil(private var context: Context) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("RestrictedApi")
|
|
|
|
@SuppressLint("RestrictedApi")
|
|
|
|
fun sortAudioFormats(formats: List<Format>) : List<Format> {
|
|
|
|
fun sortAudioFormats(formats: List<Format>, forVideoDownload: Boolean = false) : List<Format> {
|
|
|
|
val orderPreferences = getAudioFormatImportance()
|
|
|
|
val orderPreferences = getAudioFormatImportance(forVideoDownload)
|
|
|
|
|
|
|
|
|
|
|
|
val comparator = Comparator<Format> { a, b ->
|
|
|
|
val comparator = Comparator<Format> { a, b ->
|
|
|
|
if ("prefer_drc" in orderPreferences) {
|
|
|
|
if ("prefer_drc" in orderPreferences) {
|
|
|
|
|