fix(themes): pages themes Twitch vides -> requetes Helix tokenisees + fallbacks game_id/top-streams

This commit is contained in:
2026-09-26 18:46:55 -04:00
parent db03b70854
commit 21f2296c41
4 changed files with 389 additions and 87 deletions
@@ -193,12 +193,15 @@ export class ProviderThemePageComponent implements OnDestroy {
const baseTokens = this.themes.tokensFor(slug);
if (provider === 'twitch') {
// Helix /search/channels et /search/categories ne matchent que des noms
// proches : une longue phrase multi-mots ("cooking food Food Cooking
// Recipe") ne retourne jamais rien. On envoie UN mot-clé court ; le
// service tente ensuite les variantes + game_id + top streams.
const twitchTokens = TWITCH_THEME_KEYWORDS[slug] || [];
const merged = [...new Set([...twitchTokens, ...baseTokens])];
const value = merged.join(' ').trim();
if (value) return value;
if (twitchTokens.length) return twitchTokens.join(' ');
return slug.replace(/-/g, ' ');
const first = (twitchTokens[0] || baseTokens[0] || slug.replace(/-/g, ' ') || '').trim();
// Garde le premier mot pour maximiser le taux de match Helix.
const short = String(first).split(/[^A-Za-z0-9à-ÿ]+/).filter(Boolean)[0] || first;
return (short || first || slug.replace(/-/g, ' ')).trim();
}
const value = baseTokens.join(' ').trim();
@@ -215,8 +215,10 @@ export class ThemePageComponent {
return;
}
// Twitch hors live/trending : VODs + clips + fallback top streams.
// Helix ne matche pas les longues phrases : un seul mot-clé court.
if (block.provider === 'twitch') {
const q = tokens.join(' ');
const raw = tokens.join(' ').trim();
const q = (raw.split(/[^A-Za-z0-9à-ÿ]+/).filter(w => w.length >= 3)[0] || raw).trim();
const call = q ? this.api.searchTwitchThemePage(q, null) : this.api.getTwitchTopStreamsPage(null);
call.subscribe({
next: res => {