mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Fix for fetching channels without a videos tab.
This commit is contained in:
parent
1891a2e6a8
commit
bb3bb3889a
1 changed files with 80 additions and 71 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue