mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-22 00:21:55 +00:00
Daniel Mason
b1de018b27
- Spotify will now add images on scrobble - Renamed /api/v1/track to tracks to bypass blocklists... (uBlock :()
39 lines
620 B
Go
39 lines
620 B
Go
package goscrobble
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
var endTicker chan bool
|
|
|
|
func StartBackgroundWorkers() {
|
|
updateSpotifyData()
|
|
|
|
endTicker := make(chan bool)
|
|
|
|
hourTicker := time.NewTicker(time.Hour)
|
|
minuteTicker := time.NewTicker(time.Duration(60) * time.Second)
|
|
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <-endTicker:
|
|
fmt.Println("Stopping background workers")
|
|
return
|
|
case <-hourTicker.C:
|
|
// Clear old password reset tokens
|
|
clearOldResetTokens()
|
|
|
|
case <-minuteTicker.C:
|
|
// Update playdata from spotify
|
|
updateSpotifyData()
|
|
}
|
|
}
|
|
}()
|
|
}
|
|
|
|
func EndBackgroundWorkers() {
|
|
endTicker <- true
|
|
}
|