Fix for fetching channels without a videos tab.

This commit is contained in:
Kavin 2023-06-01 19:12:54 +01:00
parent 1891a2e6a8
commit bb3bb3889a
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
1 changed files with 80 additions and 71 deletions

View File

@ -41,10 +41,18 @@ public class ChannelHandlers {
final ChannelInfo info = ChannelInfo.getInfo("https://youtube.com/" + channelPath);
final ChannelTabInfo tabInfo = ChannelTabInfo.getInfo(YOUTUBE_SERVICE, collectPreloadedTabs(info.getTabs()).get(0));
final var preloadedVideosTab = collectPreloadedTabs(info.getTabs())
.stream()
.filter(tab -> tab.getContentFilters().contains(ChannelTabs.VIDEOS))
.findFirst();
final List<ContentItem> relatedStreams = collectRelatedItems(tabInfo.getRelatedItems());
final ChannelTabInfo tabInfo = preloadedVideosTab.isPresent() ?
ChannelTabInfo.getInfo(YOUTUBE_SERVICE, preloadedVideosTab.get()) :
null;
final List<ContentItem> relatedStreams = tabInfo != null ? collectRelatedItems(tabInfo.getRelatedItems()) : List.of();
if (tabInfo != null)
Multithreading.runAsync(() -> tabInfo.getRelatedItems()
.stream().filter(StreamInfoItem.class::isInstance)
.map(StreamInfoItem.class::cast)
@ -74,6 +82,7 @@ public class ChannelHandlers {
}
});
if (tabInfo != null)
Multithreading.runAsync(() -> {
var channel = DatabaseHelper.getChannelFromId(info.getId());
@ -132,7 +141,7 @@ public class ChannelHandlers {
});
String nextpage = null;
if (tabInfo.hasNextPage()) {
if (tabInfo != null && tabInfo.hasNextPage()) {
Page page = tabInfo.getNextPage();
nextpage = mapper.writeValueAsString(page);
}