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

View File

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

View File

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

View File

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

View File

@ -7,26 +7,34 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
) )
var ticker = time.NewTicker(500 * time.Millisecond)
func main() { func main() {
color.Yellow("Refreshing osu information") color.Yellow("Refreshing osu information")
defer color.Green("Finished.")
defer arn.Node.Close() defer arn.Node.Close()
ticker := time.NewTicker(500 * time.Millisecond)
for user := range arn.StreamUsers() { for user := range arn.StreamUsers() {
// Get osu info if user.Accounts.Osu.Nick == "" {
if user.RefreshOsuInfo() == nil { continue
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()
} }
// Fetch new info
err := user.RefreshOsuInfo()
if err != nil {
color.Red(err.Error())
continue
}
// Log it
arn.PrettyPrint(user.Accounts.Osu)
// Save in database
user.Save()
// Wait for rate limiter // Wait for rate limiter
<-ticker.C <-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 // 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() { func main() {
color.Yellow("Updating anime image average colors") color.Yellow("Updating anime image average colors")
defer arn.Node.Close()
defer color.Green("Finished.") defer color.Green("Finished.")
defer arn.Node.Close()
// Parse flags // Parse flags
var animeID string var animeID string

View File

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