add gif video container & add compatibility mode for recode video
This commit is contained in:
parent
aff25b31e2
commit
cacc871815
9 changed files with 185 additions and 25 deletions
|
|
@ -17,5 +17,6 @@ data class VideoPreferences (
|
|||
var alsoDownloadAsAudio: Boolean = false,
|
||||
var recodeVideo: Boolean = false,
|
||||
var liveFromStart: Boolean = false,
|
||||
var waitForVideoMinutes: Int = 0
|
||||
var waitForVideoMinutes: Int = 0,
|
||||
var compatibilityMode: Boolean = false
|
||||
) : Parcelable
|
||||
|
|
|
|||
|
|
@ -674,6 +674,15 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
items.forEach { it.videoPreferences.recodeVideo = checked }
|
||||
CoroutineScope(Dispatchers.IO).launch { items.forEach { downloadViewModel.updateDownload(it) } }
|
||||
},
|
||||
compatibilityModeClicked = { checked ->
|
||||
items.forEach {
|
||||
it.videoPreferences.compatibilityMode = checked
|
||||
if(checked) {
|
||||
it.container = "mkv"
|
||||
}
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { items.forEach { downloadViewModel.updateDownload(it) } }
|
||||
},
|
||||
alsoDownloadAsAudioClicked = {},
|
||||
extraCommandsClicked = {
|
||||
val callback = object : ExtraCommandsListener {
|
||||
|
|
@ -815,6 +824,16 @@ class DownloadMultipleBottomSheetDialog : BottomSheetDialogFragment(), Configure
|
|||
withContext(Dispatchers.IO){
|
||||
downloadViewModel.updateProcessingContainer(listAdapter.getCheckedItemsOrNull(), container.toString())
|
||||
}
|
||||
if (container == "gif") {
|
||||
val items = withContext(Dispatchers.IO){
|
||||
downloadViewModel.getProcessingDownloads(listAdapter.getCheckedItemsOrNull())
|
||||
}
|
||||
items.forEach {
|
||||
it.videoPreferences.removeAudio = true
|
||||
it.videoPreferences.recodeVideo = true
|
||||
}
|
||||
CoroutineScope(Dispatchers.IO).launch { items.forEach { downloadViewModel.updateDownload(it) } }
|
||||
}
|
||||
}
|
||||
setContainerText(container.toString())
|
||||
true
|
||||
|
|
|
|||
|
|
@ -307,7 +307,7 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
true
|
||||
}
|
||||
|
||||
container?.isEnabled = true
|
||||
container?.isEnabled = !downloadItem.videoPreferences.compatibilityMode
|
||||
containerAutoCompleteTextView?.setAdapter(
|
||||
ArrayAdapter(
|
||||
requireContext(),
|
||||
|
|
@ -318,6 +318,9 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
if (currentDownloadItem == null || !containers.contains(downloadItem.container.ifEmpty { getString(R.string.defaultValue) })){
|
||||
downloadItem.container = if (containerPreference == getString(R.string.defaultValue)) "" else containerPreference!!
|
||||
}
|
||||
if (downloadItem.videoPreferences.compatibilityMode) {
|
||||
container.editText?.setText("mkv")
|
||||
}
|
||||
containerAutoCompleteTextView!!.setText(
|
||||
downloadItem.container.ifEmpty { getString(R.string.defaultValue) },
|
||||
false)
|
||||
|
|
@ -326,9 +329,19 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
AdapterView.OnItemClickListener { _: AdapterView<*>?, _: View?, index: Int, _: Long ->
|
||||
downloadItem.container = containers[index]
|
||||
if (containers[index] == getString(R.string.defaultValue)) downloadItem.container = ""
|
||||
if (containers[index] == "gif") {
|
||||
view.findViewById<Chip>(R.id.adjust_audio).isEnabled = false
|
||||
downloadItem.videoPreferences.removeAudio = true
|
||||
view.findViewById<Chip>(R.id.recode_video).isEnabled = false
|
||||
downloadItem.videoPreferences.recodeVideo = true
|
||||
}else {
|
||||
view.findViewById<Chip>(R.id.adjust_audio).isEnabled = true
|
||||
downloadItem.videoPreferences.removeAudio = false
|
||||
view.findViewById<Chip>(R.id.recode_video).isEnabled = true
|
||||
downloadItem.videoPreferences.recodeVideo = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
view.findViewById<LinearLayout>(R.id.adjust).apply {
|
||||
visibility = if (shownFields.contains("adjust_video")) View.VISIBLE else View.GONE
|
||||
if (isVisible){
|
||||
|
|
@ -426,6 +439,14 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
recodeVideoClicked = {
|
||||
downloadItem.videoPreferences.recodeVideo = it
|
||||
},
|
||||
compatibilityModeClicked = {
|
||||
downloadItem.videoPreferences.compatibilityMode = it
|
||||
container.isEnabled = !it
|
||||
if (it) {
|
||||
container.editText?.setText("mkv")
|
||||
downloadItem.container = "mkv"
|
||||
}
|
||||
},
|
||||
alsoDownloadAsAudioClicked = {
|
||||
downloadItem.videoPreferences.alsoDownloadAsAudio = it
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1309,6 +1309,7 @@ object UiUtil {
|
|||
subtitleLanguagesSet: (String) -> Unit,
|
||||
removeAudioClicked: (Boolean) -> Unit,
|
||||
recodeVideoClicked: (Boolean) -> Unit,
|
||||
compatibilityModeClicked: (Boolean) -> Unit,
|
||||
alsoDownloadAsAudioClicked: (Boolean) -> Unit,
|
||||
extraCommandsClicked: () -> Unit,
|
||||
liveFromStart: (Boolean) -> Unit,
|
||||
|
|
@ -1414,7 +1415,7 @@ object UiUtil {
|
|||
adjustSubtitleDialog.show()
|
||||
}
|
||||
|
||||
if (items.size == 1 && items.first().id == 0L){
|
||||
if (items.size == 1){
|
||||
val adjustAudio = view.findViewById<Chip>(R.id.adjust_audio)
|
||||
adjustAudio.setOnClickListener {
|
||||
val adjustAudioView = context.layoutInflater.inflate(R.layout.audio_download_preferences_dialog, null)
|
||||
|
|
@ -1440,6 +1441,7 @@ object UiUtil {
|
|||
|
||||
adjustAudioDialog.show()
|
||||
}
|
||||
adjustAudio.isEnabled = items.first().container != "gif"
|
||||
}else{
|
||||
val adjustAudio = view.findViewById<Chip>(R.id.adjust_audio)
|
||||
adjustAudio.isVisible = false
|
||||
|
|
@ -1449,8 +1451,37 @@ object UiUtil {
|
|||
removeAudio.setOnCheckedChangeListener { _, _ ->
|
||||
removeAudioClicked(removeAudio.isChecked)
|
||||
}
|
||||
removeAudio.isEnabled = !items.any { it.container == "gif" }
|
||||
}
|
||||
|
||||
val recodeVideo = view.findViewById<Chip>(R.id.recode_video)
|
||||
recodeVideo.setOnClickListener {
|
||||
val adjustVideoView = context.layoutInflater.inflate(R.layout.video_download_preferences_dialog, null)
|
||||
adjustVideoView.findViewById<MaterialSwitch>(R.id.recodeVideoSwitch).apply {
|
||||
isChecked = items.all { it.videoPreferences.recodeVideo }
|
||||
setOnCheckedChangeListener { _, b ->
|
||||
recodeVideoClicked(b)
|
||||
}
|
||||
}
|
||||
|
||||
adjustVideoView.findViewById<MaterialSwitch>(R.id.compatiblityModeSwitch).apply {
|
||||
isChecked = items.first().videoPreferences.compatibilityMode
|
||||
setOnCheckedChangeListener { _, b ->
|
||||
compatibilityModeClicked(b)
|
||||
}
|
||||
}
|
||||
|
||||
val adjustVideoDialog = MaterialAlertDialogBuilder(context)
|
||||
.setTitle(context.getString(R.string.recode_video))
|
||||
.setView(adjustVideoView)
|
||||
.setIcon(R.drawable.ic_video)
|
||||
.setNegativeButton(context.resources.getString(R.string.dismiss)) { _: DialogInterface?, _: Int -> }
|
||||
|
||||
adjustVideoDialog.show()
|
||||
}
|
||||
recodeVideo.isEnabled = items.first().container != "gif"
|
||||
|
||||
|
||||
val adjustLiveStream = view.findViewById<Chip>(R.id.adjust_live_stream)
|
||||
if (items.size == 1) {
|
||||
adjustLiveStream.setOnClickListener {
|
||||
|
|
@ -1509,13 +1540,6 @@ object UiUtil {
|
|||
adjustLiveStream.isVisible = false
|
||||
}
|
||||
|
||||
val recodeVideo = view.findViewById<Chip>(R.id.recode_video)
|
||||
recodeVideo.isChecked = items.all { it.videoPreferences.recodeVideo }
|
||||
recodeVideo.setOnCheckedChangeListener { _, _ ->
|
||||
recodeVideoClicked(recodeVideo.isChecked)
|
||||
}
|
||||
|
||||
|
||||
val sponsorBlock = view.findViewById<Chip>(R.id.sponsorblock_filters)
|
||||
sponsorBlock.isEnabled = sharedPreferences.getBoolean("use_sponsorblock", true)
|
||||
sponsorBlock!!.setOnClickListener {
|
||||
|
|
|
|||
|
|
@ -1127,10 +1127,16 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
if (downloadItem.videoPreferences.recodeVideo && !cantRecode.contains(cont)) {
|
||||
request.addOption("--recode-video", outputContainer.lowercase())
|
||||
}else{
|
||||
request.addOption("--merge-output-format", outputContainer.lowercase())
|
||||
if (downloadItem.videoPreferences.compatibilityMode) {
|
||||
request.addOption("--recode-video", "mp4")
|
||||
request.addOption("--merge-output-format", "mkv")
|
||||
}
|
||||
else {
|
||||
request.addOption("--merge-output-format", outputContainer.lowercase())
|
||||
}
|
||||
}
|
||||
|
||||
if (!listOf("webm", "avi", "flv").contains(outputContainer.lowercase())) {
|
||||
if (!listOf("webm", "avi", "flv", "gif").contains(outputContainer.lowercase())) {
|
||||
val embedThumb = sharedPreferences.getBoolean("embed_thumbnail", false)
|
||||
if (embedThumb) {
|
||||
metadataCommands.addOption("--embed-thumbnail")
|
||||
|
|
@ -1350,12 +1356,9 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
request.addOption("--sub-langs", downloadItem.videoPreferences.subsLanguages.ifEmpty { "en.*,.*-orig" })
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (downloadItem.videoPreferences.removeAudio){
|
||||
if (downloadItem.videoPreferences.removeAudio && outputContainer != "gif") {
|
||||
request.addOption("--use-postprocessor", "FFmpegCopyStream")
|
||||
request.addOption("--ppa", "CopyStream:-c copy -an")
|
||||
|
||||
}
|
||||
|
||||
request.addOption("-P", downDir.absolutePath)
|
||||
|
|
|
|||
|
|
@ -109,6 +109,16 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/recode_video"
|
||||
style="@style/Widget.Material3.Chip.Filter.Elevated"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
app:chipIconVisible="true"
|
||||
app:chipIcon="@drawable/ic_video"
|
||||
android:text="@string/recode_video" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/adjust_live_stream"
|
||||
style="@style/Widget.Material3.Chip.Assist.Elevated"
|
||||
|
|
@ -169,14 +179,6 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.chip.Chip
|
||||
android:id="@+id/recode_video"
|
||||
style="@style/Widget.Material3.Chip.Filter.Elevated"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="false"
|
||||
android:text="@string/recode_video" />
|
||||
|
||||
</com.google.android.material.chip.ChipGroup>
|
||||
|
||||
</HorizontalScrollView>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recodeVideoTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/recode_video"
|
||||
android:textStyle="bold"
|
||||
android:textAppearance="?attr/textAppearanceBodyLarge"
|
||||
app:layout_constraintEnd_toStartOf="@+id/recodeVideoSwitch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/recodeVideoDescription"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/recode_video_summary"
|
||||
app:layout_constraintEnd_toStartOf="@+id/recodeVideoSwitch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/recodeVideoTitle" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/recodeVideoSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/compatiblityModeTitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/video_compatible"
|
||||
android:textStyle="bold"
|
||||
android:textAppearance="?attr/textAppearanceBodyLarge"
|
||||
app:layout_constraintEnd_toStartOf="@+id/compatiblityModeSwitch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/compatiblityModeDescription"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/video_compatible_summary"
|
||||
app:layout_constraintEnd_toStartOf="@+id/compatiblityModeSwitch"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/compatiblityModeTitle" />
|
||||
|
||||
<com.google.android.material.materialswitch.MaterialSwitch
|
||||
android:id="@+id/compatiblityModeSwitch"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="10dp"
|
||||
android:paddingEnd="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -29,6 +29,7 @@
|
|||
<item>mov</item>
|
||||
<item>avi</item>
|
||||
<item>flv</item>
|
||||
<item>gif</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="video_containers_values">
|
||||
|
|
@ -39,6 +40,7 @@
|
|||
<item>mov</item>
|
||||
<item>avi</item>
|
||||
<item>flv</item>
|
||||
<item>gif</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="video_formats">
|
||||
|
|
|
|||
|
|
@ -483,4 +483,6 @@
|
|||
<string name="reverse">Reverse</string>
|
||||
<string name="no_keep_subs">Delete subtitle files after embedding</string>
|
||||
<string name="no_keep_subs_summary">When using both Embed Subtitles and Write Subtitles, don\'t keep the subtitle files after embedding</string>
|
||||
<string name="video_compatible">Compatible Video</string>
|
||||
<string name="video_compatible_summary">Recodes the video making it compatible with other apps</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Reference in a new issue