Improved jobs

This commit is contained in:
Eduard Urbach 2018-03-21 05:15:03 +01:00
parent 71d6ba9848
commit 18cca18ebe
8 changed files with 28 additions and 20 deletions

View File

@ -25,7 +25,7 @@ var colorPool = []*color.Color{
var jobs = map[string]time.Duration{
"anime-ratings": 10 * time.Minute,
// "test": 1 * time.Hour,
"test": 1 * time.Hour,
"twist": 4 * time.Hour,
// "refresh-episodes": 10 * time.Hour,
// "refresh-osu": 12 * time.Hour,

View File

@ -11,8 +11,8 @@ import (
func main() {
color.Yellow("Importing Kitsu anime")
defer arn.Node.Close()
defer color.Green("Finished.")
defer arn.Node.Close()
// In case we refresh only one anime
if InvokeShellArgs() {

View File

@ -11,8 +11,8 @@ import (
func main() {
color.Yellow("Importing Kitsu mappings")
defer arn.Node.Close()
defer color.Green("Finished.")
defer arn.Node.Close()
// Iterate over all mappings
for mapping := range kitsu.StreamMappings() {

View File

@ -16,8 +16,8 @@ import (
func main() {
color.Yellow("Importing MAL anime")
defer arn.Node.Close()
defer color.Green("Finished.")
defer arn.Node.Close()
// readFile("../mal-download/files/anime-31240.html")

View File

@ -7,26 +7,34 @@ import (
"github.com/fatih/color"
)
var ticker = time.NewTicker(500 * time.Millisecond)
func main() {
color.Yellow("Refreshing osu information")
defer color.Green("Finished.")
defer arn.Node.Close()
ticker := time.NewTicker(500 * time.Millisecond)
for user := range arn.StreamUsers() {
// Get osu info
if user.RefreshOsuInfo() == nil {
if user.Accounts.Osu.Nick == "" {
continue
}
// Fetch new info
err := user.RefreshOsuInfo()
if err != nil {
color.Red(err.Error())
continue
}
// Log it
arn.PrettyPrint(user.Accounts.Osu)
// Fetch user again to prevent writing old data
updatedUser, _ := arn.GetUser(user.ID)
updatedUser.Accounts.Osu = user.Accounts.Osu
updatedUser.Save()
}
// Save in database
user.Save()
// Wait for rate limiter
<-ticker.C
}
color.Green("Finished.")
}

View File

@ -116,5 +116,5 @@ func search(anime *arn.Anime, title string) {
}
// This will start a goroutine that saves the anime
anime.SetMapping("shoboi/anime", shoboi.TID, "")
anime.SetMapping("shoboi/anime", shoboi.TID)
}

View File

@ -16,8 +16,8 @@ import (
func main() {
color.Yellow("Updating anime image average colors")
defer arn.Node.Close()
defer color.Green("Finished.")
defer arn.Node.Close()
// Parse flags
var animeID string

View File

@ -14,8 +14,8 @@ import (
func main() {
color.Yellow("Updating anime thumbnails")
defer arn.Node.Close()
defer color.Green("Finished.")
defer arn.Node.Close()
// Parse flags
var animeID string