Merge branch 'master' into dev
This commit is contained in:
commit
d116680ea3
|
@ -11,7 +11,7 @@ NewPipe Extractor is available at JitPack's Maven repo.
|
||||||
If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:
|
If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:
|
||||||
|
|
||||||
1. Add `maven { url 'https://jitpack.io' }` to the `repositories` in your `build.gradle`.
|
1. Add `maven { url 'https://jitpack.io' }` to the `repositories` in your `build.gradle`.
|
||||||
2. Add `implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.20.8'`the `dependencies` in your `build.gradle`. Replace `v0.20.8` with the latest release.
|
2. Add `implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.20.9'`the `dependencies` in your `build.gradle`. Replace `v0.20.9` with the latest release.
|
||||||
|
|
||||||
**Note:** To use NewPipe Extractor in projects with a `minSdkVersion` below 26, [API desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) is required.
|
**Note:** To use NewPipe Extractor in projects with a `minSdkVersion` below 26, [API desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) is required.
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ allprojects {
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
version 'v0.20.8'
|
version 'v0.20.9'
|
||||||
group 'com.github.TeamNewPipe'
|
group 'com.github.TeamNewPipe'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
|
|
@ -20,9 +20,7 @@ import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
|
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.*;
|
||||||
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.utils.JsonUtils.EMPTY_STRING;
|
import static org.schabi.newpipe.extractor.utils.JsonUtils.EMPTY_STRING;
|
||||||
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||||
|
|
||||||
|
@ -230,9 +228,9 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
.getArray("contents").getObject(0).getObject("itemSectionRenderer")
|
.getArray("contents").getObject(0).getObject("itemSectionRenderer")
|
||||||
.getArray("contents").getObject(0).getObject("gridRenderer");
|
.getArray("contents").getObject(0).getObject("gridRenderer");
|
||||||
|
|
||||||
collectStreamsFrom(collector, gridRenderer.getArray("items"));
|
final JsonObject continuation = collectStreamsFrom(collector, gridRenderer.getArray("items"));
|
||||||
|
|
||||||
nextPage = getNextPageFrom(gridRenderer.getArray("continuations"));
|
nextPage = getNextPageFrom(continuation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new InfoItemsPage<>(collector, nextPage);
|
return new InfoItemsPage<>(collector, nextPage);
|
||||||
|
@ -252,36 +250,47 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
final JsonArray ajaxJson = getJsonResponse(page.getUrl(), getExtractorLocalization());
|
final JsonArray ajaxJson = getJsonResponse(page.getUrl(), getExtractorLocalization());
|
||||||
|
|
||||||
JsonObject sectionListContinuation = ajaxJson.getObject(1).getObject("response")
|
JsonObject sectionListContinuation = ajaxJson.getObject(1).getObject("response")
|
||||||
.getObject("continuationContents").getObject("gridContinuation");
|
.getArray("onResponseReceivedActions").getObject(0).getObject("appendContinuationItemsAction");
|
||||||
|
|
||||||
collectStreamsFrom(collector, sectionListContinuation.getArray("items"));
|
final JsonObject continuation = collectStreamsFrom(collector, sectionListContinuation.getArray("continuationItems"));
|
||||||
|
|
||||||
return new InfoItemsPage<>(collector, getNextPageFrom(sectionListContinuation.getArray("continuations")));
|
return new InfoItemsPage<>(collector, getNextPageFrom(continuation));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Page getNextPageFrom(final JsonArray continuations) {
|
private Page getNextPageFrom(final JsonObject continuations) {
|
||||||
if (isNullOrEmpty(continuations)) {
|
if (isNullOrEmpty(continuations)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final JsonObject nextContinuationData = continuations.getObject(0).getObject("nextContinuationData");
|
final JsonObject continuationEndpoint = continuations.getObject("continuationEndpoint");
|
||||||
final String continuation = nextContinuationData.getString("continuation");
|
final String continuation = continuationEndpoint.getObject("continuationCommand").getString("token");
|
||||||
final String clickTrackingParams = nextContinuationData.getString("clickTrackingParams");
|
final String clickTrackingParams = continuationEndpoint.getString("clickTrackingParams");
|
||||||
return new Page("https://www.youtube.com/browse_ajax?ctoken=" + continuation
|
return new Page("https://www.youtube.com/browse_ajax?ctoken=" + continuation
|
||||||
+ "&continuation=" + continuation + "&itct=" + clickTrackingParams);
|
+ "&continuation=" + continuation + "&itct=" + clickTrackingParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectStreamsFrom(StreamInfoItemsCollector collector, JsonArray videos) throws ParsingException {
|
/**
|
||||||
|
* Collect streams from an array of items
|
||||||
|
*
|
||||||
|
* @param collector the collector where videos will be commited
|
||||||
|
* @param videos the array to get videos from
|
||||||
|
* @return the continuation object
|
||||||
|
* @throws ParsingException if an error happened while extracting
|
||||||
|
*/
|
||||||
|
private JsonObject collectStreamsFrom(StreamInfoItemsCollector collector, JsonArray videos) throws ParsingException {
|
||||||
collector.reset();
|
collector.reset();
|
||||||
|
|
||||||
final String uploaderName = getName();
|
final String uploaderName = getName();
|
||||||
final String uploaderUrl = getUrl();
|
final String uploaderUrl = getUrl();
|
||||||
final TimeAgoParser timeAgoParser = getTimeAgoParser();
|
final TimeAgoParser timeAgoParser = getTimeAgoParser();
|
||||||
|
|
||||||
for (Object video : videos) {
|
JsonObject continuation = null;
|
||||||
if (((JsonObject) video).has("gridVideoRenderer")) {
|
|
||||||
|
for (Object object : videos) {
|
||||||
|
final JsonObject video = (JsonObject) object;
|
||||||
|
if (video.has("gridVideoRenderer")) {
|
||||||
collector.commit(new YoutubeStreamInfoItemExtractor(
|
collector.commit(new YoutubeStreamInfoItemExtractor(
|
||||||
((JsonObject) video).getObject("gridVideoRenderer"), timeAgoParser) {
|
video.getObject("gridVideoRenderer"), timeAgoParser) {
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderName() {
|
public String getUploaderName() {
|
||||||
return uploaderName;
|
return uploaderName;
|
||||||
|
@ -292,8 +301,12 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
return uploaderUrl;
|
return uploaderUrl;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} else if (video.has("continuationItemRenderer")) {
|
||||||
|
continuation = video.getObject("continuationItemRenderer");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return continuation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonObject getVideoTab() throws ParsingException {
|
private JsonObject getVideoTab() throws ParsingException {
|
||||||
|
|
Loading…
Reference in New Issue