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 IP blocks better on the watch page #5757

Merged
Merged
Show file tree
Hide file tree
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
21 changes: 15 additions & 6 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,21 @@ export default defineComponent({

const playabilityStatus = result.playability_status

if (playabilityStatus.status === 'UNPLAYABLE') {
/**
* @type {import ('youtubei.js').YTNodes.PlayerErrorMessage}
*/
const errorScreen = playabilityStatus.error_screen
throw new Error(`[${playabilityStatus.status}] ${errorScreen.reason.text}: ${errorScreen.subreason.text}`)
// The apostrophe is intentionally that one (char code 8217), because that is the one YouTube uses
const BOT_MESSAGE = 'Sign in to confirm you’re not a bot'

if (playabilityStatus.status === 'UNPLAYABLE' || (playabilityStatus.status === 'LOGIN_REQUIRED' && playabilityStatus.reason === BOT_MESSAGE)) {
if (playabilityStatus.reason === BOT_MESSAGE) {
throw new Error(this.$t('Video.IP block'))
}

let errorText = `[${playabilityStatus.status}] ${playabilityStatus.reason}`

if (playabilityStatus.error_screen) {
errorText += `: ${playabilityStatus.error_screen.subreason.text}`
}

throw new Error(errorText)
}

// extract localised title first and fall back to the not localised one
Expand Down
1 change: 1 addition & 0 deletions static/locales/en-US.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ Channel:
Video hidden by FreeTube: Video hidden by FreeTube
Viewing Posts Only Supported By Invidious: Viewing Posts is only supported by Invidious. Head to a channel's community tab to view content there without Invidious.
Video:
IP block: 'YouTube has blocked your IP address from watching videos. Please try switching to a different VPN or proxy.'
More Options: More Options
Mark As Watched: Mark As Watched
Remove From History: Remove From History
Expand Down