Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ ksp {
arg("room.schemaLocation", "$projectDir/schemas")
}


// Custom dependency configuration for ktlint
val ktlint by configurations.creating

Expand Down Expand Up @@ -256,6 +255,7 @@ dependencies {

// HTTP client
implementation(libs.squareup.okhttp)
implementation(libs.squareup.okhttp.brotli)

// Media player
implementation(libs.google.exoplayer.core)
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.schabi.newpipe;

import android.content.Context;
import android.system.Os;
import android.system.OsConstants;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -23,9 +25,12 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import okhttp3.CompressionInterceptor;
import okhttp3.Gzip;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okhttp3.brotli.Brotli;

public final class DownloaderImpl extends Downloader {
public static final String USER_AGENT =
Expand All @@ -40,10 +45,20 @@ public final class DownloaderImpl extends Downloader {
private final OkHttpClient client;

private DownloaderImpl(final OkHttpClient.Builder builder) {
final CompressionInterceptor compressionInterceptor;
if (Os.sysconf(OsConstants._SC_NPROCESSORS_CONF) > 2) {
compressionInterceptor = new CompressionInterceptor(
Brotli.INSTANCE,
Gzip.INSTANCE);
} else {
compressionInterceptor = new CompressionInterceptor(
Gzip.INSTANCE);
}
this.client = builder
.readTimeout(30, TimeUnit.SECONDS)
// .cache(new Cache(new File(context.getExternalCacheDir(), "okhttp"),
// 16 * 1024 * 1024))
.addInterceptor(compressionInterceptor)
.build();
this.mCookies = new HashMap<>();
}
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ squareup-leakcanary-core = { module = "com.squareup.leakcanary:leakcanary-androi
squareup-leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android", version.ref = "leakcanary" }
squareup-leakcanary-watcher = { module = "com.squareup.leakcanary:leakcanary-object-watcher-android", version.ref = "leakcanary" }
squareup-okhttp = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
squareup-okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli", version.ref = "okhttp" }
zacsweers-autoservice-compiler = { module = "dev.zacsweers.autoservice:auto-service-ksp", version.ref = "autoservice-zacsweers" }

[plugins]
Expand Down