Skip to content

Commit 36aec37

Browse files
authored
Fix age-restricted videos breaking the watch page (#8831)
1 parent d0d3b11 commit 36aec37

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

src/renderer/helpers/api/local.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -470,28 +470,32 @@ export async function getLocalVideoInfo(id) {
470470
info.playability_status.reason === 'Sign in to confirm your age') ||
471471
(hasTrailer && trailerIsAgeRestricted)
472472
) {
473-
const webEmbeddedInnertube = await createInnertube({ clientType: ClientType.WEB_EMBEDDED })
474-
webEmbeddedInnertube.session.context.client.visitorData = webInnertube.session.context.client.visitorData
473+
try {
474+
const webEmbeddedInnertube = await createInnertube({ clientType: ClientType.WEB_EMBEDDED })
475+
webEmbeddedInnertube.session.context.client.visitorData = webInnertube.session.context.client.visitorData
475476

476-
const videoId = hasTrailer && trailerIsAgeRestricted ? info.playability_status.error_screen.video_id : id
477+
const videoId = hasTrailer && trailerIsAgeRestricted ? info.playability_status.error_screen.video_id : id
477478

478-
// getBasicInfo needs the signature timestamp (sts) from inside the player
479-
webEmbeddedInnertube.session.player = webInnertube.session.player
479+
// getBasicInfo needs the signature timestamp (sts) from inside the player
480+
webEmbeddedInnertube.session.player = webInnertube.session.player
480481

481-
const bypassedInfo = await webEmbeddedInnertube.getBasicInfo(videoId, { client: 'WEB_EMBEDDED', po_token: contentPoToken })
482+
const bypassedInfo = await webEmbeddedInnertube.getBasicInfo(videoId, { client: 'WEB_EMBEDDED', po_token: contentPoToken })
482483

483-
if (bypassedInfo.playability_status.status === 'OK' && bypassedInfo.streaming_data) {
484-
info.playability_status = bypassedInfo.playability_status
485-
info.streaming_data = bypassedInfo.streaming_data
486-
info.basic_info.start_timestamp = bypassedInfo.basic_info.start_timestamp
487-
info.basic_info.duration = bypassedInfo.basic_info.duration
488-
info.captions = bypassedInfo.captions
489-
info.storyboards = bypassedInfo.storyboards
484+
if (bypassedInfo.playability_status.status === 'OK' && bypassedInfo.streaming_data) {
485+
info.playability_status = bypassedInfo.playability_status
486+
info.streaming_data = bypassedInfo.streaming_data
487+
info.basic_info.start_timestamp = bypassedInfo.basic_info.start_timestamp
488+
info.basic_info.duration = bypassedInfo.basic_info.duration
489+
info.captions = bypassedInfo.captions
490+
info.storyboards = bypassedInfo.storyboards
490491

491-
hasTrailer = false
492-
trailerIsAgeRestricted = false;
492+
hasTrailer = false
493+
trailerIsAgeRestricted = false;
493494

494-
({ clientName, clientVersion, osName, osVersion } = webEmbeddedInnertube.session.context.client)
495+
({ clientName, clientVersion, osName, osVersion } = webEmbeddedInnertube.session.context.client)
496+
}
497+
} catch (error) {
498+
console.warn('WEB_EMBEDDED fallback errored, using the original response instead', error)
495499
}
496500
}
497501

0 commit comments

Comments
 (0)