From e398e1acc4fd424015942290dd7b87a8668d99b0 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Sun, 4 May 2025 13:29:44 -0700 Subject: [PATCH] refactor: log category labels --- tvapp2/index.js | 331 +++++++++++++++++++++++++++++------------------- 1 file changed, 203 insertions(+), 128 deletions(-) diff --git a/tvapp2/index.js b/tvapp2/index.js index 26b1d67a..0f2eb12a 100755 --- a/tvapp2/index.js +++ b/tvapp2/index.js @@ -61,7 +61,6 @@ let FILE_GZP_SIZE = 0; let FILE_M3U_MODIFIED = 0; let FILE_XML_MODIFIED = 0; let FILE_GZP_MODIFIED = 0; -const FOLDER_WWW = 'www'; /* Define > Environment Variables || Defaults @@ -318,13 +317,14 @@ const semaphore = new Semaphore( 5 ); async function downloadFile( url, filePath ) { - Log.info( `file`, chalk.yellow( `[download]` ), chalk.white( `ℹ️` ), - chalk.blueBright( `` ), chalk.gray( `Downloading external file` ), - chalk.blueBright( `` ), chalk.gray( `${ url }` ), - chalk.blueBright( `` ), chalk.gray( `${ filePath }` ) ); - return new Promise( ( resolve, reject ) => { + + Log.info( `file`, chalk.yellow( `[download]` ), chalk.white( `ℹ️` ), + chalk.blueBright( `` ), chalk.gray( `Preparing to download external file` ), + chalk.blueBright( `` ), chalk.gray( `${ url }` ), + chalk.blueBright( `` ), chalk.gray( `${ filePath }` ) ); + const isHttps = new URL( url ).protocol === 'https:'; const httpModule = isHttps ? https : http; const file = fs.createWriteStream( filePath ); @@ -334,10 +334,10 @@ async function downloadFile( url, filePath ) if ( response.statusCode !== 200 ) { Log.error( `file`, chalk.redBright( `[download]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Attempt to download file returned non-200 status` ), + chalk.redBright( `` ), chalk.gray( `Attempt to download external file returned non-200 status` ), + chalk.redBright( `` ), chalk.gray( `${ response.statusCode }` ), chalk.redBright( `` ), chalk.gray( `${ url }` ), - chalk.redBright( `` ), chalk.gray( `${ filePath }` ), - chalk.redBright( `` ), chalk.gray( `${ response.statusCode }` ) ); + chalk.redBright( `` ), chalk.gray( `${ filePath }` ) ); return reject( new Error( `Failed to download file: ${ url }. Status code: ${ response.statusCode }` ) ); } @@ -345,10 +345,10 @@ async function downloadFile( url, filePath ) file.on( 'finish', () => { Log.ok( `file`, chalk.yellow( `[download]` ), chalk.white( `✅` ), - chalk.greenBright( `` ), chalk.gray( `Successfully downloaded and wrote new file` ), + chalk.greenBright( `` ), chalk.gray( `Successfully downloaded external file` ), + chalk.greenBright( `` ), chalk.gray( `${ response.statusCode }` ), chalk.greenBright( `` ), chalk.gray( `${ url }` ), - chalk.greenBright( `` ), chalk.gray( `${ filePath }` ), - chalk.greenBright( `` ), chalk.gray( `${ response.statusCode }` ) ); + chalk.greenBright( `` ), chalk.gray( `${ filePath }` ) ); file.close( () => resolve( true ) ); }); @@ -356,7 +356,7 @@ async function downloadFile( url, filePath ) .on( 'error', ( err ) => { Log.error( `file`, chalk.redBright( `[download]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Failed to download source file` ), + chalk.redBright( `` ), chalk.gray( `Failed to download external source file` ), chalk.redBright( `` ), chalk.gray( `${ err.message }` ), chalk.redBright( `` ), chalk.gray( `${ url }` ), chalk.redBright( `` ), chalk.gray( `${ filePath }` ) ); @@ -442,7 +442,7 @@ async function getFile( url, filePath ) try { Log.debug( `file`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Requesting to download file` ), + chalk.blueBright( `` ), chalk.gray( `Requesting to download external file` ), chalk.blueBright( `` ), chalk.gray( `${ url }` ), chalk.blueBright( `` ), chalk.gray( `${ filePath }` ) ); @@ -453,9 +453,9 @@ async function getFile( url, filePath ) if ( fs.existsSync( filePath ) ) { Log.warn( `file`, chalk.yellow( `[requests]` ), chalk.white( `⚠️` ), - chalk.blueBright( `` ), chalk.gray( `Download failed - Using existing local file ${ filePath }` ), - chalk.blueBright( `` ), chalk.gray( `${ url }` ), - chalk.blueBright( `` ), chalk.gray( `${ filePath }` ) ); + chalk.yellowBright( `` ), chalk.gray( `Download failed - Using existing local file ${ filePath }` ), + chalk.yellowBright( `` ), chalk.gray( `${ url }` ), + chalk.yellowBright( `` ), chalk.gray( `${ filePath }` ) ); } else { @@ -478,76 +478,72 @@ async function getFile( url, filePath ) async function createGzip( ) { - Log.info( `gzip`, chalk.yellow( `[generate]` ), chalk.white( `ℹ️` ), - chalk.blueBright( `` ), chalk.gray( `Preparing to create compressed XML gz file` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileGZP }` ) ); - return new Promise( ( resolve, reject ) => { - Log.debug( `gzip`, chalk.yellow( `[generate]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Promise to create compressed gz started` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + + Log.info( `.gzp`, chalk.yellow( `[generate]` ), chalk.white( `ℹ️` ), + chalk.blueBright( `` ), chalk.gray( `Preparing to create compressed XML gz file` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); fs.readFile( FILE_XML, ( err, buf ) => { - Log.debug( `gzip`, chalk.yellow( `[generate]` ), chalk.white( `⚙️` ), + Log.debug( `.gzp`, chalk.yellow( `[generate]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `Reading source XML file` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.blueBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); if ( err ) { - Log.error( `gzip`, chalk.redBright( `[generate]` ), chalk.white( `❌` ), + Log.error( `.gzp`, chalk.redBright( `[generate]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Could not read source XML file` ), chalk.redBright( `` ), chalk.gray( `${ err }` ), - chalk.redBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.redBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.redBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.redBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); return reject( new Error( `Could not read file ${ envFileXML }. Error: ${ err }` ) ); } zlib.gzip( buf, ( err, buf ) => { - Log.debug( `gzip`, chalk.yellow( `[generate]` ), chalk.white( `⚙️` ), + Log.debug( `.gzp`, chalk.yellow( `[generate]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `Starting zlib.gzip` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.blueBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); if ( err ) { - Log.error( `gzip`, chalk.redBright( `[generate]` ), chalk.white( `❌` ), + Log.error( `.gzp`, chalk.redBright( `[generate]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Could not create gz archive` ), chalk.redBright( `` ), chalk.gray( `${ err }` ), - chalk.redBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.redBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.redBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.redBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); return reject( new Error( `Could not create ${ envFileGZP }. Error: ${ err }` ) ); } - Log.info( `gzip`, chalk.yellow( `[generate]` ), chalk.white( `ℹ️` ), + Log.info( `.gzp`, chalk.yellow( `[generate]` ), chalk.white( `ℹ️` ), chalk.blueBright( `` ), chalk.gray( `Started creating gz archive from XML source` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.blueBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.blueBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); fs.writeFile( `${ FILE_GZP }`, buf, ( err ) => { if ( err ) { - Log.error( `gzip`, chalk.redBright( `[generate]` ), chalk.white( `❌` ), + Log.error( `.gzp`, chalk.redBright( `[generate]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Could not write to and create gz archive` ), chalk.redBright( `` ), chalk.gray( `${ err }` ), - chalk.redBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.redBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.redBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.redBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); return reject( new Error( `Could not write XML file ${ envFileXML } to ${ envFileGZP }. Error: ${ err }` ) ); } - Log.ok( `gzip`, chalk.yellow( `[generate]` ), chalk.white( `✅` ), + Log.ok( `.gzp`, chalk.yellow( `[generate]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `Successfully created compressed gz archive from XML source file` ), - chalk.greenBright( `` ), chalk.gray( `${ envFileXML }` ), - chalk.greenBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + chalk.greenBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.greenBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); resolve( true ); }); @@ -566,22 +562,29 @@ async function getGzip( ) { try { + Log.debug( `.gzp`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Requesting to create compressed gzip from uncompressed XML data` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.blueBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); + await createGzip( ); } catch ( err ) { if ( fs.existsSync( FILE_XML ) ) { - Log.warn( `gzip`, chalk.yellow( `[compress]` ), chalk.white( `⚠️` ), - chalk.blueBright( `` ), chalk.yellowBright( `Source xml file found, but gzip failed generate a compressed .gz fileL` ), - chalk.blueBright( `` ), chalk.gray( `${ FILE_XML }` ) ); + Log.warn( `.gzp`, chalk.yellow( `[requests]` ), chalk.white( `⚠️` ), + chalk.yellowBright( `` ), chalk.yellowBright( `Cannot get compressed gzip; but source XML file found and can be used` ), + chalk.yellowBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.yellowBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); } else { - Log.error( `gzip`, chalk.redBright( `[compress]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Source XML file not found; cannot create compressed gzip` ), + Log.error( `.gzp`, chalk.redBright( `[requests]` ), chalk.white( `❌` ), + chalk.redBright( `` ), chalk.gray( `Failed to get compressed gzip, and source XML file not found` ), chalk.redBright( `` ), chalk.gray( `${ err.message }` ), - chalk.redBright( `` ), chalk.gray( `${ FILE_XML }` ) ); + chalk.redBright( `` ), chalk.gray( `${ FILE_XML }` ), + chalk.redBright( `` ), chalk.gray( `${ FILE_GZP }` ) ); throw err; } @@ -621,15 +624,17 @@ async function fetchRemote( url, req ) } }, ( resp ) => { - Log.info( `conn`, chalk.yellow( `[retrieve]` ), chalk.white( `ℹ️` ), - chalk.blueBright( `` ), chalk.gray( `Processing encoding types for remote fetch` ), + Log.info( `remo`, chalk.yellow( `[retrieve]` ), chalk.white( `ℹ️` ), + chalk.blueBright( `` ), chalk.gray( `Getting response from remote fetch request` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ resp.statusCode }` ), chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); if ( resp.statusCode !== 200 ) { - Log.error( `conn`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Server returned status code other than 200` ), + Log.error( `remo`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), + chalk.redBright( `` ), chalk.gray( `Remote fetch returned status code other than 200` ), + chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ resp.statusCode }` ), chalk.redBright( `` ), chalk.gray( `${ url }` ) ); @@ -650,8 +655,9 @@ async function fetchRemote( url, req ) { if ( err ) { - Log.error( `conn`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Could not complete encoding type ${ encoding }` ), + Log.error( `remo`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), + chalk.redBright( `` ), chalk.gray( `Remote fetch could not complete encoding type ${ encoding }` ), + chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ err }` ), chalk.redBright( `` ), chalk.gray( `${ encoding }` ), chalk.redBright( `` ), chalk.gray( `${ resp.statusCode }` ), @@ -660,8 +666,9 @@ async function fetchRemote( url, req ) return reject( err ); } - Log.debug( `conn`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Processing encoding type ${ encoding }` ), + Log.debug( `remo`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Remote fetch detected encoding type ${ encoding }; decoding` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ encoding }` ), chalk.blueBright( `` ), chalk.gray( `${ resp.statusCode }` ), chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); @@ -675,8 +682,9 @@ async function fetchRemote( url, req ) { if ( err ) { - Log.error( `conn`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Could not complete encoding type ${ encoding }` ), + Log.error( `remo`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), + chalk.redBright( `` ), chalk.gray( `Remote fetch could not complete encoding type ${ encoding }` ), + chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ err }` ), chalk.redBright( `` ), chalk.gray( `${ encoding }` ), chalk.redBright( `` ), chalk.gray( `${ resp.statusCode }` ), @@ -685,8 +693,9 @@ async function fetchRemote( url, req ) return reject( err ); } - Log.debug( `conn`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Processing encoding type ${ encoding }` ), + Log.debug( `remo`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Remote fetch detected encoding type ${ encoding }; decoding` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ encoding }` ), chalk.blueBright( `` ), chalk.gray( `${ resp.statusCode }` ), chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); @@ -700,8 +709,9 @@ async function fetchRemote( url, req ) { if ( err ) { - Log.error( `conn`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), - chalk.redBright( `` ), chalk.gray( `Could not complete encoding type ${ encoding } (brotli decompress)` ), + Log.error( `remo`, chalk.redBright( `[retrieve]` ), chalk.white( `❌` ), + chalk.redBright( `` ), chalk.gray( `Remote fetch could not complete encoding type ${ encoding } (brotli decompress)` ), + chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ err }` ), chalk.redBright( `` ), chalk.gray( `${ encoding }` ), chalk.redBright( `` ), chalk.gray( `${ resp.statusCode }` ), @@ -710,8 +720,9 @@ async function fetchRemote( url, req ) return reject( err ); } - Log.debug( `conn`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Processing encoding type ${ encoding } (brotli decompress)` ), + Log.debug( `remo`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Remote fetch detected encoding type ${ encoding } (brotli decompress); decoding` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ encoding }` ), chalk.blueBright( `` ), chalk.gray( `${ resp.statusCode }` ), chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); @@ -721,6 +732,13 @@ async function fetchRemote( url, req ) } else { + Log.debug( `remo`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Remote fetch contains no headers to decode; resolving buffer` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ encoding }` ), + chalk.blueBright( `` ), chalk.gray( `${ resp.statusCode }` ), + chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); + resolve( buffer ); } }); @@ -729,6 +747,12 @@ async function fetchRemote( url, req ) }); } +/* + Serve Keys + + @url https://tvapp2.domain.lan/keys?uri=https://v16.thetvapp.to/hls/WABCDT1/tracks-v2a1/mono.m3u8?token=a0b2C-1ae-qaxAV5iKAd8g&expires=1746394920&user_id=EjLZVsIiJphafFxXRVWRdVWPvzTqpWBZbchvsTwpAlrQZzFuZMpdSn== +*/ + async function serveKey( req, res ) { try @@ -765,8 +789,8 @@ async function serveKey( req, res ) return res.end( JSON.stringify( statusCheck ) ); } - Log.debug( `conn`, chalk.yellow( `[response]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Valid paramUrl specified; establishing connection` ), + Log.debug( `keys`, chalk.yellow( `[response]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Valid paramUrl specified; establishing connection to serve key to client` ), chalk.blueBright( `` ), chalk.gray( `serveKey` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ req.url }` ), @@ -777,8 +801,8 @@ async function serveKey( req, res ) 'Content-Type': 'application/octet-stream' }); - Log.ok( `key`, chalk.yellow( `[response]` ), chalk.white( `✅` ), - chalk.greenBright( `` ), chalk.greenBright( `Found valid uri parameter` ), + Log.ok( `keys`, chalk.yellow( `[response]` ), chalk.white( `✅` ), + chalk.greenBright( `` ), chalk.gray( `Serving key to client` ), chalk.greenBright( `` ), chalk.gray( `serveKey` ), chalk.greenBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.greenBright( `` ), chalk.gray( `200` ), @@ -795,7 +819,7 @@ async function serveKey( req, res ) ip: envIpContainer, gateway: envIpGateway, client: clientIp( req ), - message: `Failed to serve key; try{} failed`, + message: `Failed to serve key; try{} failed. Ensure you specify a valid uri to tvapp / tvpass`, error: `${ err.message }`, status: 'unhealthy', ref: req.url, @@ -809,7 +833,7 @@ async function serveKey( req, res ) 'Content-Type': 'application/json' }); - Log.error( `key`, chalk.yellow( `[response]` ), chalk.white( `❌` ), + Log.error( `keys`, chalk.yellow( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), chalk.redBright( `` ), chalk.gray( `serveKey` ), chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), @@ -848,7 +872,7 @@ function buildCookieHeader() return pairs.join( '; ' ); } -function fetchPage( url ) +function fetchPage( url, req ) { return new Promise( ( resolve, reject ) => { @@ -865,15 +889,17 @@ function fetchPage( url ) { Log.info( `http`, chalk.yellow( `[retrieve]` ), chalk.white( `ℹ️` ), chalk.blueBright( `` ), chalk.gray( `status code returned` ), - chalk.blueBright( `` ), chalk.gray( `${ url }` ), - chalk.blueBright( `` ), chalk.gray( `${ res.statusCode }` ) ); + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ res.statusCode }` ), + chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); if ( res.statusCode !== 200 ) { Log.debug( `http`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `failed to load url; status 200 was not returned` ), - chalk.blueBright( `` ), chalk.gray( `${ url }` ), - chalk.blueBright( `` ), chalk.gray( `${ res.statusCode }` ) ); + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ res.statusCode }` ), + chalk.blueBright( `` ), chalk.gray( `${ url }` ) ); return reject( new Error( `page did not return code 200 status ${ res.statusCode } => ${ url }` ) ); } @@ -881,10 +907,11 @@ function fetchPage( url ) if ( res.headers['set-cookie']) { Log.debug( `http`, chalk.yellow( `[retrieve]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `setting headers` ), - chalk.blueBright( `` ), chalk.gray( `${ url }` ), - chalk.blueBright( `
` ), chalk.gray( `set-cookie` ), - chalk.blueBright( `` ), chalk.gray( `${ res.statusCode }` ) ); + chalk.blueBright( `` ), chalk.gray( `setting headers` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ res.statusCode }` ), + chalk.blueBright( `` ), chalk.gray( `${ url }` ), + chalk.blueBright( `
` ), chalk.gray( `set-cookie` ) ); parseSetCookieHeaders( res.headers['set-cookie']); } @@ -901,13 +928,12 @@ async function getTokenizedUrl( channelUrl, req ) { try { - const html = await fetchPage( channelUrl ); - + const html = await fetchPage( channelUrl, req ); let streamName; let streamHost; - Log.debug( `m3u8`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Attempting to tokenize url ` ), + Log.debug( `play`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Requesting to get tokenize url ` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ channelUrl }` ) ); @@ -924,7 +950,7 @@ async function getTokenizedUrl( channelUrl, req ) const streamNameMatch = html.match( /id="stream_name" name="([^"]+)"/ ); if ( !streamNameMatch ) { - Log.error( `m3u8`, chalk.yellow( `[tokenize]` ), chalk.white( `❌` ), + Log.error( `play`, chalk.yellow( `[tokenize]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Cannot find streamNameMatch; returned empty` ), chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.grey( `${ channelUrl }` ), @@ -935,7 +961,7 @@ async function getTokenizedUrl( channelUrl, req ) streamName = streamNameMatch[1]; - Log.debug( `m3u8`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), + Log.debug( `play`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `streamName found` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ channelUrl }` ), @@ -954,10 +980,10 @@ async function getTokenizedUrl( channelUrl, req ) }; const tokenUrl = `https://${ streamHost }/token/${ streamName }?quality=${ envStreamQuality.toLowerCase() }`; - const tokenResponse = await fetchPage( tokenUrl ); + const tokenResponse = await fetchPage( tokenUrl, req ); let tokenizedUrl; - Log.debug( `m3u8`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), + Log.debug( `play`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `Generating tokenized final stream URL` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ channelUrl }` ), @@ -972,7 +998,7 @@ async function getTokenizedUrl( channelUrl, req ) const json = JSON.parse( tokenResponse ); tokenizedUrl = json.url; - Log.debug( `m3u8`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), + Log.debug( `play`, chalk.yellow( `[tokenize]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `Returned token response in json format` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `${ channelUrl }` ), @@ -985,7 +1011,7 @@ async function getTokenizedUrl( channelUrl, req ) } catch ( err ) { - Log.error( `m3u8`, chalk.redBright( `[tokenize]` ), chalk.white( `❌` ), + Log.error( `play`, chalk.redBright( `[tokenize]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Failed to parse token JSON for channel` ), chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ channelUrl }` ), @@ -1000,7 +1026,7 @@ async function getTokenizedUrl( channelUrl, req ) if ( !tokenizedUrl ) { - Log.error( `m3u8`, chalk.redBright( `[tokenize]` ), chalk.white( `❌` ), + Log.error( `play`, chalk.redBright( `[tokenize]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `No URL found in token JSON for channel` ), chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ channelUrl }` ), @@ -1013,7 +1039,7 @@ async function getTokenizedUrl( channelUrl, req ) return null; } - Log.ok( `m3u8`, chalk.yellow( `[tokenize]` ), chalk.white( `✅` ), + Log.ok( `play`, chalk.yellow( `[tokenize]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `Successfully generated token for stream` ), chalk.greenBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.greenBright( `` ), chalk.gray( `${ channelUrl }` ), @@ -1028,7 +1054,7 @@ async function getTokenizedUrl( channelUrl, req ) } catch ( err ) { - Log.error( `m3u8`, chalk.redBright( `[tokenize]` ), chalk.white( `❌` ), + Log.error( `play`, chalk.redBright( `[tokenize]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Fatal error fetching token` ), chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ err.message }` ), @@ -1047,6 +1073,11 @@ async function serveM3UPlaylist( req, res ) await semaphore.acquire(); try { + Log.debug( `plst`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Requesting to serve M3U playlist` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ req.url }` ) ); + /* paramUrl > decodedUrl > tokenizedUrl */ @@ -1072,7 +1103,7 @@ async function serveM3UPlaylist( req, res ) 'Content-Type': 'application/json' }); - Log.error( `m3u8`, chalk.redBright( `[response]` ), chalk.white( `❌` ), + Log.error( `plst`, chalk.redBright( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), chalk.redBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.code }` ), @@ -1090,7 +1121,7 @@ async function serveM3UPlaylist( req, res ) Location: decodedUrl }); - Log.notice( `m3u8`, chalk.yellow( `[response]` ), chalk.white( `📌` ), + Log.notice( `plst`, chalk.yellow( `[response]` ), chalk.white( `📌` ), chalk.yellowBright( `` ), chalk.gray( `decodedUrl ends with .ts script; (302) redirecting` ), chalk.yellowBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.yellowBright( `` ), chalk.gray( `302` ), @@ -1112,8 +1143,8 @@ async function serveM3UPlaylist( req, res ) 'Content-Disposition': 'inline; filename="' + envFileM3U }); - Log.debug( `m3u8`, chalk.yellow( `[response]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `serving already cached m3u playlist to client` ), + Log.debug( `plst`, chalk.yellow( `[response]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `serving cachedUrl m3u playlist to client` ), chalk.blueBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.blueBright( `` ), chalk.gray( `200` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), @@ -1125,7 +1156,8 @@ async function serveM3UPlaylist( req, res ) return; } - Log.info( `m3u8`, chalk.yellow( `[response]` ), chalk.white( `ℹ️` ), + Log.info( `plst`, chalk.yellow( `[response]` ), chalk.white( `ℹ️` ), + chalk.blueBright( `` ), chalk.gray( `request not cached; generating new tokenizedUrl for m3u playlist to client` ), chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.blueBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.blueBright( `` ), chalk.gray( `${ paramUrl }` ), @@ -1157,7 +1189,7 @@ async function serveM3UPlaylist( req, res ) 'Content-Type': 'application/json' }); - Log.error( `m3u8`, chalk.redBright( `[response]` ), chalk.white( `❌` ), + Log.error( `plst`, chalk.redBright( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), chalk.redBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.code }` ), @@ -1166,7 +1198,6 @@ async function serveM3UPlaylist( req, res ) chalk.redBright( `` ), chalk.gray( `${ tokenizedUrl }` ) ); res.end( JSON.stringify( statusCheck ) ); - return; } @@ -1179,18 +1210,17 @@ async function serveM3UPlaylist( req, res ) 'Content-Disposition': 'inline; filename="' + envFileM3U }); - res.end( rewrittenPlaylist ); - - Log.ok( `m3u8`, chalk.yellow( `[response]` ), chalk.white( `✅` ), - chalk.greenBright( `` ), chalk.gray( `Serving new playlist to client` ), + Log.ok( `plst`, chalk.yellow( `[response]` ), chalk.white( `✅` ), + chalk.greenBright( `` ), chalk.gray( `Serving new tokenizedUrl with m3u playlist to client` ), chalk.greenBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.greenBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.greenBright( `` ), chalk.gray( `200` ), chalk.greenBright( `` ), chalk.gray( `${ envFileM3U }` ), chalk.greenBright( `` ), chalk.gray( `${ paramUrl }` ), chalk.greenBright( `` ), chalk.gray( `${ decodedUrl }` ), - chalk.greenBright( `` ), chalk.gray( `${ tokenizedUrl }` ), - chalk.greenBright( `` ), chalk.gray( `${ hdUrl }` ) ); + chalk.greenBright( `` ), chalk.gray( `${ tokenizedUrl }` ) ); + + res.end( rewrittenPlaylist ); } catch ( err ) { @@ -1215,7 +1245,7 @@ async function serveM3UPlaylist( req, res ) 'Content-Type': 'application/json' }); - Log.error( `m3u8`, chalk.redBright( `[response]` ), chalk.white( `❌` ), + Log.error( `plst`, chalk.redBright( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `Failed to serve m3u playlist` ), chalk.redBright( `` ), chalk.gray( `serveM3UPlaylist` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), @@ -1261,10 +1291,10 @@ async function serveHealthCheck( req, res ) }); Log.ok( `/api`, chalk.yellow( `[health]` ), chalk.white( `✅` ), - chalk.greenBright( `` ), chalk.gray( `health check response` ), + chalk.greenBright( `` ), chalk.gray( `response` ), chalk.greenBright( `` ), chalk.gray( `${ clientIp( req ) }` ), - chalk.greenBright( `` ), chalk.gray( `${ statusCheck.status }` ), chalk.greenBright( `` ), chalk.gray( `${ statusCheck.code }` ), + chalk.greenBright( `` ), chalk.gray( `${ statusCheck.status }` ), chalk.greenBright( `` ), chalk.gray( `${ process.uptime() }` ) ); res.end( JSON.stringify( statusCheck ) ); @@ -1295,8 +1325,8 @@ async function serveHealthCheck( req, res ) Log.error( `/api`, chalk.redBright( `[health]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message } response` ), - chalk.redBright( `` ), chalk.gray( `${ statusCheck.status }` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.code }` ), + chalk.redBright( `` ), chalk.gray( `${ statusCheck.status }` ), chalk.redBright( `` ), chalk.gray( `${ clientIp( req ) }` ), chalk.redBright( `` ), chalk.gray( `${ err.message }` ), chalk.redBright( `` ), chalk.gray( `${ process.uptime() }` ) ); @@ -1316,7 +1346,7 @@ async function serveHealthCheck( req, res ) async function rewriteM3U( originalUrl, req ) { - const rawData = await fetchRemote( originalUrl ); + const rawData = await fetchRemote( originalUrl, req ); const protocol = req.headers['x-forwarded-proto']?.split( ',' )[0] || ( req.socket.encrypted ? 'https' : 'http' ); const host = req.headers.host; const baseUrl = `${ protocol }://${ host }`; @@ -1366,7 +1396,7 @@ async function serveM3U( res, req ) 'Content-Disposition': 'inline; filename="' + envFileM3U }); - Log.ok( `m3u8`, chalk.yellow( `[response]` ), chalk.white( `✅` ), + Log.ok( `.m3u`, chalk.yellow( `[response]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `Successfully served m3u8 channel playlist data` ), chalk.greenBright( `` ), chalk.gray( `serveM3U` ), chalk.greenBright( `` ), chalk.gray( `200` ), @@ -1398,7 +1428,7 @@ async function serveM3U( res, req ) 'Content-Type': 'application/json' }); - Log.error( `m3u8`, chalk.yellow( `[response]` ), chalk.white( `❌` ), + Log.error( `.m3u`, chalk.yellow( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), chalk.redBright( `` ), chalk.gray( `serveM3U` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.code }` ), @@ -1429,7 +1459,7 @@ async function serveXML( res, req ) 'Content-Disposition': 'inline; filename="' + envFileXML }); - Log.ok( `xml`, chalk.yellow( `[response]` ), chalk.white( `✅` ), + Log.ok( `.xml`, chalk.yellow( `[response]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `Successfully served uncompressed xml / epg guide data` ), chalk.greenBright( `` ), chalk.gray( `serveXML` ), chalk.greenBright( `` ), chalk.gray( `200` ), @@ -1461,7 +1491,7 @@ async function serveXML( res, req ) 'Content-Type': 'text/plain' }); - Log.error( `xml`, chalk.yellow( `[response]` ), chalk.white( `❌` ), + Log.error( `.xml`, chalk.yellow( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), chalk.redBright( `` ), chalk.gray( `serveXML` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.code }` ), @@ -1492,7 +1522,7 @@ async function serveGZP( res, req ) 'Content-Disposition': 'inline; filename="' + envFileGZP }); - Log.ok( `gzip`, chalk.yellow( `[response]` ), chalk.white( `✅` ), + Log.ok( `.gzp`, chalk.yellow( `[response]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `Successfully served compressed gzip xml/epg guide data` ), chalk.greenBright( `` ), chalk.gray( `serveGZP` ), chalk.greenBright( `` ), chalk.gray( `200` ), @@ -1524,7 +1554,7 @@ async function serveGZP( res, req ) 'Content-Type': 'text/plain' }); - Log.error( `gzip`, chalk.yellow( `[response]` ), chalk.white( `❌` ), + Log.error( `.gzp`, chalk.yellow( `[response]` ), chalk.white( `❌` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.message }` ), chalk.redBright( `` ), chalk.gray( `serveGZP` ), chalk.redBright( `` ), chalk.gray( `${ statusCheck.code }` ), @@ -1599,13 +1629,13 @@ async function initialize() chalk.blueBright( `` ), chalk.gray( `${ envIpContainer }` ), chalk.blueBright( `` ), chalk.gray( `${ envWebPort }` ) ); - Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `FILE_URL` ), - chalk.blueBright( `` ), chalk.gray( `${ FILE_URL }` ) ); + /* + Debug > network + */ - Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `FILE_M3U` ), - chalk.blueBright( `` ), chalk.gray( `${ FILE_M3U }` ) ); + Log.debug( `.net`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `IP_CONTAINER` ), chalk.blueBright( `` ), chalk.gray( `${ envIpContainer }` ) ); + Log.debug( `.net`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `IP_GATEWAY` ), chalk.blueBright( `` ), chalk.gray( `${ envIpGateway }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `RELEASE` ), chalk.blueBright( `` ), chalk.gray( `${ envAppRelease }` ) ); /* Debug > Verbose > environment vars @@ -1617,6 +1647,51 @@ async function initialize() Log.verbose( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `📣` ), chalk.blueBright( `` ), chalk.gray( `${ key }` ), chalk.blueBright( `` ), chalk.gray( `${ env[key] }` ) ); }); + /* + Debug > environment vars + + we could just loop process.env; but that will show every container env var. We just want this app + */ + + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `URL_REPO` ), chalk.blueBright( `` ), chalk.gray( `${ envUrlRepo }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `WEB_IP` ), chalk.blueBright( `` ), chalk.gray( `${ envWebIP }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `WEB_PORT` ), chalk.blueBright( `` ), chalk.gray( `${ envWebPort }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `WEB_FOLDER` ), chalk.blueBright( `` ), chalk.gray( `${ envWebFolder }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `WEB_ENCODING` ), chalk.blueBright( `` ), chalk.gray( `${ envWebEncoding }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `WEB_PROXY_HEADER` ), chalk.blueBright( `` ), chalk.gray( `${ envProxyHeader }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `STREAM_QUALITY` ), chalk.blueBright( `` ), chalk.gray( `${ envStreamQuality }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `API_KEY` ), chalk.blueBright( `` ), chalk.gray( `${ envApiKey }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `FILE_URL` ), chalk.blueBright( `` ), chalk.gray( `${ envFileURL }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `FILE_M3U` ), chalk.blueBright( `` ), chalk.gray( `${ envFileM3U }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `FILE_EPG` ), chalk.blueBright( `` ), chalk.gray( `${ envFileXML }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `FILE_GZP` ), chalk.blueBright( `` ), chalk.gray( `${ envFileGZP }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `HEALTH_TIMER` ), chalk.blueBright( `` ), chalk.gray( `${ envHealthTimer }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `LOG_LEVEL` ), chalk.blueBright( `` ), chalk.gray( `${ LOG_LEVEL }` ) ); + Log.debug( `.env`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `USERAGENT` ), chalk.blueBright( `` ), chalk.gray( `${ USERAGENT }` ) ); + + /* + Debug > vars > external urls + */ + + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `extURL` ), chalk.blueBright( `` ), chalk.gray( `${ extURL }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `extXML` ), chalk.blueBright( `` ), chalk.gray( `${ extXML }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `extM3U` ), chalk.blueBright( `` ), chalk.gray( `${ extM3U }` ) ); + + /* + Debug > vars > subdomain keywords + */ + + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainGZP` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainGZP.join() }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainM3U` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainM3U.join() }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainEPG` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainEPG.join() }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainKey` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainKey.join() }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainChan` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainChan.join() }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainHealth` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainHealth.join() }` ) ); + Log.debug( `.var`, chalk.yellow( `[assigner]` ), chalk.white( `⚙️` ), chalk.blueBright( `` ), chalk.gray( `subdomainRestart` ), chalk.blueBright( `` ), chalk.gray( `${ subdomainRestart.join() }` ) ); + + /* + get files + */ await getFile( extURL, FILE_URL ); await getFile( extXML, FILE_XML ); @@ -2034,7 +2109,7 @@ const server = http.createServer( ( request, response ) => { if ( !envApiKey ) Log.warn( `/api`, chalk.yellow( `[callback]` ), chalk.white( `⚠️` ), - chalk.blueBright( `` ), chalk.gray( `API_KEY environment variable not defined for api, leaving blank` ) ); + chalk.yellowBright( `` ), chalk.gray( `API_KEY environment variable not defined for api, leaving blank` ) ); else Log.ok( `/api`, chalk.yellow( `[callback]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `API_KEY environment variable successfully assigned` ) );