From f441036ed2a41551031a39aa01ee9a42046cb926 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Mon, 22 Jul 2024 11:48:02 +0200 Subject: [PATCH] [Bandcamp] Upgrade incoming links to HTTPS --- .../bandcamp/extractors/BandcampExtractorHelper.java | 7 ++++++- .../linkHandler/BandcampChannelLinkHandlerFactory.java | 3 ++- .../linkHandler/BandcampCommentsLinkHandlerFactory.java | 5 +++-- .../linkHandler/BandcampPlaylistLinkHandlerFactory.java | 3 ++- .../linkHandler/BandcampStreamLinkHandlerFactory.java | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java index ade12b0309..b230079109 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java @@ -16,6 +16,7 @@ import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.utils.ImageSuffix; +import org.schabi.newpipe.extractor.utils.Utils; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -171,7 +172,11 @@ public static boolean isArtistDomain(final String url) throws ParsingException { try { // Test other URLs for whether they contain a footer that links to bandcamp - return Jsoup.parse(NewPipe.getDownloader().get(url).responseBody()) + return Jsoup.parse( + NewPipe.getDownloader() + .get(Utils.replaceHttpWithHttps(url)) + .responseBody() + ) .getElementsByClass("cart-wrapper") .get(0) .getElementsByTag("a") diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java index 440b75c922..dc508ddbe3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java @@ -33,7 +33,8 @@ public static BandcampChannelLinkHandlerFactory getInstance() { @Override public String getId(final String url) throws ParsingException, UnsupportedOperationException { try { - final String response = NewPipe.getDownloader().get(url).responseBody(); + final String response = NewPipe.getDownloader().get(Utils.replaceHttpWithHttps(url)) + .responseBody(); // Use band data embedded in website to extract ID final JsonObject bandData = JsonUtils.getJsonData(response, "data-band"); diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java index 2fae715157..797dea09b3 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java @@ -3,6 +3,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper; +import org.schabi.newpipe.extractor.utils.Utils; import java.util.List; @@ -24,7 +25,7 @@ public static BandcampCommentsLinkHandlerFactory getInstance() { @Override public String getId(final String url) throws ParsingException, UnsupportedOperationException { - return url; + return Utils.replaceHttpWithHttps(url); } @Override @@ -47,6 +48,6 @@ public String getUrl(final String id, final List contentFilter, final String sortFilter) throws ParsingException, UnsupportedOperationException { - return id; + return Utils.replaceHttpWithHttps(id); } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java index 76dd92c553..6a308a9a9b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java @@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper; +import org.schabi.newpipe.extractor.utils.Utils; import java.util.List; @@ -33,7 +34,7 @@ public String getUrl(final String url, final List contentFilter, final String sortFilter) throws ParsingException, UnsupportedOperationException { - return url; + return Utils.replaceHttpWithHttps(url); } /** diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java index 88d4dda15c..a052999656 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java @@ -5,6 +5,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory; import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper; +import org.schabi.newpipe.extractor.utils.Utils; import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_URL; @@ -49,7 +50,7 @@ public String getUrl(final String input) if (input.matches("\\d+")) { return BASE_URL + "/?show=" + input; } else { - return input; + return Utils.replaceHttpWithHttps(input); } }