Spaces:
Paused
Paused
File size: 1,250 Bytes
801eb21 44fe9f2 801eb21 44fe9f2 8368055 13e8fd1 4b43dc3 60c44c1 13e8fd1 60c44c1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | const fs = require('fs');
let code = fs.readFileSync('index.js', 'utf8');
// Patch 1: PUBLIC_URL support
code = code.replace(
'function getLocalBaseUrl() {\n return `http://${httpHost}:${port}`;\n}',
'function getLocalBaseUrl() {\n if (process.env.PUBLIC_URL) return process.env.PUBLIC_URL;\n return `http://${httpHost}:${port}`;\n}'
);
// Patch 2: EPG header
code = code.replace(
"const output = ['#EXTM3U'];",
"const output = ['#EXTM3U url-tvg=\"http://www.epg-guide.com/it.gz\" x-tvg-url=\"http://www.epg-guide.com/it.gz\"'];"
);
// Patch 3: insert epgId variable and use it in EXTINF
const oldLine = "output.push(`#EXTINF:-1 tvg-name=\"${channel.name}\" group-title=\"${channel.country}\" tvg-logo=\"${channel.logo}\" tvg-id=\"${channel.name}\",${channel.name}`);";
const newLine = "const epgId = channel.name.toLowerCase().replace(/ \\.[cs]$/, '').trim();\n output.push(`#EXTINF:-1 tvg-name=\"${channel.name}\" group-title=\"${channel.country}\" tvg-logo=\"${channel.logo}\" tvg-id=\"${epgId}\",${channel.name}`);";
if (code.includes(oldLine)) {
code = code.replace(oldLine, newLine);
console.log('Patch 3 OK');
} else {
console.log('Patch 3 FAILED - line not found');
}
fs.writeFileSync('index.js', code); |