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

Only use android formats when the video id in the response is correct #3719

Merged
merged 2 commits into from
Jul 3, 2023
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
12 changes: 9 additions & 3 deletions src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,16 @@ export async function getLocalVideoInfo(id, attemptBypass = false) {
const androidInnertube = await createInnertube({ clientType: ClientType.ANDROID, generateSessionLocally: false })
const androidInfo = await androidInnertube.getBasicInfo(id, 'ANDROID')

if (androidInfo.playability_status.status === 'OK') {
info.streaming_data = androidInfo.streaming_data
// Sometimes when YouTube detects a third party client or has applied an IP-ratelimit,
// they replace the response with a different video id
// https://github.com/TeamNewPipe/NewPipe/issues/8713
// https://github.com/TeamPiped/Piped/issues/2487
if (androidInfo.basic_info.id !== id) {
console.error(`Failed to fetch android formats. Wrong video ID in response: ${androidInfo.basic_info.id}, expected: ${id}`)
} else if (androidInfo.playability_status.status !== 'OK') {
console.error('Failed to fetch android formats', JSON.stringify(androidInfo.playability_status))
} else {
console.error('Failed to fetch android formats', JSON.parse(JSON.stringify(androidInfo.playability_status)))
info.streaming_data = androidInfo.streaming_data
}
} catch (error) {
console.error('Failed to fetch android formats')
Expand Down