Started working on media relations

This commit is contained in:
Eduard Urbach 2017-10-17 12:55:54 +02:00
parent 44b33b8215
commit dea7ab42fa

View File

@ -0,0 +1,35 @@
package main
import (
"fmt"
"strings"
"github.com/animenotifier/kitsu"
"github.com/fatih/color"
)
func main() {
color.Yellow("Syncing media relations with Kitsu DB")
kitsuMediaRelations := kitsu.StreamMediaRelations()
for mediaRelation := range kitsuMediaRelations {
// We only care about anime for now
if mediaRelation.Relationships.Source.Data.Type != "anime" || mediaRelation.Relationships.Destination.Data.Type != "anime" {
continue
}
relationType := strings.Replace(mediaRelation.Attributes.Role, "_", " ", -1)
fmt.Printf(
"%s %s has a %s which is %s %s\n",
mediaRelation.Relationships.Source.Data.Type,
mediaRelation.Relationships.Source.Data.ID,
color.GreenString(relationType),
mediaRelation.Relationships.Destination.Data.Type,
mediaRelation.Relationships.Destination.Data.ID,
)
}
color.Green("Finished.")
}