From 4c0d49508f6335a5a733e2c4408cd41a34613a4a Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Tue, 30 Sep 2025 22:52:21 -0700 Subject: [PATCH] feat: add git.binaryninja.net health check; stop overwriting m3u/epg when down stops the app from wiping the m3u and xml file if the bit.binaryninja.net repo /website is down --- tvapp2/index.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/tvapp2/index.js b/tvapp2/index.js index 60804a0e..cb5ab6c4 100755 --- a/tvapp2/index.js +++ b/tvapp2/index.js @@ -159,6 +159,19 @@ const fileIpContainer = '/var/run/s6/container_environment/IP_CONTAINER'; const envIpGateway = fs.existsSync( fileIpGateway ) ? fs.readFileSync( fileIpGateway, 'utf8' ) : `0.0.0.0`; const envIpContainer = fs.existsSync( fileIpContainer ) ? fs.readFileSync( fileIpContainer, 'utf8' ) : `0.0.0.0`; +/* + Hosts +*/ + +const hosts = +[ + { name: 'TVPass.org', url: 'https://tvpass.org' }, + { name: 'TheTVApp.to', url: 'https://thetvapp.to' }, + { name: 'MoveOnJoy.com', url: 'http://moveonjoy.com' }, + { name: 'Daddylive.dad', url: 'https://daddylivestream.com' }, + { name: 'git.binaryninja.com', url: envUrlRepo } +]; + /* Get Server OS @@ -630,7 +643,35 @@ async function getFile( url, filePath ) chalk.blueBright( `` ), chalk.gray( `${ url }` ), chalk.blueBright( `` ), chalk.gray( `${ filePath }` ) ); - await downloadFile( url, filePath ); + const ok = await hostCheck( 'git.binaryninja.com', `${ envUrlRepo }` ); + + if ( ok ) + { + try + { + await downloadFile( url, filePath ); + return true; + } + catch ( err ) + { + Log.error( `file`, chalk.redBright( `[download]` ), chalk.white( `❌` ), + chalk.redBright( `` ), chalk.gray( `Download attempt failed after service check succeeded` ), + chalk.redBright( `` ), chalk.gray( `${ err.message }` ), + chalk.redBright( `` ), chalk.gray( `${ url }` ), + chalk.redBright( `` ), chalk.gray( `${ filePath }` ) ); + + return false; + } + } + else + { + Log.info( `file`, chalk.yellow( `[download]` ), chalk.white( `ℹ️` ), + chalk.yellowBright( `` ), chalk.gray( `Skipping download because service is offline; using existing local file` ), + chalk.yellowBright( `` ), chalk.gray( `${ url }` ), + chalk.yellowBright( `` ), chalk.gray( `${ filePath }` ) ); + + return false; + } } catch ( err ) {