debug(sync): logs serveur yt-history/WL (counts + detail erreur)

This commit is contained in:
2026-09-27 07:49:30 -04:00
parent 8edf9de0c6
commit d3836989ea
+10
View File
@@ -673,6 +673,9 @@ r.get('/oauth/google/watchlater', authMiddlewareCookieAware, oauthLimiter, async
console.warn(`[oauth] WL Data API indisponible (${apiError.message}), repli youtubei.js`);
} catch {}
const { items } = await fetchInnerTubeWatchLaterViaLib(conn, 100);
try {
console.log(`[oauth] WL via innertube user=${req.user?.id} count=${items.length}`);
} catch {}
return res.json({
items, count: items.length, writeGranted, via: 'innertube',
note: 'Liste lue via InnerTube (l’API YouTube ne l’expose pas pour ce compte).',
@@ -718,11 +721,18 @@ r.get('/oauth/google/yt-history', authMiddlewareCookieAware, oauthLimiter, async
const conn = await freshOAuthToken(req.user.id, 'google');
const max = Math.min(500, Math.max(1, Number(req.query.max || 200)));
const { items, hasMore } = await fetchInnerTubeHistory(conn, max);
try {
console.log(`[oauth] yt-history user=${req.user?.id} count=${items.length} hasMore=${hasMore}`);
} catch {}
return res.json({ items, count: items.length, hasMore });
} catch (error) {
const out = { error: error?.message || 'ythistory_fetch_failed' };
if (error?.ytReason) out.ytReason = error.ytReason;
if (error?.detail) out.detail = error.detail;
if (error?.hint) out.hint = error.hint;
try {
console.warn(`[oauth] yt-history échec user=${req.user?.id} code=${out.error} detail=${String(error?.detail || error?.ytReason || '').slice(0, 300)}`);
} catch {}
if (!out.hint && error?.status === 401) {
out.hint = 'Session Google expirée : déconnectez puis reconnectez Google.';
} else if (!out.hint && String(error?.ytReason || '').toLowerCase().includes('insufficientpermissions')) {