Updated MAL tools
This commit is contained in:
parent
85cd5538b6
commit
3a6cd6b3bc
@ -41,11 +41,11 @@ func main() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return readFile(name)
|
return readAnimeFile(name)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func readFile(name string) error {
|
func readAnimeFile(name string) error {
|
||||||
file, err := os.Open(name)
|
file, err := os.Open(name)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -89,8 +89,8 @@ func readFile(name string) error {
|
|||||||
modified = true
|
modified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if existing.ImagePath != character.ImagePath {
|
if existing.Image != character.Image {
|
||||||
existing.ImagePath = character.ImagePath
|
existing.Image = character.Image
|
||||||
modified = true
|
modified = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,3 +103,36 @@ func readFile(name string) error {
|
|||||||
arn.MAL.Set("Anime", anime.ID, anime)
|
arn.MAL.Set("Anime", anime.ID, anime)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readCharacterFile(name string) error {
|
||||||
|
file, err := os.Open(name)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
reader, err := gzip.NewReader(file)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
character, err := malparser.ParseCharacter(reader)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
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
|
||||||
|
}
|
||||||
|
@ -29,7 +29,7 @@ func InvokeShellArgs() bool {
|
|||||||
panic("No MAL ID")
|
panic("No MAL ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
readFile(path.Join(arn.Root, "jobs/mal-download/anime", "anime-"+anime.GetMapping("myanimelist/anime")+".html"))
|
readAnimeFile(path.Join(arn.Root, "jobs/mal-download/anime", "anime-"+anime.GetMapping("myanimelist/anime")+".html"))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ func syncCharacters(anime *arn.Anime, malAnime *mal.Anime) {
|
|||||||
|
|
||||||
malCharacter := obj.(*mal.Character)
|
malCharacter := obj.(*mal.Character)
|
||||||
|
|
||||||
if malCharacter.ID == "" || malCharacter.Name == "" || malCharacter.ImagePath == "" {
|
if malCharacter.ID == "" || malCharacter.Name == "" || malCharacter.Image == "" {
|
||||||
fmt.Println("Skip character:", malAnimeCharacter.ID)
|
fmt.Println("Skip character:", malAnimeCharacter.ID)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ func syncCharacters(anime *arn.Anime, malAnime *mal.Anime) {
|
|||||||
|
|
||||||
// import character
|
// import character
|
||||||
func importCharacter(malCharacter *mal.Character) *arn.Character {
|
func importCharacter(malCharacter *mal.Character) *arn.Character {
|
||||||
fmt.Println("Importing MAL Character:", malCharacter.ID, malCharacter.Name, malCharacter.ImagePath)
|
fmt.Println("Importing MAL Character:", malCharacter.ID, malCharacter.Name, malCharacter.Image)
|
||||||
|
|
||||||
character := arn.NewCharacter()
|
character := arn.NewCharacter()
|
||||||
character.Name.Canonical = malCharacter.Name
|
character.Name.Canonical = malCharacter.Name
|
||||||
|
Loading…
Reference in New Issue
Block a user