pull/765/head
deniscerri 1 year ago
parent 0931e33b6c
commit f47e05b9f8
No known key found for this signature in database
GPG Key ID: 95C43D517D830350

@ -4,25 +4,32 @@
# What's Changed
## Automatically generate PO Tokens & Visitor Data with NewPipe Extractor
## Automatically generate WEB PO Tokens & Visitor Data inside the app
Thanks to NewPipe Extractor for allowing the use of Po Token Generators, and some references from LibreTube, the app now has a po token generator using webview. Now all NewPipe actions like data fetching and format fetching will work.
Also at the same time these records are stored in the apps preferences. In advanced settings now there is a toggle to enable the use of the tokens in yt-dlp.
These tokens need visitor data to work and since visitor data and cookies cant be used at the same time, cookies will be disabled if you enable this function.
With it, the app will apply these settings as youtube extractor arguments
Since youtube is enforcing a policy that sessions need po tokens, you might need them to appear more legitimate and not get errors like 403, or even unlock formats that need po tokens.
With some references from LibreTube and OuterTune, the app now has a po token generator using it's WebView.
These records are stored in the apps preferences. In advanced settings now there is a toggle to enable the use of the tokens in yt-dlp.
Some formats need PO Token to show up like HIGH AUDIO, you will need to log in with cookies and then generate the tokens. There is also the option to use visitor data but you need to disable cookies.
yt-dlp doesn't recommend using it but the option is there if u need it.
The app will apply these settings as youtube extractor arguments
youtube:player_client=web;po_token=web.gvs+GVS_TOKEN,web.player+PLAYER_TOKEN;player-skip=webpage,configs;visitor_data=VISITOR_DATA
If you have po tokens set up with web client with po token, there might be duplication happening, so check that out.
Also since these tokens work for any web client, there is also an option to select which web clients to include as extractor arguments.
Other stuff
- Cut Section has been reworked,thanks to madmini. Now you can cut down to milliseconds.
- Added safeBrowsingEnabled in WebView for generating cookies for devices of API 26 and above. Thought to generate incognito cookies that last longer
- Added feature to reset all settings belonging to a certain preference page
- Added option to turn off the code color highlighter
- Fixed app not applying prefer small formats. It shouldve been last in format sorting not first.
- Fixed app not applying prefer small sized formats. It should've been last in format sorting not first.
- Added ability to enable automatic backup when the app checks for new update and finds one
- Added write-subs and write-auto-subs and --compat-options no-keep-subs when the user embeds subs but doesnt want to save them so he can get more subtitles to embed
- Turned the changelog dialog to a separate screen for better visibility
- Added --external-downloader-args aria2c:"--check-certificate=false" to fix aria2 not working
- Added bitrate info for audio formats card in the download card
- Some small bug fix here and there
> # 1.8.2.2 (2025-02)

@ -15,12 +15,8 @@ class CookieRepository(private val cookieDao: CookieDao) {
return cookieDao.getByURL(url)
}
suspend fun insert(item: CookieItem) : Long{
if (! cookieDao.checkIfExistsWithSameURL(item.url)){
return cookieDao.insert(item)
}
return -1
suspend fun insert(item: CookieItem) : Long {
return cookieDao.insert(item)
}
suspend fun delete(item: CookieItem){

@ -53,11 +53,18 @@ class CookieViewModel(private val application: Application) : AndroidViewModel(a
return repository.getAll()
}
fun getByURL(url: String) : CookieItem? {
private fun getByURL(url: String) : CookieItem? {
return repository.getByURL(url)
}
suspend fun insert(item: CookieItem) : Long {
val exists = getByURL(item.url)
if (exists != null) {
exists.content = item.content
repository.update(exists)
return exists.id
}
return repository.insert(item)
}

@ -2,10 +2,12 @@ package com.deniscerri.ytdl.ui.more.settings.advanced.generateyoutubepotokens.we
import android.annotation.SuppressLint
import android.content.Intent
import android.content.SharedPreferences
import android.os.Build
import android.os.Bundle
import android.webkit.CookieManager
import android.webkit.WebView
import android.widget.Toast
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
@ -14,8 +16,12 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.ComposeView
import androidx.core.view.forEach
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager
import com.deniscerri.ytdl.R
import com.deniscerri.ytdl.database.models.CookieItem
import com.deniscerri.ytdl.database.viewmodel.CookieViewModel
import com.deniscerri.ytdl.ui.BaseActivity
import com.deniscerri.ytdl.ui.more.settings.advanced.generateyoutubepotokens.PoTokenGenerator
import com.google.accompanist.web.AccompanistWebChromeClient
@ -37,6 +43,8 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
private lateinit var generateBtn: MaterialButton
private lateinit var cookieManager: CookieManager
private lateinit var webViewClient: AccompanistWebViewClient
private lateinit var cookiesViewModel: CookieViewModel
private lateinit var preferences: SharedPreferences
private val sampleVideoID = "aqz-KE-bpKQ" //Big Buck Bunny
@ -44,6 +52,8 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.webview_activity)
cookiesViewModel = ViewModelProvider(this)[CookieViewModel::class.java]
lifecycleScope.launch {
val appbar = findViewById<AppBarLayout>(R.id.webview_appbarlayout)
toolbar = appbar.findViewById(R.id.webviewToolbar)
@ -53,6 +63,8 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
webViewCompose = findViewById(R.id.webview_compose)
cookieManager = CookieManager.getInstance()
preferences = PreferenceManager.getDefaultSharedPreferences(this@PoTokenWebViewLoginActivity)
webViewClient = object : AccompanistWebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
@ -85,6 +97,35 @@ class PoTokenWebViewLoginActivity : BaseActivity() {
setResult(RESULT_OK, intent)
}
//update cookies
withContext(Dispatchers.IO) {
val url = "https://youtube.com"
cookiesViewModel.getCookiesFromDB(url).getOrNull()?.let {
kotlin.runCatching {
cookiesViewModel.insert(
CookieItem(
0,
url,
it
)
)
cookiesViewModel.updateCookiesFile()
}.onFailure {
withContext(Dispatchers.Main) {
Toast.makeText(
this@PoTokenWebViewLoginActivity,
"Tokens were generated but cookies were not updated",
Toast.LENGTH_SHORT
).show()
}
}
}
}
preferences.edit().putBoolean("use_cookies", true).apply()
webView.clearCache(true)
// ensures that the WebView isn't doing anything when destroying it
webView.loadUrl("about:blank")

@ -474,5 +474,5 @@
<string name="write_subs_when_embed_subs_summary">This will apply Save Subtitles and Save Automatic Subtitles to download the sub files and then delete them after embedding</string>
<string name="generate_potokens">Generate PO Tokens</string>
<string name="regenerate">Re-generate</string>
<string name="generate_potokens_warning">* By enabling this, you need to disable cookies. If you want to keep using cookies, fill in the Data Sync ID Extractor Argument</string>
<string name="generate_potokens_warning">* By enabling this, you need to disable cookies</string>
</resources>

@ -1,6 +1,6 @@
# What's Changed
- Added ability to automatically generate Po Tokens and Visitor Data through NewPipe Extractor
- Added ability to automatically generate Po Tokens and Visitor Data
- Fixed auto resume not working #727
- Applied "Prefer Container over Codec" preference on default format sorting
- Added automatic Backup

Loading…
Cancel
Save