cosmetic: new log points, self closing
This commit is contained in:
1 parent
c94fa0a9b8
commit
b0aa24dbc9
2 files changed
+29
-12
No files matched your search
@@ -9,7 +9,9 @@ import Track from './Track.js'
|
||||
|
||||
dotenv.config()
|
||||
|
||||
const defaultVolume = parseInt(process.env.VOLUME_DEFAULT)
|
||||
const defaultVolume = parseInt(process.env.VOLUME_DEFAULT),
|
||||
offset = Number(process.env.OFFSET),
|
||||
verbose = Number(process.env.VERBOSE)
|
||||
|
||||
function play(track) {
|
||||
queueCommand('volume', [defaultVolume])
|
||||
@@ -25,8 +27,11 @@ function sToHM(seconds) {
|
||||
return [h, m]
|
||||
}
|
||||
|
||||
console.info(`_______________________________`)
|
||||
console.info(`Fetching playlist data`)
|
||||
console.info(
|
||||
`Volume: ${chalk.yellow(defaultVolume)}, Verbose: ${chalk.yellow(verbose)}`
|
||||
)
|
||||
|
||||
console.info(`Fetching playlist (${chalk.yellow(process.env.DOMAIN)})`)
|
||||
|
||||
getTop()
|
||||
.then(async (data) => {
|
||||
@@ -54,9 +59,13 @@ getTop()
|
||||
throw err
|
||||
})
|
||||
.then((schedule) => {
|
||||
let currentSeconds = now()
|
||||
let currentSeconds = now() - offset
|
||||
|
||||
console.info(`Running track scheduler`)
|
||||
console.info(
|
||||
`Running track scheduler @${new Date().toLocaleTimeString()} +${chalk.yellow(
|
||||
offset
|
||||
)}s`
|
||||
)
|
||||
|
||||
for (let nthPrzerwa in seconds) {
|
||||
let [begin, end] = seconds[nthPrzerwa]
|
||||
@@ -100,9 +109,10 @@ getTop()
|
||||
}, sched * 1e3)
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
console.info(`Beginning of #${nthPrzerwa} in 10s`)
|
||||
}, (begin - currentSeconds) * 1e3 - 10e3)
|
||||
verbose > 0 &&
|
||||
setTimeout(() => {
|
||||
console.info(`Beginning of #${nthPrzerwa} in 10s`)
|
||||
}, (begin - currentSeconds) * 1e3 - 10e3)
|
||||
|
||||
let endin = end - currentSeconds,
|
||||
[h, m] = sToHM(end)
|
||||
@@ -113,9 +123,16 @@ getTop()
|
||||
console.info(`Ending playback for #${nthPrzerwa}`)
|
||||
player.fadeOut(6)
|
||||
updateStatus(null, null, null, true)
|
||||
|
||||
if (nthPrzerwa == seconds.length - 1) {
|
||||
console.info(`--- Day Ended ---`)
|
||||
setTimeout(() => {
|
||||
process.exit(0)
|
||||
}, 20e3)
|
||||
}
|
||||
}, endin * 1e3)
|
||||
}
|
||||
|
||||
console.info(`Track scheduling done`)
|
||||
console.info(`‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾`)
|
||||
console.info(`\nTrack scheduling done`)
|
||||
console.info(`_______________________________`)
|
||||
})
|
||||
+2
-2
@@ -14,7 +14,7 @@ radio.stdout.on('data', (data) => {
|
||||
for (let line of lines) {
|
||||
let [status, ...data] = JSON.parse(line)
|
||||
|
||||
verbose > 0 && console.log(' -> ', status, data)
|
||||
verbose > 0 && console.info(' -> ', status, data)
|
||||
|
||||
if (status == 'waiting')
|
||||
if (data[0]) {
|
||||
@@ -35,7 +35,7 @@ radio.on('close', (code) => {
|
||||
})
|
||||
|
||||
function sendCommand(comm, data = [null]) {
|
||||
verbose > 1 && console.log(' <- ', comm, data)
|
||||
verbose > 1 && console.info(' <- ', comm, data)
|
||||
busy = true
|
||||
radio.stdin.write(JSON.stringify(['command', comm, ...data]) + '\n')
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user