From bae104a03bab0a918520be15c4e3851c6806bf59 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Sun, 17 Dec 2023 04:50:47 +0000 Subject: [PATCH] Enable sending consent cookie. --- config.properties | 4 ++++ src/main/java/me/kavin/piped/Main.java | 2 ++ src/main/java/me/kavin/piped/consts/Constants.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/config.properties b/config.properties index 4b99288..ff8592f 100644 --- a/config.properties +++ b/config.properties @@ -56,6 +56,10 @@ DISABLE_LBRY:false # How long should unauthenticated subscriptions last for SUBSCRIPTIONS_EXPIRY:30 +# Send consent accepted cookie +# This is required for certain features to work in some countries +CONSENT_COOKIE:true + # Sentry DSN # Use Sentry to log errors and trace performance #SENTRY_DSN:INSERT_HERE diff --git a/src/main/java/me/kavin/piped/Main.java b/src/main/java/me/kavin/piped/Main.java index 32295c3..7e223b9 100644 --- a/src/main/java/me/kavin/piped/Main.java +++ b/src/main/java/me/kavin/piped/Main.java @@ -20,6 +20,7 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.localization.ContentCountry; import org.schabi.newpipe.extractor.localization.Localization; import org.schabi.newpipe.extractor.services.youtube.YoutubeJavaScriptPlayerManager; +import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper; import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeStreamExtractor; import org.schabi.newpipe.extractor.stream.StreamInfo; import rocks.kavin.reqwest4j.ReqwestUtils; @@ -46,6 +47,7 @@ public class Main { NewPipe.init(new DownloaderImpl(), new Localization("en", "US"), ContentCountry.DEFAULT, Multithreading.getCachedExecutor()); YoutubeStreamExtractor.forceFetchAndroidClient(true); YoutubeStreamExtractor.forceFetchIosClient(true); + YoutubeParsingHelper.setConsentAccepted(CONSENT_COOKIE); // Warm up the extractor try { diff --git a/src/main/java/me/kavin/piped/consts/Constants.java b/src/main/java/me/kavin/piped/consts/Constants.java index cac0223..176a3a4 100644 --- a/src/main/java/me/kavin/piped/consts/Constants.java +++ b/src/main/java/me/kavin/piped/consts/Constants.java @@ -83,6 +83,8 @@ public class Constants { public static final int SUBSCRIPTIONS_EXPIRY; + public static final boolean CONSENT_COOKIE; + public static final String SENTRY_DSN; public static final String S3_ENDPOINT; @@ -152,6 +154,7 @@ public class Constants { DISABLE_SERVER = Boolean.parseBoolean(getProperty(prop, "DISABLE_SERVER", "false")); DISABLE_LBRY = Boolean.parseBoolean(getProperty(prop, "DISABLE_LBRY", "false")); SUBSCRIPTIONS_EXPIRY = Integer.parseInt(getProperty(prop, "SUBSCRIPTIONS_EXPIRY", "30")); + CONSENT_COOKIE = Boolean.parseBoolean(getProperty(prop, "CONSENT_COOKIE", "true")); SENTRY_DSN = getProperty(prop, "SENTRY_DSN", ""); S3_ENDPOINT = getProperty(prop, "S3_ENDPOINT"); S3_ACCESS_KEY = getProperty(prop, "S3_ACCESS_KEY");