Skip to content

Commit dde8b5f

Browse files
committed
Wrap logs in BuildConfig.DEBUG
1 parent 8433203 commit dde8b5f

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

app/src/main/java/org/schabi/newpipe/util/potoken/PoTokenProviderImpl.kt

+10-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.os.Handler
44
import android.os.Looper
55
import android.util.Log
66
import org.schabi.newpipe.App
7+
import org.schabi.newpipe.BuildConfig
78
import org.schabi.newpipe.extractor.NewPipe
89
import org.schabi.newpipe.extractor.services.youtube.PoTokenProvider
910
import org.schabi.newpipe.extractor.services.youtube.PoTokenResult
@@ -39,7 +40,7 @@ object PoTokenProviderImpl : PoTokenProvider {
3940
val (poTokenGenerator, visitorData, streamingPot, hasBeenRecreated) =
4041
synchronized(WebPoTokenGenLock) {
4142
val shouldRecreate = webPoTokenGenerator == null || forceRecreate ||
42-
webPoTokenGenerator!!.isExpired()
43+
webPoTokenGenerator!!.isExpired()
4344

4445
if (shouldRecreate) {
4546
// close the current webPoTokenGenerator on the main thread
@@ -84,7 +85,14 @@ object PoTokenProviderImpl : PoTokenProvider {
8485
}
8586
}
8687

87-
Log.e(TAG, "success($videoId) $playerPot,web.gvs+$streamingPot;visitor_data=$visitorData")
88+
if (BuildConfig.DEBUG) {
89+
Log.d(
90+
TAG,
91+
"poToken for $videoId: playerPot=$playerPot, " +
92+
"streamingPot=$streamingPot, visitor_data=$visitorData"
93+
)
94+
}
95+
8896
return PoTokenResult(visitorData, playerPot, streamingPot)
8997
}
9098

app/src/main/java/org/schabi/newpipe/util/potoken/PoTokenWebView.kt

+17-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import io.reactivex.rxjava3.core.Single
1313
import io.reactivex.rxjava3.core.SingleEmitter
1414
import io.reactivex.rxjava3.disposables.CompositeDisposable
1515
import io.reactivex.rxjava3.schedulers.Schedulers
16+
import org.schabi.newpipe.BuildConfig
1617
import org.schabi.newpipe.DownloaderImpl
1718
import java.time.Instant
1819

@@ -100,7 +101,9 @@ class PoTokenWebView private constructor(
100101
*/
101102
@JavascriptInterface
102103
fun onJsInitializationError(error: String) {
103-
Log.e(TAG, "Initialization error from JavaScript: $error")
104+
if (BuildConfig.DEBUG) {
105+
Log.e(TAG, "Initialization error from JavaScript: $error")
106+
}
104107
onInitializationErrorCloseAndCancel(PoTokenException(error))
105108
}
106109

@@ -110,12 +113,16 @@ class PoTokenWebView private constructor(
110113
*/
111114
@JavascriptInterface
112115
fun onRunBotguardResult(botguardResponse: String) {
113-
Log.e(TAG, "botguardResponse: $botguardResponse")
116+
if (BuildConfig.DEBUG) {
117+
Log.d(TAG, "botguardResponse: $botguardResponse")
118+
}
114119
makeJnnPaGoogleapisRequest(
115120
"https://jnn-pa.googleapis.com/\$rpc/google.internal.waa.v1.Waa/GenerateIT",
116121
"[ \"$REQUEST_KEY\", \"$botguardResponse\" ]",
117122
) { responseBody ->
118-
Log.e(TAG, "GenerateIT response: $responseBody")
123+
if (BuildConfig.DEBUG) {
124+
Log.d(TAG, "GenerateIT response: $responseBody")
125+
}
119126
webView.evaluateJavascript(
120127
"""(async function() {
121128
try {
@@ -194,7 +201,9 @@ class PoTokenWebView private constructor(
194201
*/
195202
@JavascriptInterface
196203
fun onObtainPoTokenError(identifier: String, error: String) {
197-
Log.e(TAG, "obtainPoToken error from JavaScript: $error")
204+
if (BuildConfig.DEBUG) {
205+
Log.e(TAG, "obtainPoToken error from JavaScript: $error")
206+
}
198207
popPoTokenEmitter(identifier)?.onError(PoTokenException(error))
199208
}
200209

@@ -204,8 +213,9 @@ class PoTokenWebView private constructor(
204213
*/
205214
@JavascriptInterface
206215
fun onObtainPoTokenResult(identifier: String, poToken: String) {
207-
Log.e(TAG, "identifier=$identifier")
208-
Log.e(TAG, "poToken=$poToken")
216+
if (BuildConfig.DEBUG) {
217+
Log.d(TAG, "Generated poToken: identifier=$identifier poToken=$poToken")
218+
}
209219
popPoTokenEmitter(identifier)?.onSuccess(poToken)
210220
}
211221

@@ -298,7 +308,7 @@ class PoTokenWebView private constructor(
298308
private const val GOOGLE_API_KEY = "AIzaSyDyT5W0Jh49F30Pqqtyfdf7pDLFKLJoAnw"
299309
private const val REQUEST_KEY = "O43z0dpjhgX20SCx4KAo"
300310
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
301-
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.3"
311+
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.3"
302312

303313
override fun newPoTokenGenerator(context: Context): Single<PoTokenGenerator> =
304314
Single.create { emitter ->

0 commit comments

Comments
 (0)