mirror of
https://github.com/ArthurDanjou/artdanj-api.git
synced 2026-01-25 17:10:27 +01:00
Connect Athena to Spotify
This commit is contained in:
16
app/Tasks/CurrentSongTask.ts
Normal file
16
app/Tasks/CurrentSongTask.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import Logger from '@ioc:Adonis/Core/Logger'
|
||||
import { getCurrentPlayingFromSpotify } from 'App/Utils/SongUtils'
|
||||
|
||||
const MS = 1000
|
||||
let taskId
|
||||
|
||||
export async function Activate(): Promise<void> {
|
||||
Logger.info(`Starting task runner for watching spotify current playing [${MS} ms]`)
|
||||
await getCurrentPlayingFromSpotify()
|
||||
taskId = setInterval(getCurrentPlayingFromSpotify, MS)
|
||||
}
|
||||
|
||||
export function ShutDown(): void {
|
||||
clearInterval(taskId)
|
||||
Logger.info('Shutdown task runner for getting current developing state')
|
||||
}
|
||||
Reference in New Issue
Block a user