Add backend language detection, flexible live channel search, iptv-org catalog caching, and protected built-in EPG source registration. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
21 lines
1.2 KiB
JavaScript
21 lines
1.2 KiB
JavaScript
const BUILTIN_EPG_SOURCES = Object.freeze([
|
|
Object.freeze({ builtinKey: 'epgpw-fr', type: 'epg', name: 'EPG.PW France', url: 'https://epg.pw/xmltv/epg_FR.xml.gz', provider: 'EPG.PW', language: 'fr', country: 'FR', priority: 100 }),
|
|
Object.freeze({ builtinKey: 'epgpw-us', type: 'epg', name: 'EPG.PW United States', url: 'https://epg.pw/xmltv/epg_US.xml.gz', provider: 'EPG.PW', language: 'en', country: 'US', priority: 90 })
|
|
]);
|
|
|
|
function protectedFields(source) {
|
|
return source?.builtinKey ? { readonly: true, removable: false } : { readonly: false, removable: true };
|
|
}
|
|
|
|
function ensureBuiltinSources(database) {
|
|
database.sources ||= [];
|
|
for (const definition of BUILTIN_EPG_SOURCES) {
|
|
const existing = database.sources.find(source => source.builtinKey === definition.builtinKey);
|
|
if (existing) Object.assign(existing, definition, protectedFields(definition));
|
|
else database.sources.push({ id: database.nextId++, ...definition, ...protectedFields(definition), enabled: false, created_at: new Date().toISOString(), updated_at: new Date().toISOString() });
|
|
}
|
|
return database;
|
|
}
|
|
|
|
module.exports = { BUILTIN_EPG_SOURCES, ensureBuiltinSources, protectedFields };
|