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

Localization inconsistency fix for Local API #2535

20 changes: 17 additions & 3 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,14 @@ export default Vue.extend({

throw new Error(`${reason}: ${subReason}`)
}

this.videoTitle = result.videoDetails.title
try {
// workaround for title localization
this.videoTitle = result.response.contents.twoColumnWatchNextResults.results.results.contents[0].videoPrimaryInfoRenderer.title.runs[0].text
} catch (err) {
console.error('Failed to extract localised video title, falling back to the standard one.', err)
// if the workaround for localization fails, this sets the title to the potentially non-localized value
this.videoTitle = result.videoDetails.title
}
this.videoViewCount = parseInt(
result.player_response.videoDetails.viewCount,
10
Expand All @@ -299,7 +305,15 @@ export default Vue.extend({
})

this.videoPublished = new Date(result.videoDetails.publishDate.replace('-', '/')).getTime()
this.videoDescription = result.player_response.videoDetails.shortDescription
try {
// workaround for description localization
const descriptionLines = result.response.contents.twoColumnWatchNextResults.results.results.contents[1].videoSecondaryInfoRenderer.description?.runs
this.videoDescription = descriptionLines?.map(line => line.text).join('') ?? ''
} catch (err) {
console.error('Failed to extract localised video description, falling back to the standard one.', err)
// if the workaround for localization fails, this sets the description to the potentially non-localized value
this.videoDescription = result.player_response.videoDetails.shortDescription
}

switch (this.thumbnailPreference) {
case 'start':
Expand Down