Use Page.body for YoutubeChannelExtractor
This commit is contained in:
parent
eda1b6e199
commit
7b06c696e2
|
@ -4,6 +4,8 @@ import java.io.Serializable;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||
|
||||
public class Page implements Serializable {
|
||||
|
@ -11,10 +13,12 @@ public class Page implements Serializable {
|
|||
private final String id;
|
||||
private final List<String> ids;
|
||||
private final Map<String, String> cookies;
|
||||
|
||||
@Nullable
|
||||
private final byte[] body;
|
||||
|
||||
public Page(final String url, final String id, final List<String> ids,
|
||||
final Map<String, String> cookies, final byte[] body) {
|
||||
final Map<String, String> cookies, @Nullable final byte[] body) {
|
||||
this.url = url;
|
||||
this.id = id;
|
||||
this.ids = ids;
|
||||
|
@ -67,6 +71,7 @@ public class Page implements Serializable {
|
|||
|| !isNullOrEmpty(page.getIds()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getBody() {
|
||||
return body;
|
||||
}
|
||||
|
|
|
@ -21,15 +21,16 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
|||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getClientVersion;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonResponse;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getValidJsonResponseBody;
|
||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.prepareJsonBuilder;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
|
||||
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||
|
@ -264,23 +265,9 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
// as they don't deliver enough information on their own (the channel name, for example).
|
||||
fetchPage();
|
||||
|
||||
// @formatter:off
|
||||
byte[] json = JsonWriter.string()
|
||||
.object()
|
||||
.object("context")
|
||||
.object("client")
|
||||
.value("clientName", "1")
|
||||
.value("clientVersion", getClientVersion())
|
||||
.end()
|
||||
.end()
|
||||
.value("continuation", page.getId())
|
||||
.end()
|
||||
.done()
|
||||
.getBytes(UTF_8);
|
||||
// @formatter:on
|
||||
|
||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||
final Response response = getDownloader().post(page.getUrl(), null, json, getExtractorLocalization());
|
||||
final Response response = getDownloader().post(page.getUrl(), null, page.getBody(),
|
||||
getExtractorLocalization());
|
||||
|
||||
final JsonObject ajaxJson = JsonUtils.toJsonObject(getValidJsonResponseBody(response));
|
||||
|
||||
|
@ -300,8 +287,14 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
final JsonObject continuationEndpoint = continuations.getObject("continuationEndpoint");
|
||||
final String continuation = continuationEndpoint.getObject("continuationCommand").getString("token");
|
||||
|
||||
final byte[] body = JsonWriter.string(prepareJsonBuilder()
|
||||
.value("continuation", continuation)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
|
||||
return new Page("https://www.youtube.com/youtubei/v1/browse?key=" + getKey(),
|
||||
continuation);
|
||||
body);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue