Skip to content

Commit 7706fa4

Browse files
committed
Trim video titles with the local API to avoid breaking the databases
1 parent a196575 commit 7706fa4

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/renderer/helpers/api/local.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ export function parseShort(short, channelId, channelName) {
10391039
return {
10401040
type: 'video',
10411041
videoId: reelItem.id,
1042-
title: reelItem.title.text,
1042+
title: reelItem.title.text?.trim(),
10431043
author: channelName,
10441044
authorId: channelId,
10451045
viewCount: reelItem.views.isEmpty() ? null : parseLocalSubscriberCount(reelItem.views.text),
@@ -1052,7 +1052,7 @@ export function parseShort(short, channelId, channelName) {
10521052
return {
10531053
type: 'video',
10541054
videoId: shortsLockupView.on_tap_endpoint.payload.videoId,
1055-
title: shortsLockupView.overlay_metadata.primary_text.text,
1055+
title: shortsLockupView.overlay_metadata.primary_text.text?.trim(),
10561056
author: channelName,
10571057
authorId: channelId,
10581058
viewCount: shortsLockupView.overlay_metadata.secondary_text ? parseLocalSubscriberCount(shortsLockupView.overlay_metadata.secondary_text.text) : null,
@@ -1247,7 +1247,7 @@ export function parseLocalPlaylistVideo(video) {
12471247
return {
12481248
type: 'video',
12491249
videoId: short.id,
1250-
title: short.title.text,
1250+
title: short.title.text?.trim(),
12511251
viewCount: parseLocalSubscriberCount(short.views.text),
12521252
lengthSeconds: ''
12531253
}
@@ -1283,7 +1283,7 @@ export function parseLocalPlaylistVideo(video) {
12831283
return {
12841284
type: 'video',
12851285
videoId: shortsLockupView.on_tap_endpoint.payload.videoId,
1286-
title: shortsLockupView.overlay_metadata.primary_text.text,
1286+
title: shortsLockupView.overlay_metadata.primary_text.text?.trim(),
12871287
viewCount,
12881288
lengthSeconds: ''
12891289
}
@@ -1329,7 +1329,7 @@ export function parseLocalPlaylistVideo(video) {
13291329
return {
13301330
type: 'video',
13311331
videoId: video_.id,
1332-
title: video_.title.text,
1332+
title: video_.title.text?.trim(),
13331333
author: video_.author.name,
13341334
authorId: video_.author.id,
13351335
viewCount,
@@ -1355,7 +1355,7 @@ export function parseLocalListVideo(item, channelId, channelName) {
13551355
return {
13561356
type: 'video',
13571357
videoId: movie.id,
1358-
title: movie.title.text,
1358+
title: movie.title.text?.trim(),
13591359
author: movie.author.name !== 'N/A' ? movie.author.name : channelName,
13601360
authorId: movie.author.id !== 'N/A' ? movie.author.id : channelId,
13611361
description: movie.description_snippet?.text,
@@ -1385,7 +1385,7 @@ export function parseLocalListVideo(item, channelId, channelName) {
13851385
return {
13861386
type: 'video',
13871387
videoId: video.video_id,
1388-
title: video.title.text,
1388+
title: video.title.text?.trim(),
13891389
author: video.author?.name ?? channelName,
13901390
authorId: video.author?.id ?? channelId,
13911391
viewCount: video.views.text == null ? null : extractNumberFromString(video.views.text),
@@ -1436,7 +1436,7 @@ export function parseLocalListVideo(item, channelId, channelName) {
14361436
return {
14371437
type: 'video',
14381438
videoId: video.video_id,
1439-
title: video.title.text,
1439+
title: video.title.text?.trim(),
14401440
author: video.author.name !== 'N/A' ? video.author.name : channelName,
14411441
authorId: video.author.id !== 'N/A' ? video.author.id : channelId,
14421442
description: video.description,
@@ -1545,7 +1545,7 @@ function parseLockupView(lockupView, channelId = undefined, channelName = undefi
15451545
return {
15461546
type: 'video',
15471547
videoId: lockupView.content_id,
1548-
title: lockupView.metadata.title.text,
1548+
title: lockupView.metadata.title.text?.trim(),
15491549
author: lockupView.metadata.metadata?.metadata_rows[0].metadata_parts?.[0].text?.text,
15501550
authorId: lockupView.metadata.image?.renderer_context?.command_context?.on_tap?.payload.browseId,
15511551
viewCount,
@@ -1686,7 +1686,7 @@ export function parseLocalWatchNextVideo(video) {
16861686
return {
16871687
type: 'video',
16881688
videoId: video.id,
1689-
title: video.title.text,
1689+
title: video.title.text?.trim(),
16901690
author: video.author.name,
16911691
authorId: video.author.id,
16921692
lengthSeconds: video.duration.seconds
@@ -1705,7 +1705,7 @@ export function parseLocalWatchNextVideo(video) {
17051705
return {
17061706
type: 'video',
17071707
videoId: video.video_id,
1708-
title: video.title.text,
1708+
title: video.title.text?.trim(),
17091709
author: video.author.name,
17101710
authorId: video.author.id,
17111711
viewCount: video.view_count == null ? null : extractNumberFromString(video.view_count.text),

src/renderer/views/Watch/Watch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ export default defineComponent({
426426
}
427427

428428
// extract localised title first and fall back to the not localised one
429-
this.videoTitle = result.primary_info?.title.text ?? result.basic_info.title
429+
this.videoTitle = result.primary_info?.title.text?.trim() ?? result.basic_info.title?.trim()
430430
this.videoViewCount = result.basic_info.view_count ?? (result.primary_info.view_count ? extractNumberFromString(result.primary_info.view_count.text) : null)
431431
this.license = result.secondary_info.metadata.rows.find(element => element.title?.text === 'License')?.contents[0]?.text
432432

0 commit comments

Comments
 (0)