mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-24 17:35:16 +00:00
Daniel Mason
723077ce2d
- Fix spotify image import on scrobble for new artists/albums - Create image resizer
46 lines
933 B
Go
46 lines
933 B
Go
package goscrobble
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
var endTicker chan bool
|
|
|
|
func StartBackgroundWorkers() {
|
|
endTicker := make(chan bool)
|
|
|
|
minuteTicker := time.NewTicker(time.Duration(60) * time.Second)
|
|
hourTicker := time.NewTicker(time.Duration(1) * time.Hour)
|
|
|
|
go func() {
|
|
for {
|
|
select {
|
|
case <-endTicker:
|
|
fmt.Println("Stopping background workers")
|
|
return
|
|
case <-minuteTicker.C:
|
|
// Update playdata from Spotify
|
|
go updateSpotifyData()
|
|
|
|
// Update playdate from Navidrome
|
|
go updateNavidromeData()
|
|
|
|
// There should only be whatever new images are in pending
|
|
go resizeImages()
|
|
case <-hourTicker.C:
|
|
// Clear old password reset tokens
|
|
go clearOldResetTokens()
|
|
|
|
// Attempt to pull missing images from spotify - hackerino version!
|
|
user, _ := getUserByUsername("idanoo")
|
|
go user.updateImageDataFromSpotify()
|
|
}
|
|
}
|
|
}()
|
|
}
|
|
|
|
func EndBackgroundWorkers() {
|
|
endTicker <- true
|
|
}
|