Safer MAL sync

This commit is contained in:
Eduard Urbach 2018-04-17 15:33:19 +02:00
parent 03d8414551
commit 5127e1b6d2

View File

@ -9,7 +9,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
) )
const malImageLargeWidth = 285 const imageWidthThreshold = 225
var ( var (
malDB = arn.Node.Namespace("mal").RegisterTypes((*mal.Anime)(nil)) malDB = arn.Node.Namespace("mal").RegisterTypes((*mal.Anime)(nil))
@ -95,7 +95,7 @@ func sync(anime *arn.Anime, malID string) {
anime.Title.English = malAnime.EnglishTitle anime.Title.English = malAnime.EnglishTitle
} }
if (!anime.HasImage() || anime.Image.Width < malImageLargeWidth) && malAnime.Image != "" { if (!anime.HasImage() || anime.Image.Width <= imageWidthThreshold) && malAnime.Image != "" {
fmt.Println("Downloading image:", malAnime.Image) fmt.Println("Downloading image:", malAnime.Image)
response, err := client.Get(malAnime.Image).End() response, err := client.Get(malAnime.Image).End()