fix(themes): pages themes Twitch vides -> requetes Helix tokenisees + fallbacks game_id/top-streams
This commit is contained in:
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user