Started working on media relations
This commit is contained in:
parent
44b33b8215
commit
dea7ab42fa
35
jobs/sync-media-relations/sync-media-relations.go
Normal file
35
jobs/sync-media-relations/sync-media-relations.go
Normal 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.")
|
||||
}
|
Loading…
Reference in New Issue
Block a user