fix: persist canonical title from youtube metadata

This commit is contained in:
2026-03-22 19:40:12 -07:00
parent d65575c80d
commit ef716b82c7
3 changed files with 16 additions and 0 deletions

View File

@@ -42,6 +42,8 @@ Recent sessions, streak calendar, watch-time history, and a tracking snapshot wi
Cover-art library with search and sorting, per-series progress, episode drill-down, and direct links into mined cards.
When YouTube channel metadata is available, the Library tab groups videos by creator/channel and treats each tracked video as an episode-like entry inside that channel section.
![Stats Library](/screenshots/stats-library.png)
#### Trends

View File

@@ -2369,8 +2369,18 @@ printf '%s\n' '{"id":"abc123","title":"Video Name","webpage_url":"https://www.yo
uploaderUrl: string;
description: string;
} | null;
const videoRow = privateApi.db
.prepare(
`
SELECT canonical_title AS canonicalTitle
FROM imm_videos
WHERE video_id = 1
`,
)
.get() as { canonicalTitle: string } | null;
assert.ok(row);
assert.ok(videoRow);
assert.equal(row.youtubeVideoId, 'abc123');
assert.equal(row.videoUrl, 'https://www.youtube.com/watch?v=abc123');
assert.equal(row.videoTitle, 'Video Name');
@@ -2382,6 +2392,7 @@ printf '%s\n' '{"id":"abc123","title":"Video Name","webpage_url":"https://www.yo
assert.equal(row.uploaderId, '@creator');
assert.equal(row.uploaderUrl, 'https://www.youtube.com/@creator');
assert.equal(row.description, 'Video description');
assert.equal(videoRow.canonicalTitle, 'Video Name');
} finally {
process.env.PATH = originalPath;
globalThis.fetch = originalFetch;

View File

@@ -909,6 +909,9 @@ export class ImmersionTrackerService {
return;
}
upsertYoutubeVideoMetadata(this.db, videoId, metadata);
if (metadata.videoTitle?.trim()) {
updateVideoTitleRecord(this.db, videoId, metadata.videoTitle.trim());
}
} catch (error) {
this.logger.debug(
'youtube metadata capture skipped for videoId=%d: %s',