more fixes
This commit is contained in:
parent
1c69165e24
commit
476220b3c6
5 changed files with 55 additions and 20 deletions
|
|
@ -64,7 +64,10 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
|
|||
lateinit var title : TextInputLayout
|
||||
lateinit var author : TextInputLayout
|
||||
lateinit var preferences: SharedPreferences
|
||||
lateinit var shownFields: List<String>
|
||||
private lateinit var shownFields: List<String>
|
||||
|
||||
private var disabledCutClicked: Boolean = false
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
|
|
@ -341,6 +344,7 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
|
|||
resultItem?.apply {
|
||||
val rsVM = ViewModelProvider(requireActivity())[ResultViewModel::class.java]
|
||||
rsVM.updateItemData(this)
|
||||
disabledCutClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -375,6 +379,12 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
|
|||
e.printStackTrace()
|
||||
}
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
view.findViewById<Chip>(R.id.cut).apply {
|
||||
if (this.isEnabled && savedInstanceState?.containsKey("click_cut") == true) {
|
||||
this.performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -401,6 +411,10 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
|
|||
resultItem = res
|
||||
val state = Bundle()
|
||||
state.putBoolean("updated", true)
|
||||
if (disabledCutClicked) {
|
||||
state.putBoolean("click_cut", true)
|
||||
disabledCutClicked = false
|
||||
}
|
||||
onViewCreated(requireView(),savedInstanceState = state)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import com.deniscerri.ytdl.util.FileUtil
|
|||
import com.deniscerri.ytdl.util.FormatUtil
|
||||
import com.deniscerri.ytdl.util.UiUtil
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.chip.Chip
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.textfield.TextInputLayout
|
||||
import com.google.android.material.textfield.TextInputLayout.END_ICON_CUSTOM
|
||||
|
|
@ -68,6 +69,8 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
|
||||
lateinit var downloadItem: DownloadItem
|
||||
|
||||
private var disabledCutClicked: Boolean = false
|
||||
|
||||
|
||||
@SuppressLint("RestrictedApi")
|
||||
override fun onCreateView(
|
||||
|
|
@ -371,6 +374,7 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
resultItem?.apply {
|
||||
val rsVM = ViewModelProvider(requireActivity())[ResultViewModel::class.java]
|
||||
rsVM.updateItemData(this)
|
||||
disabledCutClicked = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -444,6 +448,12 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
view.findViewById<Chip>(R.id.cut).apply {
|
||||
if (this.isEnabled && savedInstanceState?.containsKey("click_cut") == true) {
|
||||
this.performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -460,6 +470,10 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
|||
resultItem = res
|
||||
val state = Bundle()
|
||||
state.putBoolean("updated", true)
|
||||
if (disabledCutClicked) {
|
||||
state.putBoolean("click_cut", true)
|
||||
disabledCutClicked = false
|
||||
}
|
||||
onViewCreated(requireView(),savedInstanceState = state)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class FormatSelectionBottomSheetDialog(
|
|||
requireActivity()
|
||||
)
|
||||
recyclerView = view.findViewById(R.id.recyclerView)
|
||||
recyclerView.layoutManager = GridLayoutManager(context, resources.getInteger(R.integer.grid_size))
|
||||
recyclerView.layoutManager = GridLayoutManager(context, 1)
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
refreshBtn = view.findViewById(R.id.format_refresh)
|
||||
|
|
|
|||
|
|
@ -2210,7 +2210,10 @@ object UiUtil {
|
|||
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
bottomSheet.setContentView(R.layout.ytdlp_sources_list)
|
||||
|
||||
val list = preferences.getStringSet("custom_ytdlp_sources", emptySet())!!.toMutableList()
|
||||
val list = kotlin.runCatching {
|
||||
preferences.getStringSet("custom_ytdlp_sources", emptySet())!!.toMutableList()
|
||||
}.getOrDefault(mutableListOf<String>())
|
||||
|
||||
val parentView = bottomSheet.findViewById<LinearLayout>(R.id.sourcesList)!!
|
||||
|
||||
bottomSheet.findViewById<View>(R.id.add)?.apply {
|
||||
|
|
|
|||
|
|
@ -358,7 +358,10 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
request.applyDefaultOptionsForFetchingData(urls.firstOrNull { it.isURL() })
|
||||
if (urls.all { it.isYoutubeURL() }) {
|
||||
request.setYoutubeExtractorArgs(urls[0])
|
||||
request.addOption("--extractor-args", "youtube:player_skip=initial_data,webpage")
|
||||
request.addOption("--extractor-args", "youtubetab:skip=webpage")
|
||||
}
|
||||
if (!request.hasOption("--no-check-certificates")) request.addOption("--no-check-certificates")
|
||||
|
||||
val txt = parseYTDLRequestString(request)
|
||||
println(txt)
|
||||
|
|
@ -388,26 +391,24 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
urlIdx++
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.message?.split(System.lineSeparator())?.apply {
|
||||
this.forEach { line ->
|
||||
println(line)
|
||||
if (line.contains("unavailable")) {
|
||||
kotlin.runCatching {
|
||||
val id = Regex("""\[.*?\] (\w+):""").find(line)!!.groupValues[1]
|
||||
val url = urls.first { it.contains(id) }
|
||||
progress(
|
||||
ResultViewModel.MultipleFormatProgress(
|
||||
url,
|
||||
listOf(),
|
||||
true,
|
||||
line
|
||||
)
|
||||
e.message?.split(System.lineSeparator())?.onEach { line ->
|
||||
println(line)
|
||||
if (line.contains("unavailable")) {
|
||||
kotlin.runCatching {
|
||||
val id = Regex("""\[.*?\] (\w+):""").find(line)!!.groupValues[1]
|
||||
val url = urls.first { it.contains(id) }
|
||||
progress(
|
||||
ResultViewModel.MultipleFormatProgress(
|
||||
url,
|
||||
listOf(),
|
||||
true,
|
||||
line
|
||||
)
|
||||
delay(500)
|
||||
}
|
||||
)
|
||||
delay(500)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
handler.post {
|
||||
|
|
@ -430,7 +431,10 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
|||
request.applyDefaultOptionsForFetchingData(url)
|
||||
if (url.isYoutubeURL()) {
|
||||
request.setYoutubeExtractorArgs(url)
|
||||
request.addOption("--extractor-args", "youtube:player_skip=initial_data,webpage")
|
||||
request.addOption("--extractor-args", "youtubetab:skip=webpage")
|
||||
}
|
||||
if (!request.hasOption("--no-check-certificates")) request.addOption("--no-check-certificates")
|
||||
|
||||
val res = YoutubeDL.getInstance().execute(request)
|
||||
val results: Array<String?> = try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue