use match filter id for youtube playlist items instead if -I
This commit is contained in:
parent
9f82f43392
commit
2bf0d01648
5 changed files with 39 additions and 81 deletions
|
|
@ -142,7 +142,7 @@ class MoreFragment : Fragment() {
|
||||||
|
|
||||||
lateinit var dialog: AlertDialog
|
lateinit var dialog: AlertDialog
|
||||||
val terminateDialog = MaterialAlertDialogBuilder(requireContext())
|
val terminateDialog = MaterialAlertDialogBuilder(requireContext())
|
||||||
terminateDialog.setTitle(getString(R.string.confirm_terminate))
|
terminateDialog.setTitle(getString(R.string.kill_app))
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_terminate_app, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_terminate_app, null)
|
||||||
val checkbox = dialogView.findViewById<CheckBox>(R.id.doNotShowAgain)
|
val checkbox = dialogView.findViewById<CheckBox>(R.id.doNotShowAgain)
|
||||||
terminateDialog.setView(dialogView)
|
terminateDialog.setView(dialogView)
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,16 @@ class WebViewActivity : BaseActivity() {
|
||||||
private lateinit var cookies: String
|
private lateinit var cookies: String
|
||||||
private lateinit var webViewClient: AccompanistWebViewClient
|
private lateinit var webViewClient: AccompanistWebViewClient
|
||||||
private lateinit var preferences: SharedPreferences
|
private lateinit var preferences: SharedPreferences
|
||||||
|
|
||||||
|
private var incognito: Boolean = false
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
public override fun onCreate(savedInstanceState: Bundle?) {
|
public override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.webview_activity)
|
setContentView(R.layout.webview_activity)
|
||||||
url = intent.extras!!.getString("url")!!
|
url = intent.extras!!.getString("url")!!
|
||||||
|
incognito = intent.extras!!.getBoolean("incognito", false)
|
||||||
|
|
||||||
cookiesViewModel = ViewModelProvider(this)[CookieViewModel::class.java]
|
cookiesViewModel = ViewModelProvider(this)[CookieViewModel::class.java]
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val appbar = findViewById<AppBarLayout>(R.id.webview_appbarlayout)
|
val appbar = findViewById<AppBarLayout>(R.id.webview_appbarlayout)
|
||||||
|
|
@ -69,6 +74,8 @@ class WebViewActivity : BaseActivity() {
|
||||||
toolbar.menu.children.firstOrNull { it.itemId == R.id.get_data_sync_id }?.isVisible = false
|
toolbar.menu.children.firstOrNull { it.itemId == R.id.get_data_sync_id }?.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
toolbar.menu.children.firstOrNull { it.itemId == R.id.incognito }?.isChecked = incognito
|
||||||
|
|
||||||
toolbar.setOnMenuItemClickListener { m : MenuItem ->
|
toolbar.setOnMenuItemClickListener { m : MenuItem ->
|
||||||
when(m.itemId) {
|
when(m.itemId) {
|
||||||
R.id.get_data_sync_id -> {
|
R.id.get_data_sync_id -> {
|
||||||
|
|
@ -77,16 +84,8 @@ class WebViewActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.incognito -> {
|
R.id.incognito -> {
|
||||||
m.isChecked = !m.isChecked
|
intent.putExtra("incognito", !incognito)
|
||||||
webView.apply {
|
recreate()
|
||||||
if (this == null) {
|
|
||||||
m.isChecked = false
|
|
||||||
return@apply
|
|
||||||
}
|
|
||||||
|
|
||||||
configureIncognito(this, m.isChecked)
|
|
||||||
this.reload()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
R.id.desktop -> {
|
R.id.desktop -> {
|
||||||
m.isChecked = !m.isChecked
|
m.isChecked = !m.isChecked
|
||||||
|
|
@ -164,35 +163,6 @@ class WebViewActivity : BaseActivity() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun configureIncognito(webView: WebView, incognito: Boolean) {
|
|
||||||
if (!incognito) {
|
|
||||||
webView.settings.run {
|
|
||||||
cacheMode = WebSettings.LOAD_DEFAULT
|
|
||||||
domStorageEnabled = true
|
|
||||||
setGeolocationEnabled(true)
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
webView.settings.run {
|
|
||||||
cacheMode = WebSettings.LOAD_NO_CACHE
|
|
||||||
domStorageEnabled = false
|
|
||||||
setGeolocationEnabled(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (incognito) {
|
|
||||||
WebStorage.getInstance().deleteAllData()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (incognito) {
|
|
||||||
webView.apply {
|
|
||||||
clearHistory()
|
|
||||||
clearCache(true)
|
|
||||||
clearFormData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun configureDesktopMode(webView: WebView, desktop: Boolean) {
|
private fun configureDesktopMode(webView: WebView, desktop: Boolean) {
|
||||||
webView.settings.apply {
|
webView.settings.apply {
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
|
|
@ -225,8 +195,22 @@ class WebViewActivity : BaseActivity() {
|
||||||
captureBackPresses = false, factory = { context ->
|
captureBackPresses = false, factory = { context ->
|
||||||
WebView(context).apply {
|
WebView(context).apply {
|
||||||
settings.run {
|
settings.run {
|
||||||
|
if (!incognito) {
|
||||||
|
cacheMode = WebSettings.LOAD_DEFAULT
|
||||||
|
domStorageEnabled = true
|
||||||
|
setGeolocationEnabled(true)
|
||||||
|
}else {
|
||||||
|
cacheMode = WebSettings.LOAD_NO_CACHE
|
||||||
|
domStorageEnabled = false
|
||||||
|
setGeolocationEnabled(false)
|
||||||
|
WebStorage.getInstance().deleteAllData()
|
||||||
|
|
||||||
|
this@apply.clearHistory()
|
||||||
|
this@apply.clearCache(true)
|
||||||
|
this@apply.clearFormData()
|
||||||
|
}
|
||||||
|
|
||||||
javaScriptEnabled = true
|
javaScriptEnabled = true
|
||||||
domStorageEnabled = true
|
|
||||||
javaScriptCanOpenWindowsAutomatically = true
|
javaScriptCanOpenWindowsAutomatically = true
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
safeBrowsingEnabled = true
|
safeBrowsingEnabled = true
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,8 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
val appbar = findViewById<AppBarLayout>(R.id.webview_appbarlayout)
|
val appbar = findViewById<AppBarLayout>(R.id.webview_appbarlayout)
|
||||||
toolbar = appbar.findViewById(R.id.webviewToolbar)
|
toolbar = appbar.findViewById(R.id.webviewToolbar)
|
||||||
|
//hide incognito
|
||||||
|
toolbar.menu.findItem(1).isVisible = false
|
||||||
toolbar.setOnMenuItemClickListener { m : MenuItem ->
|
toolbar.setOnMenuItemClickListener { m : MenuItem ->
|
||||||
when(m.itemId) {
|
when(m.itemId) {
|
||||||
R.id.get_data_sync_id -> {
|
R.id.get_data_sync_id -> {
|
||||||
|
|
@ -71,13 +72,6 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
|
||||||
UiUtil.copyToClipboard(id.replace("\"", ""), this@PoTokenWebViewLoginActivity)
|
UiUtil.copyToClipboard(id.replace("\"", ""), this@PoTokenWebViewLoginActivity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
R.id.incognito -> {
|
|
||||||
m.isChecked = !m.isChecked
|
|
||||||
webView.apply {
|
|
||||||
configureIncognito(this, m.isChecked)
|
|
||||||
this.reload()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
R.id.desktop -> {
|
R.id.desktop -> {
|
||||||
m.isChecked = !m.isChecked
|
m.isChecked = !m.isChecked
|
||||||
webView.apply {
|
webView.apply {
|
||||||
|
|
@ -173,34 +167,6 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun configureIncognito(webView: WebView, incognito: Boolean) {
|
|
||||||
if (!incognito) {
|
|
||||||
webView.settings.run {
|
|
||||||
cacheMode = WebSettings.LOAD_DEFAULT
|
|
||||||
domStorageEnabled = true
|
|
||||||
setGeolocationEnabled(true)
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
webView.settings.run {
|
|
||||||
cacheMode = WebSettings.LOAD_NO_CACHE
|
|
||||||
domStorageEnabled = false
|
|
||||||
setGeolocationEnabled(false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (incognito) {
|
|
||||||
WebStorage.getInstance().deleteAllData()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (incognito) {
|
|
||||||
webView.apply {
|
|
||||||
clearHistory()
|
|
||||||
clearCache(true)
|
|
||||||
clearFormData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun configureDesktopMode(webView: WebView, desktop: Boolean) {
|
private fun configureDesktopMode(webView: WebView, desktop: Boolean) {
|
||||||
webView.settings.apply {
|
webView.settings.apply {
|
||||||
if (desktop) {
|
if (desktop) {
|
||||||
|
|
@ -232,11 +198,17 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
|
||||||
.padding(paddingValues)
|
.padding(paddingValues)
|
||||||
.fillMaxSize(),
|
.fillMaxSize(),
|
||||||
captureBackPresses = false, factory = { context ->
|
captureBackPresses = false, factory = { context ->
|
||||||
|
WebStorage.getInstance().deleteAllData()
|
||||||
WebView(context).apply {
|
WebView(context).apply {
|
||||||
webView = this
|
webView = this
|
||||||
|
clearHistory()
|
||||||
|
clearCache(true)
|
||||||
|
clearFormData()
|
||||||
settings.run {
|
settings.run {
|
||||||
|
cacheMode = WebSettings.LOAD_NO_CACHE
|
||||||
|
domStorageEnabled = false
|
||||||
|
setGeolocationEnabled(false)
|
||||||
javaScriptEnabled = true
|
javaScriptEnabled = true
|
||||||
domStorageEnabled = true
|
|
||||||
javaScriptCanOpenWindowsAutomatically = true
|
javaScriptCanOpenWindowsAutomatically = true
|
||||||
if (Build.VERSION.SDK_INT >= 26) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
safeBrowsingEnabled = true
|
safeBrowsingEnabled = true
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import com.deniscerri.ytdl.database.models.YoutubeGeneratePoTokenItem
|
||||||
import com.deniscerri.ytdl.database.models.YoutubePlayerClientItem
|
import com.deniscerri.ytdl.database.models.YoutubePlayerClientItem
|
||||||
import com.deniscerri.ytdl.database.viewmodel.DownloadViewModel
|
import com.deniscerri.ytdl.database.viewmodel.DownloadViewModel
|
||||||
import com.deniscerri.ytdl.database.viewmodel.ResultViewModel
|
import com.deniscerri.ytdl.database.viewmodel.ResultViewModel
|
||||||
|
import com.deniscerri.ytdl.util.Extensions.getIDFromYoutubeURL
|
||||||
import com.deniscerri.ytdl.util.Extensions.getIntByAny
|
import com.deniscerri.ytdl.util.Extensions.getIntByAny
|
||||||
import com.deniscerri.ytdl.util.Extensions.getStringByAny
|
import com.deniscerri.ytdl.util.Extensions.getStringByAny
|
||||||
import com.deniscerri.ytdl.util.Extensions.isURL
|
import com.deniscerri.ytdl.util.Extensions.isURL
|
||||||
|
|
@ -731,9 +732,8 @@ class YTDLPUtil(private val context: Context, private val commandTemplateDao: Co
|
||||||
}else{
|
}else{
|
||||||
isPlaylistItem = true
|
isPlaylistItem = true
|
||||||
YoutubeDLRequest(downloadItem.playlistURL!!).apply {
|
YoutubeDLRequest(downloadItem.playlistURL!!).apply {
|
||||||
if(downloadItem.playlistIndex == null){
|
if(downloadItem.playlistIndex == null || downloadItem.url.isYoutubeURL()){
|
||||||
val matchPortion = downloadItem.url.split("/").last().split("=").last().split("&").first()
|
request.addOption("--match-filter", "id~='${downloadItem.url.getIDFromYoutubeURL()}'")
|
||||||
request.addOption("--match-filter", "id~='${matchPortion}'")
|
|
||||||
}else{
|
}else{
|
||||||
request.addOption("-I", "${downloadItem.playlistIndex!!}:${downloadItem.playlistIndex}")
|
request.addOption("-I", "${downloadItem.playlistIndex!!}:${downloadItem.playlistIndex}")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="5dp"
|
||||||
android:text="@string/confirm_terminate"
|
android:text="@string/confirm_terminate"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
|
@ -16,6 +17,7 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:minWidth="0dp"
|
||||||
android:text="@string/dont_ask_again"/>
|
android:text="@string/dont_ask_again"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Loading…
Reference in a new issue