From 1ba0865a090e0810fdd6dc279603e4634d9778a4 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Mon, 3 Jul 2023 04:48:35 +0200 Subject: [PATCH] Only use android formats when the video id in the response is correct (#3719) * Only use android formats when the video id in the response is correct * Fix typo in playability status check Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> --------- Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com> --- src/renderer/helpers/api/local.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/renderer/helpers/api/local.js b/src/renderer/helpers/api/local.js index e0d0ab87a..dfff7ce3d 100644 --- a/src/renderer/helpers/api/local.js +++ b/src/renderer/helpers/api/local.js @@ -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')