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

Handle channel URL resolve redirects in the local API #4205

Merged
Merged
Changes from 1 commit
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
11 changes: 11 additions & 0 deletions src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,17 @@ export async function getLocalChannelId(url) {

if (navigationEndpoint.metadata.page_type === 'WEB_PAGE_TYPE_CHANNEL') {
return navigationEndpoint.payload.browseId
} else if (navigationEndpoint.metadata.page_type === 'WEB_PAGE_TYPE_UNKNOWN' && navigationEndpoint.payload.url?.startsWith('https://www.youtube.com/')) {
// handle redirects like https://www.youtube.com/@wanderbots, which resolves to https://www.youtube.com/Wanderbots, which we need to resolve again

// while we could just have this function recursively call itself, YouTube should only ever redirect once, so if they do it multiple times, we should assume something is wrong
const secondNavigationEndpoint = await innertube.resolveURL(navigationEndpoint.payload.url)

if (secondNavigationEndpoint.metadata.page_type === 'WEB_PAGE_TYPE_CHANNEL') {
return secondNavigationEndpoint.payload.browseId
} else {
return null
}
} else {
return null
}
Expand Down