debug(sync): diag inclut la chaîne mine=true (id+titre) pour comparaison
This commit is contained in:
+6
-1
@@ -108,7 +108,7 @@ import {
|
|||||||
fetchGoogleLiked, fetchTwitchProfile, fetchTwitchFollows, hasGoogleWriteScope,
|
fetchGoogleLiked, fetchTwitchProfile, fetchTwitchFollows, hasGoogleWriteScope,
|
||||||
fetchGoogleWatchLater, pushGoogleWatchLater, fetchInnerTubeHistory,
|
fetchGoogleWatchLater, pushGoogleWatchLater, fetchInnerTubeHistory,
|
||||||
fetchInnerTubeWatchLaterViaLib, pushInnerTubeWatchLater, fetchGoogleWatchLaterId,
|
fetchInnerTubeWatchLaterViaLib, pushInnerTubeWatchLater, fetchGoogleWatchLaterId,
|
||||||
fetchAccountChannels, diagnoseInnertube,
|
fetchAccountChannels, diagnoseInnertube, fetchMineChannel,
|
||||||
} from './oauth.mjs';
|
} from './oauth.mjs';
|
||||||
import { getSearchMode, getYtDlpBin, hasCookiesFile, metricsSnapshot } from './providers/youtube-common.mjs';
|
import { getSearchMode, getYtDlpBin, hasCookiesFile, metricsSnapshot } from './providers/youtube-common.mjs';
|
||||||
import { ytScrapeCacheStats } from './providers/youtube.mjs';
|
import { ytScrapeCacheStats } from './providers/youtube.mjs';
|
||||||
@@ -590,6 +590,11 @@ r.get('/oauth/google/diag', authMiddlewareCookieAware, oauthLimiter, async (req,
|
|||||||
try {
|
try {
|
||||||
const conn = await freshOAuthToken(req.user.id, 'google');
|
const conn = await freshOAuthToken(req.user.id, 'google');
|
||||||
const dataApi = {};
|
const dataApi = {};
|
||||||
|
try {
|
||||||
|
dataApi.mineChannel = await fetchMineChannel(conn.accessToken);
|
||||||
|
} catch (e) {
|
||||||
|
dataApi.mineChannel = { error: String(e?.message || '').slice(0, 80) };
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await fetchGoogleWatchLaterId(conn.accessToken);
|
await fetchGoogleWatchLaterId(conn.accessToken);
|
||||||
dataApi.watchLaterId = true;
|
dataApi.watchLaterId = true;
|
||||||
|
|||||||
@@ -347,6 +347,18 @@ async function googleApiPost(accessToken, path, body) {
|
|||||||
return data;
|
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). */
|
/** ID de la playlist "Regarder plus tard" du compte (lecture seule OK). */
|
||||||
export async function fetchGoogleWatchLaterId(accessToken) {
|
export async function fetchGoogleWatchLaterId(accessToken) {
|
||||||
const data = await googleApiGet(accessToken, 'channels', { part: 'contentDetails', mine: 'true' });
|
const data = await googleApiGet(accessToken, 'channels', { part: 'contentDetails', mine: 'true' });
|
||||||
|
|||||||
Reference in New Issue
Block a user