feat(history): miniatures des vidéos importées (i.ytimg déterministe)
This commit is contained in:
+6
-1
@@ -893,13 +893,18 @@ r.post('/user/history/takeout', authMiddleware, oauthLimiter, (req, res) => {
|
||||
const videoId = String(it?.videoId || '').trim().slice(0, 64);
|
||||
if (!/^[A-Za-z0-9_-]{6,64}$/.test(videoId)) { skipped++; continue; }
|
||||
const title = String(it?.title || '').slice(0, 300) || videoId;
|
||||
// Miniature YouTube déterministe quand Takeout n'en fournit pas.
|
||||
let thumbnail = String(it?.thumbnail || '').slice(0, 500);
|
||||
if (!thumbnail && /^[A-Za-z0-9_-]{11}$/.test(videoId)) {
|
||||
thumbnail = `https://i.ytimg.com/vi/${videoId}/hqdefault.jpg`;
|
||||
}
|
||||
let watchedAt = new Date().toISOString();
|
||||
if (it?.watchedAt) {
|
||||
const d = new Date(String(it.watchedAt));
|
||||
if (!Number.isNaN(d.getTime())) watchedAt = d.toISOString();
|
||||
}
|
||||
try {
|
||||
upsertWatchHistory({ userId: req.user.id, provider: 'youtube', videoId, title, watchedAt });
|
||||
upsertWatchHistory({ userId: req.user.id, provider: 'youtube', videoId, title, thumbnail, watchedAt });
|
||||
imported++;
|
||||
} catch { skipped++; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user