mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 21:27:43 +02:00
chore: Lint code
This commit is contained in:
@ -30,6 +30,7 @@ object AppClient {
|
||||
|
||||
private const val DEVICE_MAKE_IOS = "Apple"
|
||||
private const val OS_NAME_IOS = "iOS"
|
||||
|
||||
/**
|
||||
* The device machine id for the iPhone 15 Pro Max (iPhone16,2),
|
||||
* used to get HDR with AV1 hardware decoding.
|
||||
@ -240,7 +241,6 @@ object AppClient {
|
||||
val userAgent: String,
|
||||
/**
|
||||
* Android SDK version, equivalent to [Build.VERSION.SDK] (System property: ro.build.version.sdk)
|
||||
* Field is null if not applicable.
|
||||
*/
|
||||
val androidSdkVersion: String = Build.VERSION.SDK,
|
||||
/**
|
||||
|
@ -141,8 +141,9 @@ public class SpoofStreamingDataPatch {
|
||||
* 1. Save the requestHeader in a field.
|
||||
* 2. Invoke fetchRequest with the videoId used in PlaybackStartDescriptor.
|
||||
* <p>
|
||||
* @param requestHeaders Save the request Headers used for login to a field.
|
||||
* Only used in YouTube Music where login is required.
|
||||
*
|
||||
* @param requestHeaders Save the request Headers used for login to a field.
|
||||
* Only used in YouTube Music where login is required.
|
||||
*/
|
||||
private static void setRequestHeaders(Map<String, String> requestHeaders) {
|
||||
if (SPOOF_STREAMING_DATA_MUSIC) {
|
||||
|
@ -130,17 +130,35 @@ object PlayerRoutes {
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPlayerResponseConnectionFromRoute(route: CompiledRoute, clientType: AppClient.ClientType): HttpURLConnection {
|
||||
return getPlayerResponseConnectionFromRoute(route, clientType.userAgent, clientType.id.toString())
|
||||
fun getPlayerResponseConnectionFromRoute(
|
||||
route: CompiledRoute,
|
||||
clientType: AppClient.ClientType
|
||||
): HttpURLConnection {
|
||||
return getPlayerResponseConnectionFromRoute(
|
||||
route,
|
||||
clientType.userAgent,
|
||||
clientType.id.toString()
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPlayerResponseConnectionFromRoute(route: CompiledRoute, clientType: WebClient.ClientType): HttpURLConnection {
|
||||
return getPlayerResponseConnectionFromRoute(route, clientType.userAgent, clientType.id.toString())
|
||||
fun getPlayerResponseConnectionFromRoute(
|
||||
route: CompiledRoute,
|
||||
clientType: WebClient.ClientType
|
||||
): HttpURLConnection {
|
||||
return getPlayerResponseConnectionFromRoute(
|
||||
route,
|
||||
clientType.userAgent,
|
||||
clientType.id.toString()
|
||||
)
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
fun getPlayerResponseConnectionFromRoute(route: CompiledRoute, userAgent: String, clientVersion: String): HttpURLConnection {
|
||||
fun getPlayerResponseConnectionFromRoute(
|
||||
route: CompiledRoute,
|
||||
userAgent: String,
|
||||
clientVersion: String
|
||||
): HttpURLConnection {
|
||||
val connection = Requester.getConnectionFromCompiledRoute(YT_API_URL, route)
|
||||
|
||||
connection.setRequestProperty("Content-Type", "application/json")
|
||||
|
@ -9,7 +9,6 @@ import app.revanced.extension.shared.patches.spoof.requests.PlayerRoutes.getPlay
|
||||
import app.revanced.extension.shared.settings.BaseSettings
|
||||
import app.revanced.extension.shared.utils.Logger
|
||||
import app.revanced.extension.shared.utils.Utils
|
||||
import org.apache.commons.lang3.ArrayUtils
|
||||
import org.apache.commons.lang3.StringUtils
|
||||
import java.io.BufferedInputStream
|
||||
import java.io.ByteArrayOutputStream
|
||||
@ -111,6 +110,7 @@ class StreamingDataRequest private constructor(
|
||||
* Any arbitrarily large value, but must be at least twice [.HTTP_TIMEOUT_MILLISECONDS]
|
||||
*/
|
||||
private const val MAX_MILLISECONDS_TO_WAIT_FOR_FETCH = 20 * 1000
|
||||
|
||||
@GuardedBy("itself")
|
||||
val cache: MutableMap<String, StreamingDataRequest> = Collections.synchronizedMap(
|
||||
object : LinkedHashMap<String, StreamingDataRequest>(100) {
|
||||
@ -171,11 +171,13 @@ class StreamingDataRequest private constructor(
|
||||
Logger.printDebug { "Fetching video streams for: $videoId using client: $clientType" }
|
||||
|
||||
try {
|
||||
val connection = getPlayerResponseConnectionFromRoute(GET_STREAMING_DATA, clientType)
|
||||
val connection =
|
||||
getPlayerResponseConnectionFromRoute(GET_STREAMING_DATA, clientType)
|
||||
connection.connectTimeout = HTTP_TIMEOUT_MILLISECONDS
|
||||
connection.readTimeout = HTTP_TIMEOUT_MILLISECONDS
|
||||
|
||||
val usePoToken = clientType.requirePoToken && !StringUtils.isAnyEmpty(botGuardPoToken, visitorId)
|
||||
val usePoToken =
|
||||
clientType.requirePoToken && !StringUtils.isAnyEmpty(botGuardPoToken, visitorId)
|
||||
|
||||
for (key in REQUEST_HEADER_KEYS) {
|
||||
var value = playerHeaders[key]
|
||||
@ -248,7 +250,8 @@ class StreamingDataRequest private constructor(
|
||||
// Retry with different client if empty response body is received.
|
||||
for (clientType in CLIENT_ORDER_TO_USE) {
|
||||
if (clientType.requireAuth &&
|
||||
playerHeaders[AUTHORIZATION_HEADER] == null) {
|
||||
playerHeaders[AUTHORIZATION_HEADER] == null
|
||||
) {
|
||||
Logger.printDebug { "Skipped login-required client (incognito mode or not logged in)\nClient: $clientType\nVideo: $videoId" }
|
||||
continue
|
||||
}
|
||||
@ -270,7 +273,9 @@ class StreamingDataRequest private constructor(
|
||||
ByteArrayOutputStream().use { stream ->
|
||||
val buffer = ByteArray(2048)
|
||||
var bytesRead: Int
|
||||
while ((inputStream.read(buffer).also { bytesRead = it }) >= 0) {
|
||||
while ((inputStream.read(buffer)
|
||||
.also { bytesRead = it }) >= 0
|
||||
) {
|
||||
stream.write(buffer, 0, bytesRead)
|
||||
}
|
||||
lastSpoofedClientType = clientType
|
||||
|
@ -121,21 +121,27 @@ public class ReturnYouTubeDislikeApi {
|
||||
public static long getFetchCallResponseTimeLast() {
|
||||
return fetchCallResponseTimeLast;
|
||||
}
|
||||
|
||||
public static long getFetchCallResponseTimeMin() {
|
||||
return fetchCallResponseTimeMin;
|
||||
}
|
||||
|
||||
public static long getFetchCallResponseTimeMax() {
|
||||
return fetchCallResponseTimeMax;
|
||||
}
|
||||
|
||||
public static long getFetchCallResponseTimeAverage() {
|
||||
return fetchCallCount == 0 ? 0 : (fetchCallResponseTimeTotal / fetchCallCount);
|
||||
}
|
||||
|
||||
public static int getFetchCallCount() {
|
||||
return fetchCallCount;
|
||||
}
|
||||
|
||||
public static int getFetchCallNumberOfFailures() {
|
||||
return fetchCallNumberOfFailures;
|
||||
}
|
||||
|
||||
public static int getNumberOfRateLimitRequestsEncountered() {
|
||||
return numberOfRateLimitRequestsEncountered;
|
||||
}
|
||||
|
@ -19,7 +19,10 @@ import java.util.concurrent.Future
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.TimeoutException
|
||||
|
||||
class MusicRequest private constructor(private val videoId: String, private val checkCategory: Boolean) {
|
||||
class MusicRequest private constructor(
|
||||
private val videoId: String,
|
||||
private val checkCategory: Boolean
|
||||
) {
|
||||
/**
|
||||
* Time this instance and the fetch future was created.
|
||||
*/
|
||||
@ -121,7 +124,10 @@ class MusicRequest private constructor(private val videoId: String, private val
|
||||
Logger.printDebug { "Fetching playlist request for: $videoId using client: $clientTypeName" }
|
||||
|
||||
try {
|
||||
val connection = PlayerRoutes.getPlayerResponseConnectionFromRoute(PlayerRoutes.GET_PLAYLIST_PAGE, clientType)
|
||||
val connection = PlayerRoutes.getPlayerResponseConnectionFromRoute(
|
||||
PlayerRoutes.GET_PLAYLIST_PAGE,
|
||||
clientType
|
||||
)
|
||||
val requestBody =
|
||||
PlayerRoutes.createApplicationRequestBody(clientType, videoId, "RD$videoId")
|
||||
|
||||
@ -158,7 +164,10 @@ class MusicRequest private constructor(private val videoId: String, private val
|
||||
Logger.printDebug { "Fetching playability request for: $videoId using client: $clientTypeName" }
|
||||
|
||||
try {
|
||||
val connection = PlayerRoutes.getPlayerResponseConnectionFromRoute(PlayerRoutes.GET_CATEGORY, clientType)
|
||||
val connection = PlayerRoutes.getPlayerResponseConnectionFromRoute(
|
||||
PlayerRoutes.GET_CATEGORY,
|
||||
clientType
|
||||
)
|
||||
val requestBody =
|
||||
PlayerRoutes.createWebInnertubeBody(clientType, videoId)
|
||||
|
||||
|
@ -4,7 +4,6 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.SearchView;
|
||||
|
Reference in New Issue
Block a user