From 64d27644c7be1c72452079747f39dce795a2b26e Mon Sep 17 00:00:00 2001 From: evermind Date: Sat, 27 Jul 2024 10:13:04 +0200 Subject: [PATCH] BITCHUTE: simplify channel id extraction --- .../extractor/BitchuteChannelExtractor.java | 14 ++------------ .../BitchuteChannelExtractorTest.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractor.java index 67da041f7a..12254e6d82 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractor.java @@ -3,16 +3,12 @@ import com.github.bravenewpipe.json2java4nanojson.bitchute.api.results.stream.channel.ResultsStreamChannel; import com.grack.nanojson.JsonObject; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; import org.schabi.newpipe.extractor.Image; import org.schabi.newpipe.extractor.StreamingService; import org.schabi.newpipe.extractor.channel.ChannelExtractor; import org.schabi.newpipe.extractor.downloader.Downloader; -import org.schabi.newpipe.extractor.downloader.Response; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler; import org.schabi.newpipe.extractor.search.filter.FilterItem; import org.schabi.newpipe.extractor.services.bitchute.BitchuteParserHelper; @@ -52,14 +48,8 @@ public ResultsStreamChannel callApiAndGetResultsStreamChannel( return new ResultsStreamChannel(streamVideoResultsJson); } - private String getChannelID() throws IOException, ReCaptchaException, ParsingException { - // TODO we should retrieve the ChannelId from somewhere else. - // so we do not need to fetch doc and can start by calling just the API - final Response response = getDownloader().get(getUrl(), - BitchuteParserHelper.getBasicHeader()); - final Document doc = Jsoup.parse(response.responseBody(), getUrl()); - final String canonicalUrl = doc.getElementById("canonical").attr("href"); - final String[] urlSegments = canonicalUrl.split("/"); + private String getChannelID() throws ParsingException { + final String[] urlSegments = getUrl().split("/"); return urlSegments[urlSegments.length - 1]; } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractorTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractorTest.java index 1e7da186e4..ad0c5fc4e2 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractorTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/bitchute/extractor/BitchuteChannelExtractorTest.java @@ -40,9 +40,19 @@ public static void setUp() throws Exception { put(KeysForTestDataMap.expectedChannelName, "Mark Dice"); put(KeysForTestDataMap.expectedId, "u3QMwGD7bSW6"); put(KeysForTestDataMap.expectedMinSubscriberCount, "70000"); - put(KeysForTestDataMap.expectedDescription, "Mark Dice - Exposing liberal lunatics, celebrity scum, mainstream media manipulation, and social justice warrior psychos. BEST CONSERVATIVE CHANNEL ON BITCHUTE."); - put(KeysForTestDataMap.expectedAvatarUrl, "ePTmphLaTzTvJgILYVieZtEv_small.jpg"); - put(KeysForTestDataMap.expectedBannerlUrl, "ePTmphLaTzTvJgILYVieZtEv_small.jpg"); + put(KeysForTestDataMap.expectedDescription, "Exposing liberal lunatics, celebrity scum, mainstream media manipulation"); + put(KeysForTestDataMap.expectedAvatarUrl, "[" + + "{\"hasImage\":" + + /* ===expected to have image? ===*/ + "true" + + ",\"url\":\"" + + /* ===set the expected url=== */ + "ePTmphLaTzTvJgILYVieZtEv_" + + "\"}" + + "]" + ); + put(KeysForTestDataMap.expectedBannerlUrl, + get(KeysForTestDataMap.expectedAvatarUrl)); put(KeysForTestDataMap.doTestMoreRelatedItems, "true"); }}; TestChannel.setUp(); @@ -73,7 +83,7 @@ public static void setUp() throws Exception { "true" + ",\"url\":\"" + /* ===set the expected url=== */ - "2fqQXi6GCbgyrXaPQ540PLNu_small.jpg" + "2fqQXi6GCbgyrXaPQ540PLNu_" + "\"}" + "]" );