From a3d29fe3cd77f4f878ba39066473f3424658954e Mon Sep 17 00:00:00 2001 From: Bruno Charest Date: Sun, 27 Sep 2026 09:01:06 -0400 Subject: [PATCH] =?UTF-8?q?debug(sync):=20diag=20inclut=20la=20cha=C3=AEne?= =?UTF-8?q?=20mine=3Dtrue=20(id+titre)=20pour=20comparaison?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/index.mjs | 7 ++++++- server/oauth.mjs | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/server/index.mjs b/server/index.mjs index ba422d0..f6eb54f 100644 --- a/server/index.mjs +++ b/server/index.mjs @@ -108,7 +108,7 @@ import { fetchGoogleLiked, fetchTwitchProfile, fetchTwitchFollows, hasGoogleWriteScope, fetchGoogleWatchLater, pushGoogleWatchLater, fetchInnerTubeHistory, fetchInnerTubeWatchLaterViaLib, pushInnerTubeWatchLater, fetchGoogleWatchLaterId, - fetchAccountChannels, diagnoseInnertube, + fetchAccountChannels, diagnoseInnertube, fetchMineChannel, } from './oauth.mjs'; import { getSearchMode, getYtDlpBin, hasCookiesFile, metricsSnapshot } from './providers/youtube-common.mjs'; import { ytScrapeCacheStats } from './providers/youtube.mjs'; @@ -590,6 +590,11 @@ r.get('/oauth/google/diag', authMiddlewareCookieAware, oauthLimiter, async (req, try { const conn = await freshOAuthToken(req.user.id, 'google'); const dataApi = {}; + try { + dataApi.mineChannel = await fetchMineChannel(conn.accessToken); + } catch (e) { + dataApi.mineChannel = { error: String(e?.message || '').slice(0, 80) }; + } try { await fetchGoogleWatchLaterId(conn.accessToken); dataApi.watchLaterId = true; diff --git a/server/oauth.mjs b/server/oauth.mjs index 533e589..98097d4 100644 --- a/server/oauth.mjs +++ b/server/oauth.mjs @@ -347,6 +347,18 @@ async function googleApiPost(accessToken, path, body) { return data; } +/** Chaîne résolue par `mine=true` pour ce token (id + titre, pour comparer). */ +export async function fetchMineChannel(accessToken) { + const data = await googleApiGet(accessToken, 'channels', { part: 'id,snippet,contentDetails', mine: 'true' }); + const item = Array.isArray(data?.items) ? data.items[0] : null; + if (!item) return { id: null, title: null, relatedKeys: [] }; + return { + id: item.id || null, + title: item.snippet?.title || null, + relatedKeys: Object.keys(item?.contentDetails?.relatedPlaylists || {}), + }; +} + /** ID de la playlist "Regarder plus tard" du compte (lecture seule OK). */ export async function fetchGoogleWatchLaterId(accessToken) { const data = await googleApiGet(accessToken, 'channels', { part: 'contentDetails', mine: 'true' });