try fix format update crash
This commit is contained in:
parent
12f99f781a
commit
63a7c1e2d0
4 changed files with 29 additions and 13 deletions
|
|
@ -54,12 +54,8 @@ class FormatAdapter(onItemClickListener: OnItemClickListener, activity: Activity
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemViewType(position: Int): Int {
|
override fun getItemViewType(position: Int): Int {
|
||||||
try {
|
val item = formats.getOrNull(position)
|
||||||
val isLabel = formats[position]!!.label != null
|
return if (item?.label != null) 0 else 1
|
||||||
return if (isLabel) 0 else 1
|
|
||||||
}catch (err: Exception) {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
|
@ -92,8 +88,8 @@ class FormatAdapter(onItemClickListener: OnItemClickListener, activity: Activity
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val item = itm.format!!
|
val item = itm.format ?: return
|
||||||
val card = holder.item!!
|
val card = holder.item ?: return
|
||||||
//card.popup()
|
//card.popup()
|
||||||
UiUtil.populateFormatCard(activity, card, item)
|
UiUtil.populateFormatCard(activity, card, item)
|
||||||
card.isChecked = selectedVideoFormat == item || selectedAudioFormats.any { it == item }
|
card.isChecked = selectedVideoFormat == item || selectedAudioFormats.any { it == item }
|
||||||
|
|
|
||||||
|
|
@ -688,12 +688,17 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
|
|
||||||
if (playerClients.isNotEmpty()){
|
if (playerClients.isNotEmpty()){
|
||||||
extractorArgs.add("player_client=${playerClients.joinToString(",")}")
|
extractorArgs.add("player_client=${playerClients.joinToString(",")}")
|
||||||
|
}else{
|
||||||
|
//TODO DISCUSS
|
||||||
|
//extractorArgs.add("player_client=default,-web,-web-safari,-android,-ios,-tv")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (poTokens.isNotEmpty() && sharedPreferences.getBoolean("use_cookies", false)) {
|
if (poTokens.isNotEmpty() && sharedPreferences.getBoolean("use_cookies", false)) {
|
||||||
extractorArgs.add("po_token=${poTokens.joinToString(",")}")
|
extractorArgs.add("po_token=${poTokens.joinToString(",")}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//extractorArgs.add("skip=translated_subs")
|
||||||
|
|
||||||
val useLanguageForMetadata = sharedPreferences.getBoolean("use_app_language_for_metadata", true)
|
val useLanguageForMetadata = sharedPreferences.getBoolean("use_app_language_for_metadata", true)
|
||||||
if (useLanguageForMetadata) {
|
if (useLanguageForMetadata) {
|
||||||
val lang = java.util.Locale.getDefault().language
|
val lang = java.util.Locale.getDefault().language
|
||||||
|
|
@ -853,6 +858,11 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
request.addOption("--proxy", proxy)
|
request.addOption("--proxy", proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val updateYTDLP = sharedPreferences.getBoolean("update_ytdlp_while_downloading", false)
|
||||||
|
if (updateYTDLP) {
|
||||||
|
request.addOption("-U")
|
||||||
|
}
|
||||||
|
|
||||||
val keepCache = sharedPreferences.getBoolean("keep_cache", false)
|
val keepCache = sharedPreferences.getBoolean("keep_cache", false)
|
||||||
if(keepCache){
|
if(keepCache){
|
||||||
request.addOption("--keep-fragments")
|
request.addOption("--keep-fragments")
|
||||||
|
|
|
||||||
|
|
@ -502,4 +502,6 @@
|
||||||
<string name="chapters">Chapters</string>
|
<string name="chapters">Chapters</string>
|
||||||
<string name="use_original_url_playlist">Use original url for playlist url</string>
|
<string name="use_original_url_playlist">Use original url for playlist url</string>
|
||||||
<string name="use_original_url_playlist_summary">Use playlist url given by user instead of the playlist_webpage_url tag from the json dump</string>
|
<string name="use_original_url_playlist_summary">Use playlist url given by user instead of the playlist_webpage_url tag from the json dump</string>
|
||||||
|
<string name="update_ytdlp_while_downloading">Update yt-dlp while downloading</string>
|
||||||
|
<string name="update_ytdlp_while_downloading_summary">Add -U to yt-dlp to update it to latest before downloading</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,6 @@
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<Preference
|
|
||||||
app:icon="@drawable/ic_info"
|
|
||||||
app:key="version"
|
|
||||||
app:title="@string/version"/>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/source">
|
<PreferenceCategory android:title="@string/source">
|
||||||
|
|
||||||
|
|
@ -34,10 +30,23 @@
|
||||||
android:key="auto_update_ytdlp"
|
android:key="auto_update_ytdlp"
|
||||||
app:title="@string/auto_update_ytdlp" />
|
app:title="@string/auto_update_ytdlp" />
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:widgetLayout="@layout/preferece_material_switch"
|
||||||
|
android:icon="@drawable/ic_update"
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="update_ytdlp_while_downloading"
|
||||||
|
android:summary="@string/update_ytdlp_while_downloading_summary"
|
||||||
|
android:title="@string/update_ytdlp_while_downloading" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/app">
|
<PreferenceCategory android:title="@string/app">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:icon="@drawable/ic_info"
|
||||||
|
app:key="version"
|
||||||
|
app:title="@string/version"/>
|
||||||
|
|
||||||
<SwitchPreferenceCompat
|
<SwitchPreferenceCompat
|
||||||
android:widgetLayout="@layout/preferece_material_switch"
|
android:widgetLayout="@layout/preferece_material_switch"
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
|
|
@ -65,7 +74,6 @@
|
||||||
app:title="@string/changelog" />
|
app:title="@string/changelog" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/format">
|
<PreferenceCategory android:title="@string/format">
|
||||||
<ListPreference
|
<ListPreference
|
||||||
android:defaultValue="filesize"
|
android:defaultValue="filesize"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue