Skip to content

Commit

Permalink
BITCHUTE: simplify channel id extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
evermind-zz committed Jul 27, 2024
1 parent 5e44148 commit 64d2764
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -73,7 +83,7 @@ public static void setUp() throws Exception {
"true"
+ ",\"url\":\""
+ /* ===set the expected url=== */
"2fqQXi6GCbgyrXaPQ540PLNu_small.jpg"
"2fqQXi6GCbgyrXaPQ540PLNu_"
+ "\"}"
+ "]"
);
Expand Down

0 comments on commit 64d2764

Please sign in to comment.