fix: group beIN Sports 1 variants and clarify Laya language warning (#15)
beIN Sports 1 variants stayed separated after projection because names with region prefixes (C Car, C Reu, Thai), time-shift suffixes (2h/4h/8h/12h) and language markers (En, Fr, Thai) produced distinct fingerprints. Extend normalization in the server projection service and the frontend grouping fallback to fold these into one logical channel, with tests on the exact reported names. Clarify the Laya language detection warning so a language-matching failure is not mistaken for a grouping failure, and bump script versions for cache refresh. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -5,6 +5,8 @@ const QUALITY_TOKENS = new Set([
|
||||
'1080p', '1080i', '720p', '576p', '480p'
|
||||
]);
|
||||
const REGION_PREFIX = /^(?:(?:\|\s*[a-z]{2,3}\s*\|)|(?:[a-z]{2,3}(?:-[a-z]{2,3})?\s*\|))\s*/i;
|
||||
const BEIN_SUFFIX_TOKENS = new Set(['fr', 'en', 'thai', 'tod', 'appel', 'app']);
|
||||
const BEIN_TIMESHIFT_TOKENS = new Set(['2h', '4h', '8h', '12h']);
|
||||
|
||||
function words(value) {
|
||||
return String(value || '')
|
||||
@ -18,7 +20,23 @@ function words(value) {
|
||||
}
|
||||
|
||||
function normalizeChannelName(name) {
|
||||
return words(name).filter(token => !QUALITY_TOKENS.has(token)).join(' ').trim();
|
||||
const tokens = words(name).filter(token => !QUALITY_TOKENS.has(token));
|
||||
const brandIndex = tokens.findIndex((token, index) => token === 'bein' && tokens[index + 1] === 'sports');
|
||||
if (brandIndex >= 0) {
|
||||
const branded = tokens.slice(brandIndex);
|
||||
const numberedBaseLength = branded[2] === 'max' && /^\d+$/.test(branded[3])
|
||||
? 4
|
||||
: (/^\d+$/.test(branded[2]) ? 3 : 0);
|
||||
if (numberedBaseLength) {
|
||||
const suffix = branded.slice(numberedBaseLength);
|
||||
const removable = suffix.every(token =>
|
||||
BEIN_SUFFIX_TOKENS.has(token) || BEIN_TIMESHIFT_TOKENS.has(token)
|
||||
);
|
||||
if (removable) return branded.slice(0, numberedBaseLength).join(' ');
|
||||
}
|
||||
return branded.join(' ').trim();
|
||||
}
|
||||
return tokens.join(' ').trim();
|
||||
}
|
||||
|
||||
function displayNameForFingerprint(fingerprint) {
|
||||
|
||||
Reference in New Issue
Block a user