fix(sync): historique via youtubei.js authentifié (contexte officiel) + WL alias WL
This commit is contained in:
+5
-4
@@ -716,14 +716,15 @@ r.get('/oauth/google/yt-history', authMiddlewareCookieAware, oauthLimiter, async
|
||||
try {
|
||||
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.accessToken, innertubeApiKey(), max);
|
||||
const { items, hasMore } = await fetchInnerTubeHistory(conn, max);
|
||||
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?.status === 401) {
|
||||
if (error?.hint) out.hint = error.hint;
|
||||
if (!out.hint && error?.status === 401) {
|
||||
out.hint = 'Session Google expirée : déconnectez puis reconnectez Google.';
|
||||
} else if (String(error?.ytReason || '').toLowerCase().includes('insufficientpermissions')) {
|
||||
} else if (!out.hint && String(error?.ytReason || '').toLowerCase().includes('insufficientpermissions')) {
|
||||
out.hint = 'Scope manquant : déconnectez puis reconnectez Google pour autoriser l’accès complet YouTube.';
|
||||
}
|
||||
return res.status(error?.status || 502).json(out);
|
||||
@@ -752,7 +753,7 @@ r.post('/oauth/google/watchlater', authMiddlewareCookieAware, oauthLimiter, asyn
|
||||
for (const videoId of clean) {
|
||||
try {
|
||||
if (useInnertube) await pushInnerTubeWatchLater(conn.accessToken, innertubeApiKey(), videoId);
|
||||
else await pushGoogleWatchLater(conn.accessToken, videoId);
|
||||
else await pushGoogleWatchLater(conn.accessToken, videoId, innertubeApiKey());
|
||||
added++;
|
||||
} catch { skipped++; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user