feat: add new env variables: FILE_PLAYLIST and FILE_EPG

This commit is contained in:
2025-03-21 02:12:10 -07:00
parent 6b88664db0
commit 03ab50f557

View File

@@ -57,6 +57,8 @@ const externalFORMATTED_1 = `${process.env.URL_REPO}/tvapp2-externals/raw/branch
const externalFORMATTED_2 = ''; const externalFORMATTED_2 = '';
const externalFORMATTED_3 = ''; const externalFORMATTED_3 = '';
const externalEvents = ''; const externalEvents = '';
const envFilePlaylist = process.env.FILE_PLAYLIST || `playlist.m3u8`;
const envFileEPG = process.env.FILE_EPG || `xmltv.xml`;
const LOG_LEVEL = process.env.LOG_LEVEL || 8; const LOG_LEVEL = process.env.LOG_LEVEL || 8;
/* /*
Define > Logs Define > Logs
@@ -535,9 +537,10 @@ async function serveChannelPlaylist(req, res) {
const cachedUrl = getCache(decodedUrl); const cachedUrl = getCache(decodedUrl);
if (cachedUrl) { if (cachedUrl) {
const rewrittenPlaylist = await rewritePlaylist(cachedUrl, req); const rewrittenPlaylist = await rewritePlaylist(cachedUrl, req);
res.writeHead(200, { res.writeHead(200,
{
'Content-Type': 'application/vnd.apple.mpegurl', 'Content-Type': 'application/vnd.apple.mpegurl',
'Content-Disposition': 'inline; filename="playlist.m3u8"', 'Content-Disposition': 'inline; filename="' + envFilePlaylist,
}); });
res.end(rewrittenPlaylist); res.end(rewrittenPlaylist);
return; return;
@@ -562,7 +565,7 @@ async function serveChannelPlaylist(req, res) {
const rewrittenPlaylist = await rewritePlaylist(hdUrl, req); const rewrittenPlaylist = await rewritePlaylist(hdUrl, req);
res.writeHead(200, { res.writeHead(200, {
'Content-Type': 'application/vnd.apple.mpegurl', 'Content-Type': 'application/vnd.apple.mpegurl',
'Content-Disposition': 'inline; filename="playlist.m3u8"', 'Content-Disposition': 'inline; filename="' + envFilePlaylist,
}); });
res.end(rewrittenPlaylist); res.end(rewrittenPlaylist);
@@ -622,7 +625,7 @@ async function servePlaylist(response, req) {
response.writeHead(200, { response.writeHead(200, {
'Content-Type': 'application/x-mpegURL', 'Content-Type': 'application/x-mpegURL',
'Content-Disposition': 'inline; filename="playlist.m3u8"', 'Content-Disposition': 'inline; filename="' + envFilePlaylist,
}); });
response.end(updatedContent); response.end(updatedContent);
@@ -636,6 +639,7 @@ async function servePlaylist(response, req) {
}); });
response.end(`Error serving playlist: ${error.message}`); response.end(`Error serving playlist: ${error.message}`);
response.end(`Error serving playlist: ${error.message}`);
} }
} }
@@ -731,6 +735,7 @@ function setCache(key, value, ttl) {
expiry expiry
}); });
Log.debug(`Cache set for key ${key} which expires in`, chalk.white(``), chalk.grey(`${ttl / 1000} seconds`));
} }
function getCache(key) { function getCache(key) {
@@ -853,9 +858,9 @@ const server = http.createServer((req, res) => {
const baseURL = window.location.origin; const baseURL = window.location.origin;
const playlistURL = baseURL + "/playlist"; const playlistURL = baseURL + "/playlist";
const epgURL = baseURL + "/epg"; const epgURL = baseURL + "/epg";
document.getElementById("playlist-url").textContent = playlistURL; document.getElementById("playlist-url").textContent = "${envFilePlaylist}";
document.getElementById("playlist-url").href = playlistURL; document.getElementById("playlist-url").href = playlistURL;
document.getElementById("epg-url").textContent = epgURL; document.getElementById("epg-url").textContent = "${envFileEPG}";
document.getElementById("epg-url").href = epgURL; document.getElementById("epg-url").href = epgURL;
</script> </script>
<script> <script>