From 7cfe22b72eb75d7d9623705ead0fdce78264b466 Mon Sep 17 00:00:00 2001 From: Aetherinox Date: Wed, 1 Oct 2025 00:47:55 -0700 Subject: [PATCH] feat: add HDHomeRun `lineup.json` to api --- tvapp2/index.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/tvapp2/index.js b/tvapp2/index.js index f73c73af..1d892512 100755 --- a/tvapp2/index.js +++ b/tvapp2/index.js @@ -2343,6 +2343,10 @@ const server = http.createServer( ( req, resp ) => chalk.blueBright( `` ), chalk.gray( `${ loadFile }` ), chalk.blueBright( `` ), chalk.gray( `${ method }` ) ); + /* + Main Server › Discovery.json + */ + if ( loadFile === 'discovery.json' ) { Log.notice( `http`, chalk.yellowBright( `[notice]` ), chalk.white( `📌` ), @@ -2356,7 +2360,7 @@ const server = http.createServer( ( req, resp ) => FirmwareName: tunerInstance.FirmwareName, FirmwareVersion: tunerInstance.FirmwareVersion, DeviceID: tunerInstance.GetDeviceId(), - TunerCount: `10`, + TunerCount: tunerInstance.SlotsMax, BaseURL: `${ envIpContainer }:${ envHdhrPort }`, LineupURL: `${ envIpContainer }:${ envHdhrPort }/lineup.json`, client: clientIp( req ), @@ -2595,6 +2599,10 @@ const serverHdHomeRun = http.createServer( ( req, resp ) => chalk.blueBright( `` ), chalk.gray( `${ loadFile }` ), chalk.blueBright( `` ), chalk.gray( `${ method }` ) ); + /* + HDHomeRun › Discovery.json + */ + if ( loadFile === 'discovery.json' ) { Log.notice( `http`, chalk.yellowBright( `[notice]` ), chalk.white( `📌` ), @@ -2608,7 +2616,7 @@ const serverHdHomeRun = http.createServer( ( req, resp ) => FirmwareName: tunerInstance.FirmwareName, FirmwareVersion: tunerInstance.FirmwareVersion, DeviceID: tunerInstance.GetDeviceId(), - TunerCount: `10`, + TunerCount: tunerInstance.SlotsMax, BaseURL: `${ envIpContainer }:${ envHdhrPort }`, LineupURL: `${ envIpContainer }:${ envHdhrPort }/lineup.json`, client: clientIp( req ), @@ -2639,6 +2647,51 @@ const serverHdHomeRun = http.createServer( ( req, resp ) => return; } + /* + HDHomeRun › Lineup.json + */ + + if ( loadFile === 'lineup.json' ) + { + const tunerInstance = new Tuner(); + const hdHomeRun = + { + FriendlyName: tunerInstance.FriendlyName, + ModelNumber: tunerInstance.ModelNumber, + FirmwareName: tunerInstance.FirmwareName, + FirmwareVersion: tunerInstance.FirmwareVersion, + DeviceID: tunerInstance.GetDeviceId(), + TunerCount: tunerInstance.SlotsMax, + BaseURL: `${ envIpContainer }:${ envHdhrPort }`, + LineupURL: `${ envIpContainer }:${ envHdhrPort }/lineup.json`, + client: clientIp( req ), + status: 'healthy', + code: 200, + uptime: Math.round( process.uptime() ), + uptimeShort: timeAgo.format( Date.now() - process.uptime() * 1000, 'twitter' ), + uptimeLong: timeAgo.format( Date.now() - process.uptime() * 1000, 'round' ), + timestamp: Date.now(), + channels: `[]` + }; + + resp.writeHead( hdHomeRun.code, { + 'Content-Type': 'application/json' + }); + + Log.ok( `http`, chalk.yellow( `[requests]` ), chalk.white( `✅` ), + chalk.blueBright( `` ), chalk.gray( `Lineup requested` ), + chalk.blueBright( `` ), chalk.gray( `${ clientIp( req ) }` ), + chalk.blueBright( `` ), chalk.gray( `${ hdHomeRun.FriendlyName }` ), + chalk.blueBright( `` ), chalk.gray( `${ hdHomeRun.ModelNumber }` ), + chalk.blueBright( `` ), chalk.gray( `${ hdHomeRun.DeviceID }` ), + chalk.blueBright( `` ), chalk.gray( `${ hdHomeRun.TunerCount }` ), + chalk.blueBright( `` ), chalk.whiteBright.bgBlack( ` ${ hdHomeRun.BaseURL } ` ), + chalk.blueBright( `` ), chalk.whiteBright.bgBlack( ` ${ hdHomeRun.LineupURL } ` ) ); + + resp.end( JSON.stringify( hdHomeRun ) ); + return; + } + const statusCheck = { ip: envIpContainer,