From 6fd81770bf290acb2cf966057d765819487a0936 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 02:48:13 +0100 Subject: [PATCH 1/8] chore: rename root project name Signed-off-by: oSumAtrIX --- settings.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 9b3c09a0..7743d887 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -8,4 +8,5 @@ dependencyResolutionManagement { } include(":app") include(":dummy") -rootProject.name = "integrations" + +rootProject.name = "revanced-integrations" From 89f866d739a7a1868b29ad6695f92e6f91b600f5 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 02:48:51 +0100 Subject: [PATCH 2/8] refactor: remove workaround task `publish` Signed-off-by: oSumAtrIX --- build.gradle.kts | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 08d8a748..5bc4f6b3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,12 +13,6 @@ buildscript { } } -// Tracking issue https://github.com/semantic-release/semantic-release/issues/963 -tasks.register("publish", DefaultTask::class) { - group = "publish" - description = "Dummy publish to pass the verification phase of the gradle-semantic-release-plugin" -} - tasks.register("clean", Delete::class) { delete(rootProject.buildDir) } From 993aadd4df80159de8497caa729b828726614ff6 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 02:49:09 +0100 Subject: [PATCH 3/8] chore: update sdk versions Signed-off-by: oSumAtrIX --- dummy/build.gradle.kts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dummy/build.gradle.kts b/dummy/build.gradle.kts index 0e98cdad..60bab807 100644 --- a/dummy/build.gradle.kts +++ b/dummy/build.gradle.kts @@ -4,11 +4,12 @@ plugins { android { namespace = "app.revanced.dummy" - compileSdk = 32 + compileSdk = 33 + buildToolsVersion = "33.0.1" defaultConfig { - minSdk = 26 - targetSdk = 32 + minSdk = 23 + targetSdk = 33 } buildTypes { @@ -24,7 +25,4 @@ android { sourceCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_11 } -} - -dependencies { } \ No newline at end of file From 8de014583ed6ee70c5d878ffc8f58cb34ec2fed9 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 02:49:43 +0100 Subject: [PATCH 4/8] chore: bump build tools version Signed-off-by: oSumAtrIX --- app/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 12d7dcdc..07d94780 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -8,7 +8,7 @@ plugins { android { compileSdk = 33 - buildToolsVersion = "33.0.0" + buildToolsVersion = "33.0.1" namespace = "app.revanced.integrations" defaultConfig { From 4a3d20e1f0b2c63c0f1837dcd6408ab5d927fdba Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 02:50:05 +0100 Subject: [PATCH 5/8] chore: set `versionName` Signed-off-by: oSumAtrIX --- app/build.gradle.kts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 07d94780..f07e39f1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,16 +15,8 @@ android { applicationId = "app.revanced.integrations" minSdk = 23 targetSdk = 33 - versionCode = 1 - versionName = "1.0" multiDexEnabled = false - - val properties = Properties() - if (rootProject.file("local.properties").exists()) { - properties.load(FileInputStream(rootProject.file("local.properties"))) - } - - buildConfigField("String", "YT_API_KEY", "\"${properties.getProperty("youtubeAPIKey", "")}\"") + versionName = project.version as String } buildTypes { From 4c18633c364491a1d699f92f1bc519517632d709 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 02:50:32 +0100 Subject: [PATCH 6/8] build: name output files Signed-off-by: oSumAtrIX --- app/build.gradle.kts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index f07e39f1..23239f63 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -22,7 +22,17 @@ android { buildTypes { release { isMinifyEnabled = true - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + applicationVariants.all { + outputs.all { + this as com.android.build.gradle.internal.api.ApkVariantOutputImpl + + outputFileName = "${rootProject.name}-$versionName.apk" + } } } compileOptions { From 843dd9de9e7fcd0b2b609e8af9a705faa1e23bc6 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 08:55:19 +0100 Subject: [PATCH 7/8] fix(twitch/block-embedded-ads): rewrite Kotlin classes to Java (#270) Signed-off-by: oSumAtrIX --- .../twitch/adblock/IAdblockService.java | 26 +++++ .../twitch/adblock/IAdblockService.kt | 18 ---- .../twitch/adblock/PurpleAdblockService.java | 83 ++++++++++++++++ .../twitch/adblock/PurpleAdblockService.kt | 68 ------------- .../twitch/adblock/TTVLolService.java | 70 +++++++++++++ .../revanced/twitch/adblock/TTVLolService.kt | 52 ---------- .../twitch/api/RequestInterceptor.java | 97 +++++++++++++++++++ .../revanced/twitch/api/RequestInterceptor.kt | 86 ---------------- 8 files changed, 276 insertions(+), 224 deletions(-) create mode 100644 app/src/main/java/app/revanced/twitch/adblock/IAdblockService.java delete mode 100644 app/src/main/java/app/revanced/twitch/adblock/IAdblockService.kt create mode 100644 app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java delete mode 100644 app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.kt create mode 100644 app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java delete mode 100644 app/src/main/java/app/revanced/twitch/adblock/TTVLolService.kt create mode 100644 app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java delete mode 100644 app/src/main/java/app/revanced/twitch/api/RequestInterceptor.kt diff --git a/app/src/main/java/app/revanced/twitch/adblock/IAdblockService.java b/app/src/main/java/app/revanced/twitch/adblock/IAdblockService.java new file mode 100644 index 00000000..612730af --- /dev/null +++ b/app/src/main/java/app/revanced/twitch/adblock/IAdblockService.java @@ -0,0 +1,26 @@ +package app.revanced.twitch.adblock; + +import okhttp3.Request; + +public interface IAdblockService { + String friendlyName(); + + Integer maxAttempts(); + + Boolean isAvailable(); + + Request rewriteHlsRequest(Request originalRequest); + + static boolean isVod(Request request){ + return request.url().pathSegments().contains("vod"); + } + + static String channelName(Request request) { + for (String pathSegment : request.url().pathSegments()) { + if (pathSegment.endsWith(".m3u8")) { + return pathSegment.replace(".m3u8", ""); + } + } + return null; + } +} diff --git a/app/src/main/java/app/revanced/twitch/adblock/IAdblockService.kt b/app/src/main/java/app/revanced/twitch/adblock/IAdblockService.kt deleted file mode 100644 index 73c199a5..00000000 --- a/app/src/main/java/app/revanced/twitch/adblock/IAdblockService.kt +++ /dev/null @@ -1,18 +0,0 @@ -package app.revanced.twitch.adblock - -import okhttp3.Request - -interface IAdblockService { - fun friendlyName(): String - fun maxAttempts(): Int - fun isAvailable(): Boolean - fun rewriteHlsRequest(originalRequest: Request): Request? - - companion object { - fun Request.isVod() = url.pathSegments.contains("vod") - fun Request.channelName() = - url.pathSegments - .firstOrNull { it.endsWith(".m3u8") } - .run { this?.replace(".m3u8", "") } - } -} \ No newline at end of file diff --git a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java new file mode 100644 index 00000000..5b2db973 --- /dev/null +++ b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.java @@ -0,0 +1,83 @@ +package app.revanced.twitch.adblock; + +import java.util.HashMap; +import java.util.Map; + +import app.revanced.twitch.api.RetrofitClient; +import app.revanced.twitch.utils.LogHelper; +import app.revanced.twitch.utils.ReVancedUtils; +import okhttp3.HttpUrl; +import okhttp3.Request; +import okhttp3.ResponseBody; + +public class PurpleAdblockService implements IAdblockService { + private final Map tunnels = new HashMap<>() {{ + put("https://eu1.jupter.ga", false); + put("https://eu2.jupter.ga", false); + }}; + + @Override + public String friendlyName() { + return ReVancedUtils.getString("revanced_proxy_purpleadblock"); + } + + @Override + public Integer maxAttempts() { + return 3; + } + + @Override + public Boolean isAvailable() { + for (String tunnel : tunnels.keySet()) { + var success = true; + + try { + var response = RetrofitClient.getInstance().getPurpleAdblockApi().ping(tunnel).execute(); + if (!response.isSuccessful()) { + LogHelper.error("PurpleAdBlock tunnel $tunnel returned an error: HTTP code %d", response.code()); + LogHelper.debug(response.message()); + if (response.errorBody() != null) { + LogHelper.debug(((ResponseBody) response.errorBody()).string()); + } + success = false; + } + } catch (Exception ex) { + LogHelper.printException("PurpleAdBlock tunnel $tunnel is unavailable", ex); + success = false; + } + + // Cache availability data + tunnels.put(tunnel, success); + + if (success) + return true; + } + + return false; + } + + @Override + public Request rewriteHlsRequest(Request originalRequest) { + for (Map.Entry entry : tunnels.entrySet()) { + if (!entry.getValue()) continue; + + var server = entry.getKey(); + + // Compose new URL + var url = HttpUrl.parse(server + "/channel/" + IAdblockService.channelName(originalRequest)); + if (url == null) { + LogHelper.error("Failed to parse rewritten URL"); + return null; + } + + // Overwrite old request + return new Request.Builder() + .get() + .url(url) + .build(); + } + + LogHelper.error("No tunnels are available"); + return null; + } +} diff --git a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.kt b/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.kt deleted file mode 100644 index 3c5e5abf..00000000 --- a/app/src/main/java/app/revanced/twitch/adblock/PurpleAdblockService.kt +++ /dev/null @@ -1,68 +0,0 @@ -package app.revanced.twitch.adblock - -import app.revanced.twitch.adblock.IAdblockService.Companion.channelName -import app.revanced.twitch.api.RetrofitClient -import app.revanced.twitch.utils.LogHelper -import app.revanced.twitch.utils.ReVancedUtils -import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import okhttp3.Request -import okhttp3.ResponseBody - -class PurpleAdblockService : IAdblockService { - private val tunnels = mutableMapOf( - /* tunnel url */ /* alive */ - "https://eu1.jupter.ga" to false, - "https://eu2.jupter.ga" to false - ) - - override fun friendlyName(): String = ReVancedUtils.getString("revanced_proxy_purpleadblock") - - override fun maxAttempts(): Int = 3 - - override fun isAvailable(): Boolean { - for(tunnel in tunnels.keys) { - var success = true - try { - val response = RetrofitClient.getInstance().purpleAdblockApi.ping(tunnel).execute() - if (!response.isSuccessful) { - LogHelper.error("PurpleAdBlock tunnel $tunnel returned an error: HTTP code %d", response.code()) - LogHelper.debug(response.message()) - LogHelper.debug((response.errorBody() as ResponseBody).string()) - success = false - } - } catch (ex: Exception) { - LogHelper.printException("PurpleAdBlock tunnel $tunnel is unavailable", ex) - success = false - } - - // Cache availability data - tunnels[tunnel] = success - - if(success) - return true - } - - return false - } - - override fun rewriteHlsRequest(originalRequest: Request): Request? { - val server = tunnels.filter { it.value }.map { it.key }.firstOrNull() - server ?: run { - LogHelper.error("No tunnels are available") - return null - } - - // Compose new URL - val url = "$server/channel/${originalRequest.channelName()}".toHttpUrlOrNull() - if (url == null) { - LogHelper.error("Failed to parse rewritten URL") - return null - } - - // Overwrite old request - return Request.Builder() - .get() - .url(url) - .build() - } -} \ No newline at end of file diff --git a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java new file mode 100644 index 00000000..6aa31d82 --- /dev/null +++ b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.java @@ -0,0 +1,70 @@ +package app.revanced.twitch.adblock; + +import java.util.ArrayList; +import java.util.Random; + +import app.revanced.twitch.utils.LogHelper; +import app.revanced.twitch.utils.ReVancedUtils; +import okhttp3.HttpUrl; +import okhttp3.Request; + +public class TTVLolService implements IAdblockService { + @Override + public String friendlyName() { + return ReVancedUtils.getString("revanced_proxy_ttv_lol"); + } + + // TTV.lol is sometimes unstable + @Override + public Integer maxAttempts() { + return 4; + } + + @Override + public Boolean isAvailable() { + return true; + } + + @Override + public Request rewriteHlsRequest(Request originalRequest) { + + var type = "vod"; + if (!IAdblockService.isVod(originalRequest)) + type = "playlist"; + + var url = HttpUrl.parse("https://api.ttv.lol/" + + type + "/" + + IAdblockService.channelName(originalRequest) + + ".m3u8" + nextQuery() + ); + + if (url == null) { + LogHelper.error("Failed to parse rewritten URL"); + return null; + } + + // Overwrite old request + return new Request.Builder() + .get() + .url(url) + .addHeader("X-Donate-To", "https://ttv.lol/donate") + .build(); + } + + private String nextQuery() { + return SAMPLE_QUERY.replace("", generateSessionId()); + } + + private String generateSessionId() { + final var chars = "abcdef0123456789".toCharArray(); + + var sessionId = new ArrayList(); + for (int i = 0; i < 32; i++) + sessionId.add(chars[randomSource.nextInt(16)]); + + return sessionId.toString(); + } + + private final Random randomSource = new Random(); + private final String SAMPLE_QUERY = "%3Fallow_source%3Dtrue%26fast_bread%3Dtrue%26allow_audio_only%3Dtrue%26p%3D0%26play_session_id%3D%26player_backend%3Dmediaplayer%26warp%3Dfalse%26force_preroll%3Dfalse%26mobile_cellular%3Dfalse"; +} diff --git a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.kt b/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.kt deleted file mode 100644 index b3cf2a73..00000000 --- a/app/src/main/java/app/revanced/twitch/adblock/TTVLolService.kt +++ /dev/null @@ -1,52 +0,0 @@ -package app.revanced.twitch.adblock - -import app.revanced.twitch.adblock.IAdblockService.Companion.channelName -import app.revanced.twitch.adblock.IAdblockService.Companion.isVod -import app.revanced.twitch.utils.LogHelper -import app.revanced.twitch.utils.ReVancedUtils -import okhttp3.HttpUrl.Companion.toHttpUrlOrNull -import okhttp3.Request -import java.util.Random - -class TTVLolService : IAdblockService { - - override fun friendlyName(): String = ReVancedUtils.getString("revanced_proxy_ttv_lol") - - // TTV.lol is sometimes unstable - override fun maxAttempts(): Int = 4 - - override fun isAvailable(): Boolean = true - - override fun rewriteHlsRequest(originalRequest: Request): Request? { - // Compose new URL - val url = "https://api.ttv.lol/${if (originalRequest.isVod()) "vod" else "playlist"}/${originalRequest.channelName()}.m3u8${nextQuery()}".toHttpUrlOrNull() - if (url == null) { - LogHelper.error("Failed to parse rewritten URL") - return null - } - - // Overwrite old request - return Request.Builder() - .get() - .url(url) - .addHeader("X-Donate-To", "https://ttv.lol/donate") - .build() - } - - private fun nextQuery(): String { - return SAMPLE_QUERY.replace("", generateSessionId()) - } - - private fun generateSessionId() = - (1..32) - .map { "abcdef0123456789"[randomSource.nextInt(16)] } - .joinToString("") - - private val randomSource = Random() - - companion object { - - private const val SAMPLE_QUERY = - "%3Fallow_source%3Dtrue%26fast_bread%3Dtrue%26allow_audio_only%3Dtrue%26p%3D0%26play_session_id%3D%26player_backend%3Dmediaplayer%26warp%3Dfalse%26force_preroll%3Dfalse%26mobile_cellular%3Dfalse" - } -} \ No newline at end of file diff --git a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java new file mode 100644 index 00000000..34cda6f6 --- /dev/null +++ b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.java @@ -0,0 +1,97 @@ +package app.revanced.twitch.api; + +import static app.revanced.twitch.adblock.IAdblockService.channelName; +import static app.revanced.twitch.adblock.IAdblockService.isVod; + +import androidx.annotation.NonNull; + +import java.io.IOException; + +import app.revanced.twitch.adblock.IAdblockService; +import app.revanced.twitch.adblock.PurpleAdblockService; +import app.revanced.twitch.adblock.TTVLolService; +import app.revanced.twitch.settings.SettingsEnum; +import app.revanced.twitch.utils.LogHelper; +import app.revanced.twitch.utils.ReVancedUtils; +import okhttp3.Interceptor; +import okhttp3.Response; + +public class RequestInterceptor implements Interceptor { + private IAdblockService activeService = null; + + @NonNull + @Override + public Response intercept(@NonNull Chain chain) throws IOException { + var originalRequest = chain.request(); + + LogHelper.debug("Intercepted request to URL: %s", originalRequest.url().toString()); + + // Skip if not HLS manifest request + if (!originalRequest.url().host().contains("usher.ttvnw.net")) { + return chain.proceed(originalRequest); + } + + var isVod = "no"; + if (isVod(originalRequest)) isVod = "yes"; + + LogHelper.debug("Found HLS manifest request. Is VOD? %s; Channel: %s", isVod, channelName(originalRequest)); + + // None of the services support VODs currently + if (isVod(originalRequest)) return chain.proceed(originalRequest); + + updateActiveService(); + + if (activeService != null) { + var available = activeService.isAvailable(); + var rewritten = activeService.rewriteHlsRequest(originalRequest); + + + if (!available || rewritten == null) { + ReVancedUtils.toast(String.format(ReVancedUtils.getString("revanced_embedded_ads_service_unavailable"), activeService.friendlyName()), true); + return chain.proceed(originalRequest); + } + + LogHelper.debug("Rewritten HLS stream URL: %s", rewritten.url().toString()); + + var maxAttempts = activeService.maxAttempts(); + + for (var i = 1; i <= maxAttempts; i++) { + // Execute rewritten request and close body to allow multiple proceed() calls + var response = chain.proceed(rewritten); + response.close(); + + if (!response.isSuccessful()) { + LogHelper.error("Request failed (attempt %d/%d): HTTP error %d (%s)", i, maxAttempts, response.code(), response.message()); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + LogHelper.printException("Failed to sleep" ,e); + } + } else { + // Accept response from ad blocker + LogHelper.debug("Ad-blocker used"); + return chain.proceed(rewritten); + } + } + + // maxAttempts exceeded; giving up on using the ad blocker + ReVancedUtils.toast(String.format(ReVancedUtils.getString("revanced_embedded_ads_service_failed"), activeService.friendlyName()), true); + + } + + // Adblock disabled + return chain.proceed(originalRequest); + + } + + private void updateActiveService() { + var current = SettingsEnum.BLOCK_EMBEDDED_ADS.getString(); + + if (current.equals(ReVancedUtils.getString("key_revanced_proxy_ttv_lol")) && !(activeService instanceof TTVLolService)) + activeService = new TTVLolService(); + else if (current.equals(ReVancedUtils.getString("key_revanced_proxy_purpleadblock")) && !(activeService instanceof PurpleAdblockService)) + activeService = new PurpleAdblockService(); + else if (current.equals(ReVancedUtils.getString("key_revanced_proxy_disabled"))) + activeService = null; + } +} diff --git a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.kt b/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.kt deleted file mode 100644 index 257e7839..00000000 --- a/app/src/main/java/app/revanced/twitch/api/RequestInterceptor.kt +++ /dev/null @@ -1,86 +0,0 @@ -package app.revanced.twitch.api - -import app.revanced.twitch.adblock.IAdblockService -import app.revanced.twitch.adblock.IAdblockService.Companion.channelName -import app.revanced.twitch.adblock.IAdblockService.Companion.isVod -import app.revanced.twitch.adblock.PurpleAdblockService -import app.revanced.twitch.adblock.TTVLolService -import app.revanced.twitch.settings.SettingsEnum -import app.revanced.twitch.utils.LogHelper -import app.revanced.twitch.utils.ReVancedUtils -import okhttp3.* - -class RequestInterceptor : Interceptor { - private var activeService: IAdblockService? = null - - private fun updateActiveService() { - val current = SettingsEnum.BLOCK_EMBEDDED_ADS.string - activeService = if(current == ReVancedUtils.getString("key_revanced_proxy_ttv_lol") && activeService !is TTVLolService) - TTVLolService() - else if(current == ReVancedUtils.getString("key_revanced_proxy_purpleadblock") && activeService !is PurpleAdblockService) - PurpleAdblockService() - else if(current == ReVancedUtils.getString("key_revanced_proxy_disabled")) - null - else - activeService - } - - override fun intercept(chain: Interceptor.Chain): Response { - val originalRequest = chain.request() - LogHelper.debug("Intercepted request to URL: %s", originalRequest.url.toString()) - - // Skip if not HLS manifest request - if (!originalRequest.url.host.contains("usher.ttvnw.net")) { - return chain.proceed(originalRequest) - } - - LogHelper.debug("Found HLS manifest request. Is VOD? %s; Channel: %s", - if (originalRequest.isVod()) "yes" else "no", originalRequest.channelName()) - - // None of the services support VODs currently - if(originalRequest.isVod()) - return chain.proceed(originalRequest) - - updateActiveService() - - activeService?.let { - val available = it.isAvailable() - val rewritten = it.rewriteHlsRequest(originalRequest) - - if (!available || rewritten == null) { - ReVancedUtils.toast( - String.format(ReVancedUtils.getString("revanced_embedded_ads_service_unavailable"), it.friendlyName()), - true - ) - return chain.proceed(originalRequest) - } - - LogHelper.debug("Rewritten HLS stream URL: %s", rewritten.url.toString()) - - val maxAttempts = it.maxAttempts() - for(i in 1..maxAttempts) { - // Execute rewritten request and close body to allow multiple proceed() calls - val response = chain.proceed(rewritten).apply { close() } - if(!response.isSuccessful) { - LogHelper.error("Request failed (attempt %d/%d): HTTP error %d (%s)", - i, maxAttempts, response.code, response.message) - Thread.sleep(50) - } - else { - // Accept response from ad blocker - LogHelper.debug("Ad-blocker used") - return chain.proceed(rewritten) - } - } - - // maxAttempts exceeded; giving up on using the ad blocker - ReVancedUtils.toast( - String.format(ReVancedUtils.getString("revanced_embedded_ads_service_failed"), it.friendlyName()), - true - ) - } - - // Adblock disabled - return chain.proceed(originalRequest) - } -} \ No newline at end of file From 64c31b84e76a270513efb4ae111afae507cacad4 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 2 Jan 2023 08:56:56 +0100 Subject: [PATCH 8/8] fix: revert removing workaround task `publish` This reverts commit 89f866d739a7a1868b29ad6695f92e6f91b600f5. --- build.gradle.kts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 5bc4f6b3..08d8a748 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,6 +13,12 @@ buildscript { } } +// Tracking issue https://github.com/semantic-release/semantic-release/issues/963 +tasks.register("publish", DefaultTask::class) { + group = "publish" + description = "Dummy publish to pass the verification phase of the gradle-semantic-release-plugin" +} + tasks.register("clean", Delete::class) { delete(rootProject.buildDir) }