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 title : TextInputLayout
|
||||||
lateinit var author : TextInputLayout
|
lateinit var author : TextInputLayout
|
||||||
lateinit var preferences: SharedPreferences
|
lateinit var preferences: SharedPreferences
|
||||||
lateinit var shownFields: List<String>
|
private lateinit var shownFields: List<String>
|
||||||
|
|
||||||
|
private var disabledCutClicked: Boolean = false
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
|
|
@ -341,6 +344,7 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
|
||||||
resultItem?.apply {
|
resultItem?.apply {
|
||||||
val rsVM = ViewModelProvider(requireActivity())[ResultViewModel::class.java]
|
val rsVM = ViewModelProvider(requireActivity())[ResultViewModel::class.java]
|
||||||
rsVM.updateItemData(this)
|
rsVM.updateItemData(this)
|
||||||
|
disabledCutClicked = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -375,6 +379,12 @@ class DownloadAudioFragment(private var resultItem: ResultItem? = null, private
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
super.onViewCreated(view, savedInstanceState)
|
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
|
resultItem = res
|
||||||
val state = Bundle()
|
val state = Bundle()
|
||||||
state.putBoolean("updated", true)
|
state.putBoolean("updated", true)
|
||||||
|
if (disabledCutClicked) {
|
||||||
|
state.putBoolean("click_cut", true)
|
||||||
|
disabledCutClicked = false
|
||||||
|
}
|
||||||
onViewCreated(requireView(),savedInstanceState = state)
|
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.FormatUtil
|
||||||
import com.deniscerri.ytdl.util.UiUtil
|
import com.deniscerri.ytdl.util.UiUtil
|
||||||
import com.google.android.material.card.MaterialCardView
|
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.snackbar.Snackbar
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
import com.google.android.material.textfield.TextInputLayout.END_ICON_CUSTOM
|
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
|
lateinit var downloadItem: DownloadItem
|
||||||
|
|
||||||
|
private var disabledCutClicked: Boolean = false
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("RestrictedApi")
|
@SuppressLint("RestrictedApi")
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
|
@ -371,6 +374,7 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
||||||
resultItem?.apply {
|
resultItem?.apply {
|
||||||
val rsVM = ViewModelProvider(requireActivity())[ResultViewModel::class.java]
|
val rsVM = ViewModelProvider(requireActivity())[ResultViewModel::class.java]
|
||||||
rsVM.updateItemData(this)
|
rsVM.updateItemData(this)
|
||||||
|
disabledCutClicked = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -444,6 +448,12 @@ class DownloadVideoFragment(private var resultItem: ResultItem? = null, private
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
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
|
resultItem = res
|
||||||
val state = Bundle()
|
val state = Bundle()
|
||||||
state.putBoolean("updated", true)
|
state.putBoolean("updated", true)
|
||||||
|
if (disabledCutClicked) {
|
||||||
|
state.putBoolean("click_cut", true)
|
||||||
|
disabledCutClicked = false
|
||||||
|
}
|
||||||
onViewCreated(requireView(),savedInstanceState = state)
|
onViewCreated(requireView(),savedInstanceState = state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ class FormatSelectionBottomSheetDialog(
|
||||||
requireActivity()
|
requireActivity()
|
||||||
)
|
)
|
||||||
recyclerView = view.findViewById(R.id.recyclerView)
|
recyclerView = view.findViewById(R.id.recyclerView)
|
||||||
recyclerView.layoutManager = GridLayoutManager(context, resources.getInteger(R.integer.grid_size))
|
recyclerView.layoutManager = GridLayoutManager(context, 1)
|
||||||
recyclerView.adapter = adapter
|
recyclerView.adapter = adapter
|
||||||
|
|
||||||
refreshBtn = view.findViewById(R.id.format_refresh)
|
refreshBtn = view.findViewById(R.id.format_refresh)
|
||||||
|
|
|
||||||
|
|
@ -2210,7 +2210,10 @@ object UiUtil {
|
||||||
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
bottomSheet.requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||||
bottomSheet.setContentView(R.layout.ytdlp_sources_list)
|
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)!!
|
val parentView = bottomSheet.findViewById<LinearLayout>(R.id.sourcesList)!!
|
||||||
|
|
||||||
bottomSheet.findViewById<View>(R.id.add)?.apply {
|
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() })
|
request.applyDefaultOptionsForFetchingData(urls.firstOrNull { it.isURL() })
|
||||||
if (urls.all { it.isYoutubeURL() }) {
|
if (urls.all { it.isYoutubeURL() }) {
|
||||||
request.setYoutubeExtractorArgs(urls[0])
|
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)
|
val txt = parseYTDLRequestString(request)
|
||||||
println(txt)
|
println(txt)
|
||||||
|
|
@ -388,26 +391,24 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
urlIdx++
|
urlIdx++
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.message?.split(System.lineSeparator())?.apply {
|
e.message?.split(System.lineSeparator())?.onEach { line ->
|
||||||
this.forEach { line ->
|
println(line)
|
||||||
println(line)
|
if (line.contains("unavailable")) {
|
||||||
if (line.contains("unavailable")) {
|
kotlin.runCatching {
|
||||||
kotlin.runCatching {
|
val id = Regex("""\[.*?\] (\w+):""").find(line)!!.groupValues[1]
|
||||||
val id = Regex("""\[.*?\] (\w+):""").find(line)!!.groupValues[1]
|
val url = urls.first { it.contains(id) }
|
||||||
val url = urls.first { it.contains(id) }
|
progress(
|
||||||
progress(
|
ResultViewModel.MultipleFormatProgress(
|
||||||
ResultViewModel.MultipleFormatProgress(
|
url,
|
||||||
url,
|
listOf(),
|
||||||
listOf(),
|
true,
|
||||||
true,
|
line
|
||||||
line
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
delay(500)
|
)
|
||||||
}
|
delay(500)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.post {
|
handler.post {
|
||||||
|
|
@ -430,7 +431,10 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
request.applyDefaultOptionsForFetchingData(url)
|
request.applyDefaultOptionsForFetchingData(url)
|
||||||
if (url.isYoutubeURL()) {
|
if (url.isYoutubeURL()) {
|
||||||
request.setYoutubeExtractorArgs(url)
|
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 res = YoutubeDL.getInstance().execute(request)
|
||||||
val results: Array<String?> = try {
|
val results: Array<String?> = try {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue