hot fixes
This commit is contained in:
parent
56edc8ae10
commit
f6b2070443
3 changed files with 40 additions and 50 deletions
|
|
@ -532,19 +532,12 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
||||||
|
|
||||||
|
|
||||||
fun getFormat(formats: List<Format>, type: Type, url: String? = null) : Format {
|
fun getFormat(formats: List<Format>, type: Type, url: String? = null) : Format {
|
||||||
val sortFormats = sharedPreferences.getBoolean("use_format_sorting", false)
|
|
||||||
|
|
||||||
when(type) {
|
when(type) {
|
||||||
Type.audio -> {
|
Type.audio -> {
|
||||||
return cloneFormat (
|
return cloneFormat (
|
||||||
try {
|
try {
|
||||||
val theFormats = formats.filter { it.vcodec.isBlank() || it.vcodec == "none" }
|
val theFormats = formats.filter { it.vcodec.isBlank() || it.vcodec == "none" }
|
||||||
|
FormatUtil(application).sortAudioFormats(theFormats).first()
|
||||||
if (sortFormats) {
|
|
||||||
FormatUtil(application).sortAudioFormats(theFormats).first()
|
|
||||||
}else {
|
|
||||||
theFormats.first()
|
|
||||||
}
|
|
||||||
}catch (e: Exception){
|
}catch (e: Exception){
|
||||||
formatUtil.getGenericAudioFormats(resources).first()
|
formatUtil.getGenericAudioFormats(resources).first()
|
||||||
}
|
}
|
||||||
|
|
@ -558,11 +551,7 @@ class DownloadViewModel(private val application: Application) : AndroidViewModel
|
||||||
formatUtil.getGenericVideoFormats(resources).sortedByDescending { it.filesize }
|
formatUtil.getGenericVideoFormats(resources).sortedByDescending { it.filesize }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortFormats) {
|
FormatUtil(application).sortVideoFormats(theFormats).first()
|
||||||
FormatUtil(application).sortVideoFormats(theFormats).first()
|
|
||||||
}else {
|
|
||||||
theFormats.first()
|
|
||||||
}
|
|
||||||
}catch (e: Exception){
|
}catch (e: Exception){
|
||||||
formatUtil.getGenericVideoFormats(resources).first()
|
formatUtil.getGenericVideoFormats(resources).first()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,31 +30,49 @@ class FormatUtil(private var context: Context) {
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
fun getAudioFormatImportance() : List<String> {
|
fun getAudioFormatImportance() : List<String> {
|
||||||
val itemValues = context.getStringArray(R.array.format_importance_audio_values).toMutableList()
|
if (sharedPreferences.getBoolean("use_format_sorting", false)) {
|
||||||
val orderPreferences = sharedPreferences.getString("format_importance_audio", itemValues.joinToString(","))!!.split(",").toMutableList()
|
val itemValues = context.getStringArray(R.array.format_importance_audio_values).toMutableList()
|
||||||
if (preferSmallerFormats) {
|
val orderPreferences = sharedPreferences.getString("format_importance_audio", itemValues.joinToString(","))!!.split(",").toMutableList()
|
||||||
orderPreferences.remove("file_size")
|
if (preferSmallerFormats) {
|
||||||
orderPreferences.add(0,"smallsize")
|
orderPreferences.remove("file_size")
|
||||||
}
|
orderPreferences.add(0,"smallsize")
|
||||||
|
}
|
||||||
|
|
||||||
val preferContainerOverCodec = sharedPreferences.getBoolean("prefer_container_over_codec_audio", false)
|
val preferContainerOverCodec = sharedPreferences.getBoolean("prefer_container_over_codec_audio", false)
|
||||||
if(preferContainerOverCodec) {
|
if(preferContainerOverCodec) {
|
||||||
orderPreferences.remove("codec")
|
orderPreferences.remove("codec")
|
||||||
}
|
}
|
||||||
|
|
||||||
return orderPreferences
|
return orderPreferences
|
||||||
|
}else {
|
||||||
|
val formatImportance = mutableListOf("codec", "container", "language")
|
||||||
|
if (sharedPreferences.getBoolean("prefer_smaller_formats", false)) {
|
||||||
|
formatImportance.add(0, "smallsize")
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatImportance
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
fun getVideoFormatImportance() : List<String> {
|
fun getVideoFormatImportance() : List<String> {
|
||||||
val itemValues = context.getStringArray(R.array.format_importance_video_values).toList()
|
if (sharedPreferences.getBoolean("use_format_sorting", false)) {
|
||||||
val orderPreferences = sharedPreferences.getString("format_importance_video", itemValues.joinToString(","))!!.split(",").toMutableList()
|
val itemValues = context.getStringArray(R.array.format_importance_video_values).toList()
|
||||||
if (preferSmallerFormats) {
|
val orderPreferences = sharedPreferences.getString("format_importance_video", itemValues.joinToString(","))!!.split(",").toMutableList()
|
||||||
orderPreferences.remove("file_size")
|
if (preferSmallerFormats) {
|
||||||
orderPreferences.add(0, "smallsize")
|
orderPreferences.remove("file_size")
|
||||||
}
|
orderPreferences.add(0, "smallsize")
|
||||||
|
}
|
||||||
|
|
||||||
return orderPreferences
|
return orderPreferences
|
||||||
|
}else {
|
||||||
|
val formatImportance = mutableListOf("resolution", "codec", "container")
|
||||||
|
if (sharedPreferences.getBoolean("prefer_smaller_formats", false)) {
|
||||||
|
formatImportance.add(0, "smallsize")
|
||||||
|
}
|
||||||
|
|
||||||
|
return formatImportance
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -822,16 +822,10 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
val ext = downloadItem.container
|
val ext = downloadItem.container
|
||||||
|
|
||||||
val formatSorting = mutableListOf<String>()
|
val formatSorting = mutableListOf<String>()
|
||||||
val formatImportance: MutableList<String>
|
val formatImportance = formatUtil.getAudioFormatImportance()
|
||||||
val useCustomFormatSorting = sharedPreferences.getBoolean("use_format_sorting", false)
|
val useCustomFormatSorting = sharedPreferences.getBoolean("use_format_sorting", false)
|
||||||
if (useCustomFormatSorting) {
|
if (useCustomFormatSorting) {
|
||||||
formatSorting.add("hasaud")
|
formatSorting.add("hasaud")
|
||||||
formatImportance = formatUtil.getAudioFormatImportance().toMutableList()
|
|
||||||
}else{
|
|
||||||
formatImportance = mutableListOf("codec", "container", "language")
|
|
||||||
if (sharedPreferences.getBoolean("prefer_smaller_formats", false)) {
|
|
||||||
formatImportance.add(0, "smallsize")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(order in formatImportance) {
|
for(order in formatImportance) {
|
||||||
|
|
@ -1126,19 +1120,8 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val preferredLanguage = sharedPreferences.getString("audio_language","")!!
|
val formatImportance = formatUtil.getVideoFormatImportance().toMutableList()
|
||||||
|
|
||||||
val formatImportance : MutableList<String>
|
|
||||||
val formatSorting = mutableListOf<String>()
|
val formatSorting = mutableListOf<String>()
|
||||||
val useCustomFormatSorting = sharedPreferences.getBoolean("use_format_sorting", false)
|
|
||||||
if (useCustomFormatSorting) {
|
|
||||||
formatImportance = formatUtil.getVideoFormatImportance().toMutableList()
|
|
||||||
}else {
|
|
||||||
formatImportance = mutableListOf("resolution", "codec", "container")
|
|
||||||
if (sharedPreferences.getBoolean("prefer_smaller_formats", false)) {
|
|
||||||
formatImportance.add(0, "smallsize")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(order in formatImportance) {
|
for(order in formatImportance) {
|
||||||
when(order) {
|
when(order) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue