mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 14:20:33 +05:30
Fix YoutubeChannelExtractor for channels without videos
This commit is contained in:
parent
cdbc751b87
commit
2399d46ab0
@ -85,6 +85,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNextPageUrl() throws ExtractionException {
|
public String getNextPageUrl() throws ExtractionException {
|
||||||
|
if (getVideoTab() == null) return "";
|
||||||
return getNextPageUrlFrom(getVideoTab().getObject("content").getObject("sectionListRenderer")
|
return getNextPageUrlFrom(getVideoTab().getObject("content").getObject("sectionListRenderer")
|
||||||
.getArray("contents").getObject(0).getObject("itemSectionRenderer")
|
.getArray("contents").getObject(0).getObject("itemSectionRenderer")
|
||||||
.getArray("contents").getObject(0).getObject("gridRenderer").getArray("continuations"));
|
.getArray("contents").getObject(0).getObject("gridRenderer").getArray("continuations"));
|
||||||
@ -195,10 +196,12 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {
|
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {
|
||||||
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
|
||||||
|
|
||||||
|
if (getVideoTab() != null) {
|
||||||
JsonArray videos = getVideoTab().getObject("content").getObject("sectionListRenderer").getArray("contents")
|
JsonArray videos = getVideoTab().getObject("content").getObject("sectionListRenderer").getArray("contents")
|
||||||
.getObject(0).getObject("itemSectionRenderer").getArray("contents").getObject(0)
|
.getObject(0).getObject("itemSectionRenderer").getArray("contents").getObject(0)
|
||||||
.getObject("gridRenderer").getArray("items");
|
.getObject("gridRenderer").getArray("items");
|
||||||
collectStreamsFrom(collector, videos);
|
collectStreamsFrom(collector, videos);
|
||||||
|
}
|
||||||
|
|
||||||
return new InfoItemsPage<>(collector, getNextPageUrl());
|
return new InfoItemsPage<>(collector, getNextPageUrl());
|
||||||
}
|
}
|
||||||
@ -241,9 +244,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
|
|
||||||
|
|
||||||
private String getNextPageUrlFrom(JsonArray continuations) {
|
private String getNextPageUrlFrom(JsonArray continuations) {
|
||||||
if (continuations == null) {
|
if (continuations == null) return "";
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonObject nextContinuationData = continuations.getObject(0).getObject("nextContinuationData");
|
JsonObject nextContinuationData = continuations.getObject(0).getObject("nextContinuationData");
|
||||||
String continuation = nextContinuationData.getString("continuation");
|
String continuation = nextContinuationData.getString("continuation");
|
||||||
@ -295,6 +296,14 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
throw new ParsingException("Could not find Videos tab");
|
throw new ParsingException("Could not find Videos tab");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (videoTab.getObject("content").getObject("sectionListRenderer").getArray("contents")
|
||||||
|
.getObject(0).getObject("itemSectionRenderer").getArray("contents")
|
||||||
|
.getObject(0).getObject("messageRenderer").getObject("text").getArray("runs")
|
||||||
|
.getObject(0).getString("text").equals("This channel has no videos."))
|
||||||
|
return null;
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
return videoTab;
|
return videoTab;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user