feat: schedule preview

This commit is contained in:
Mateusz Pstrucha committed 2021-11-30 21:54:52 +01:00
1 parent 741d8fff6b
commit 5e6625157f
2 files changed
+39

No files matched your search

+7
View File
@@ -29,6 +29,10 @@ const args = yargs(process.argv.slice(2))
alias: 'm',
type: 'boolean',
})
.option('cache', {
alias: 'c',
type: 'boolean',
})
.option('tid', {
alias: 'T',
})
@@ -87,4 +91,7 @@ switch (args._[0]) {
case 'cache':
cache({ missingOnly: args.m })
break
case 'schedule':
schedule({ checkCache: args.c })
break
}
+32
View File
@@ -0,0 +1,32 @@
import { limit } from '../env.js'
import { getTop } from './modules/calls.js'
import { logSchedule, logTrack } from './modules/log.js'
import { parse, scheduler } from './modules/parse.js'
import { check, convert } from './modules/youtube.js'
export default async function schedule({ checkCache }) {
const { schedule, tracks, ends } = await getTop() // tids
.then((tids) => tids.slice(0, limit))
.then(convert) // Tracks
.then(parse) // chart
.then(scheduler) // schedule
for (let przerwa in schedule) {
let _tracks = tracks[przerwa],
_times = schedule[przerwa],
end = ends[przerwa]
for (let n in _tracks) {
let track = _tracks[n],
starts = _times[n]
if (checkCache) var { size } = check(`cache/${track.tid}.mp4`)
logSchedule(starts)
logTrack(track, { color: size ? undefined : 'red' })
}
logSchedule(end, `#${przerwa} End`)
}
}