46 lines
736 B
Go
Raw Normal View History

2018-10-31 23:23:41 +00:00
package main
import (
"compress/gzip"
"errors"
"os"
2019-04-23 05:52:55 +00:00
"github.com/akyoto/color"
2019-04-30 14:59:53 +00:00
malparser "github.com/animenotifier/mal/parser"
2019-06-07 01:03:16 +00:00
"github.com/animenotifier/notify.moe/arn"
2018-10-31 23:23:41 +00:00
)
// 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
}