Updated MAL sync

This commit is contained in:
2018-11-01 08:23:41 +09:00
parent 3ccf470cf0
commit 9d57aaf12a
5 changed files with 169 additions and 124 deletions

View File

@ -0,0 +1,45 @@
package main
import (
"compress/gzip"
"errors"
"os"
"github.com/animenotifier/arn"
"github.com/animenotifier/mal/parser"
"github.com/fatih/color"
)
// Read character file
func readCharacterFile(name string) error {
file, err := os.Open(name)
if err != nil {
color.Red(err.Error())
return err
}
defer file.Close()
reader, err := gzip.NewReader(file)
if err != nil {
color.Red(err.Error())
return err
}
character, err := malparser.ParseCharacter(reader)
if err != nil {
color.Red(err.Error())
return err
}
if character.ID == "" {
return errors.New("Empty ID")
}
// fmt.Println(character.ID, character.Name)
arn.MAL.Set("Character", character.ID, character)
return nil
}