mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Merge pull request #605 from TeamPiped/channel-no-videos-tab-fix
Fix for fetching channels without a videos tab.
This commit is contained in:
commit
e0dc4f8784
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