Improved avatar generator

This commit is contained in:
2017-07-08 17:31:04 +02:00
parent 567d146b0e
commit c910e82a0a
2 changed files with 59 additions and 2 deletions

View File

@ -54,6 +54,9 @@ func main() {
&MyAnimeList{
RequestLimiter: time.NewTicker(250 * time.Millisecond),
},
&FileSystem{
Directory: "images/avatars/large/",
},
}
// Define the avatar outputs
@ -118,7 +121,6 @@ func StartWorkers(queue chan *arn.User, work func(*arn.User)) {
// Work handles a single user.
func Work(user *arn.User) {
fmt.Println(user.ID, "|", user.Nick)
user.AvatarExtension = ""
for _, source := range avatarSources {
@ -129,6 +131,13 @@ func Work(user *arn.User) {
continue
}
sourceType := reflect.TypeOf(source).Elem().Name()
// Avoid quality loss (if it's on the file system, we don't need to write it again)
if sourceType == "FileSystem" {
continue
}
for _, writer := range avatarOutputs {
err := writer.SaveAvatar(avatar)
@ -137,7 +146,7 @@ func Work(user *arn.User) {
}
}
fmt.Println(color.GreenString("✔"), reflect.TypeOf(source).Elem().Name(), "|", user.Nick, "|", avatar)
fmt.Println(color.GreenString("✔"), sourceType, "|", user.Nick, "|", avatar)
break
}