From 82ac23c63cf40a67dfcda437b3990896d97e5394 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Wed, 11 Jun 2025 17:02:55 -0700 Subject: [PATCH] fix: dynamic uptime on footer causing spam in console --- tvapp2/index.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/tvapp2/index.js b/tvapp2/index.js index 84e127e0..71d39628 100755 --- a/tvapp2/index.js +++ b/tvapp2/index.js @@ -1296,7 +1296,7 @@ async function serveM3UPlaylist( req, res ) return; } - const cachedUrl = getCache( decodedUrl, req ); + const cachedUrl = getCache( req, decodedUrl ); if ( cachedUrl ) { const rewrittenPlaylist = await rewriteM3U( cachedUrl, req ); @@ -1369,7 +1369,7 @@ async function serveM3UPlaylist( req, res ) return; } - setCache( decodedUrl, tokenizedUrl, 4 * 60 * 60 * 1000, req ); + setCache( req, decodedUrl, tokenizedUrl, 4 * 60 * 60 * 1000 ); const hdUrl = tokenizedUrl.replace( 'tracks-v2a1', 'tracks-v1a1' ); const rewrittenPlaylist = await rewriteM3U( hdUrl, req ); @@ -1441,10 +1441,14 @@ async function serveHealthCheck( req, res ) try { const paramUrl = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'api' ); + const paramQuery = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'query' ); if ( !paramUrl ) { - Log.debug( `/api`, chalk.yellow( `[health]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `No API key passed to health check` ) ); + if ( paramQuery !== 'uptime' ) + { + Log.debug( `/api`, chalk.yellow( `[health]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `No API key passed to health check` ) ); + } } const statusCheck = @@ -1467,8 +1471,7 @@ async function serveHealthCheck( req, res ) 'Content-Type': 'application/json' }); - const paramQuery = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'query' ); - if ( paramQuery !== 'query' ) + if ( paramQuery !== 'uptime' ) { Log.ok( `/api`, chalk.yellow( `[health]` ), chalk.white( `✅` ), chalk.greenBright( `` ), chalk.gray( `Response` ), @@ -1789,7 +1792,7 @@ async function serveGZP( res, req ) cache > set */ -function setCache( key, value, ttl, req ) +function setCache( req, key, value, ttl ) { const expiry = Date.now() + ttl; cache.set( key, { @@ -1809,7 +1812,7 @@ function setCache( key, value, ttl, req ) cache > get */ -function getCache( key, req ) +function getCache( req, key ) { const cached = cache.get( key ); if ( cached && cached.expiry > Date.now() ) @@ -2021,13 +2024,17 @@ const server = http.createServer( ( req, resp ) => loadFile channel?url=https%3A%2F%2Ftvpass.org%2Fchannel%2Fabc-wabc-new-york-ny%2F */ - Log.debug( `http`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ), - chalk.blueBright( `` ), chalk.gray( `Request started` ), - chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), - chalk.blueBright( `` ), chalk.gray( `${ req.url }` ), - chalk.blueBright( `` ), chalk.gray( `${ reqUrl }` ), - chalk.blueBright( `` ), chalk.gray( `${ loadFile }` ), - chalk.blueBright( `` ), chalk.gray( `${ method }` ) ); + const paramQuery = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'query' ); + if ( paramQuery !== 'uptime' ) + { + Log.debug( `http`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ), + chalk.blueBright( `` ), chalk.gray( `Request started` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ req.url }` ), + chalk.blueBright( `` ), chalk.gray( `${ reqUrl }` ), + chalk.blueBright( `` ), chalk.gray( `${ loadFile }` ), + chalk.blueBright( `` ), chalk.gray( `${ method }` ) ); + } if ( subdomainRestart.some( ( urlKeyword ) => loadFile.startsWith( urlKeyword ) ) ) {