Cleanup
This commit is contained in:
parent
82de7b3f1c
commit
3d1891e1a7
40
patches/import-mal-genres/import-mal-genres.go
Normal file
40
patches/import-mal-genres/import-mal-genres.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/mal"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
var malDB = arn.Node.Namespace("mal").RegisterTypes((*mal.Anime)(nil))
|
||||
|
||||
func main() {
|
||||
defer arn.Node.Close()
|
||||
color.Yellow("Importing genres")
|
||||
|
||||
for anime := range arn.StreamAnime() {
|
||||
malID := anime.GetMapping("myanimelist/anime")
|
||||
|
||||
if malID == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
sync(anime, malID)
|
||||
}
|
||||
|
||||
color.Green("Finished importing genres")
|
||||
}
|
||||
|
||||
func sync(anime *arn.Anime, malID string) {
|
||||
obj, err := malDB.Get("Anime", malID)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
malAnime := obj.(*mal.Anime)
|
||||
anime.Genres = malAnime.Genres
|
||||
}
|
Loading…
Reference in New Issue
Block a user