Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround YouTube bug causing the community tab to be empty #3318

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,11 +1038,25 @@ export default defineComponent({
* @type {import('youtubei.js/dist/src/parser/youtube/Channel').default}
*/
const channel = this.channelInstance
const communityTab = await channel.getCommunity()

/**
* @type {import('youtubei.js/dist/src/parser/youtube/Channel').default|import('youtubei.js/dist/src/parser/youtube/Channel').ChannelListContinuation}
*/
let communityTab = await channel.getCommunity()
if (expectedId !== this.id) {
return
}
this.latestCommunityPosts = communityTab.posts.map(parseLocalCommunityPost)

// work around YouTube bug where it will return a bunch of responses with only continuations in them
// e.g. https://www.youtube.com/@TheLinuxEXP/community

let posts = communityTab.posts
while (posts.length === 0 && communityTab.has_continuation) {
communityTab = await communityTab.getContinuation()
posts = communityTab.posts
}

this.latestCommunityPosts = posts.map(parseLocalCommunityPost)
this.communityContinuationData = communityTab.has_continuation ? communityTab : null
} catch (err) {
console.error(err)
Expand All @@ -1064,8 +1078,17 @@ export default defineComponent({
/**
* @type {import('youtubei.js/dist/src/parser/youtube/Channel').ChannelListContinuation}
*/
const continuation = await this.communityContinuationData.getContinuation()
this.latestCommunityPosts = this.latestCommunityPosts.concat(continuation.posts.map(parseLocalCommunityPost))
let continuation = await this.communityContinuationData.getContinuation()

// work around YouTube bug where it will return a bunch of responses with only continuations in them
// e.g. https://www.youtube.com/@TheLinuxEXP/community
let posts = continuation.posts
while (posts.length === 0 && continuation.has_continuation) {
continuation = await continuation.getContinuation()
posts = continuation.posts
}

this.latestCommunityPosts = this.latestCommunityPosts.concat(posts.map(parseLocalCommunityPost))
this.communityContinuationData = continuation.has_continuation ? continuation : null
} catch (err) {
console.error(err)
Expand Down