Added image parser
This commit is contained in:
parent
0a0cbf6467
commit
03d8414551
@ -3,11 +3,14 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/aerogo/http/client"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
const malImageLargeWidth = 285
|
||||
|
||||
var (
|
||||
malDB = arn.Node.Namespace("mal").RegisterTypes((*mal.Anime)(nil))
|
||||
characterFinder = arn.NewCharacterFinder("myanimelist/character")
|
||||
@ -92,6 +95,17 @@ func sync(anime *arn.Anime, malID string) {
|
||||
anime.Title.English = malAnime.EnglishTitle
|
||||
}
|
||||
|
||||
if (!anime.HasImage() || anime.Image.Width < malImageLargeWidth) && malAnime.Image != "" {
|
||||
fmt.Println("Downloading image:", malAnime.Image)
|
||||
response, err := client.Get(malAnime.Image).End()
|
||||
|
||||
if err == nil && response.StatusCode() == 200 {
|
||||
anime.SetImageBytes(response.Bytes())
|
||||
} else {
|
||||
color.Red("Error downloading image")
|
||||
}
|
||||
}
|
||||
|
||||
// Check for existence of characters
|
||||
animeCharacters := anime.Characters()
|
||||
modifiedCharacters := false
|
||||
|
Loading…
Reference in New Issue
Block a user