fix(shorts): embeds par fournisseur + flux infini (153/Forbidden/not-found)

This commit is contained in:
2026-09-29 09:04:09 -04:00
parent 937436658a
commit 34f432a7c1
3 changed files with 416 additions and 109 deletions
+6 -4
View File
@@ -1525,15 +1525,17 @@ export class YoutubeApiService {
if (!token) return of({ items: [], nextCursor: null });
const headers = new HttpHeaders({ 'Client-ID': this.resolveTwitchClientId()!, 'Authorization': `Bearer ${token}` });
const after = cursor ? `&after=${encodeURIComponent(cursor)}` : '';
const sPrimary = `/api/twitch-api/helix/streams?first=10${after}`;
const sFallback = `/proxy/twitch-api/helix/streams?first=10${after}`;
const sPrimary = `/api/twitch-api/helix/streams?first=20${after}`;
const sFallback = `/proxy/twitch-api/helix/streams?first=20${after}`;
return this.http.get<any>(sPrimary, { headers }).pipe(
catchError(() => this.http.get<any>(sFallback, { headers })),
switchMap(sRes => {
const streams = Array.isArray(sRes?.data) ? sRes.data : [];
const userIds: string[] = streams.map((s: any) => s?.user_id).filter(Boolean).slice(0, 10);
const userIds: string[] = streams.map((s: any) => s?.user_id).filter(Boolean).slice(0, 20);
if (!userIds.length) return of({ items: [], nextCursor: null } as PagedResult<Video>);
const since = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
// Fenêtre large (90 j) : beaucoup de chaînes n'ont pas de clips sur 7 j,
// ce qui vidait la page Shorts Twitch ("Aucun Short trouvé").
const since = new Date(Date.now() - 90 * 24 * 60 * 60 * 1000).toISOString();
const perUser = userIds.map(uid => {
const cPrimary = `/api/twitch-api/helix/clips?broadcaster_id=${encodeURIComponent(uid)}&first=5&started_at=${encodeURIComponent(since)}`;
const cFallback = `/proxy/twitch-api/helix/clips?broadcaster_id=${encodeURIComponent(uid)}&first=5&started_at=${encodeURIComponent(since)}`;