2018-04-22 15:43:20 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
"github.com/fatih/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
color.Yellow("Adding creation dates")
|
|
|
|
|
|
|
|
defer color.Green("Finished")
|
|
|
|
defer arn.Node.Close()
|
|
|
|
|
2018-04-23 12:12:53 +00:00
|
|
|
baseTime := time.Now().Add(-6 * 30 * 24 * time.Hour)
|
2018-04-22 15:43:20 +00:00
|
|
|
irregular := time.Duration(0)
|
|
|
|
|
|
|
|
for character := range arn.StreamCharacters() {
|
2018-04-24 00:46:20 +00:00
|
|
|
// Skip manually created characters
|
|
|
|
if character.CreatedBy != "" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2018-04-22 15:43:20 +00:00
|
|
|
malID := character.GetMapping("myanimelist/character")
|
|
|
|
|
|
|
|
if malID != "" {
|
|
|
|
malIDNumber, err := strconv.Atoi(malID)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
character.Created = baseTime.Add(time.Duration(malIDNumber) * time.Minute).Format(time.RFC3339)
|
|
|
|
} else {
|
|
|
|
irregular++
|
|
|
|
character.Created = baseTime.Add(-irregular * time.Minute).Format(time.RFC3339)
|
|
|
|
}
|
|
|
|
|
|
|
|
character.Save()
|
|
|
|
}
|
|
|
|
}
|