2018-03-26 00:12:06 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
2019-04-23 05:45:17 +00:00
|
|
|
"github.com/akyoto/color"
|
2019-06-03 09:32:43 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2018-03-26 00:12:06 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
color.Yellow("Checking Kitsu for anilist mappings")
|
|
|
|
defer arn.Node.Close()
|
|
|
|
|
|
|
|
confirmed := 0
|
|
|
|
added := 0
|
|
|
|
conflicted := 0
|
|
|
|
|
2018-04-04 13:21:52 +00:00
|
|
|
finder := arn.NewAnimeFinder("kitsu/anime")
|
2018-04-04 12:51:55 +00:00
|
|
|
|
2018-03-26 00:12:06 +00:00
|
|
|
for mapping := range arn.StreamKitsuMappings() {
|
|
|
|
if mapping.Relationships.Item.Data.Type != "anime" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if mapping.Attributes.ExternalSite != "anilist" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
externalID := mapping.Attributes.ExternalID
|
2018-04-25 23:14:23 +00:00
|
|
|
externalID = strings.TrimPrefix(externalID, "anime/")
|
2018-03-26 00:12:06 +00:00
|
|
|
|
2018-04-04 13:08:18 +00:00
|
|
|
anime := finder.GetAnime(mapping.Relationships.Item.Data.ID)
|
2018-03-26 00:12:06 +00:00
|
|
|
|
|
|
|
if anime == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
currentID := anime.GetMapping("anilist/anime")
|
|
|
|
|
|
|
|
if currentID == "" {
|
|
|
|
added++
|
|
|
|
// color.Yellow("Added: %s (%v) on %s is %s", anime.ID, anime, mapping.Attributes.ExternalSite, externalID)
|
|
|
|
// color.Yellow("Added:\n * https://notify.moe/anime/%s\n * https://anilist.co/anime/%s\n\n", anime.ID, externalID)
|
|
|
|
} else {
|
|
|
|
if currentID == externalID {
|
|
|
|
confirmed++
|
|
|
|
// color.Green("Confirmed: %s (%v) on %s is %s", anime.ID, anime, mapping.Attributes.ExternalSite, externalID)
|
|
|
|
} else if currentID != externalID {
|
|
|
|
conflicted++
|
|
|
|
// color.Red("Conflict: %s (%v) on %s is %s but current value is %s", anime.ID, anime, mapping.Attributes.ExternalSite, externalID, currentID)
|
|
|
|
color.Red("Conflict (#%d):\n * https://notify.moe/anime/%s\n * https://anilist.co/anime/%s (current)\n * https://anilist.co/anime/%s (suggested)\n\n", conflicted, anime.ID, externalID, currentID)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// anime.SetMapping("anilist/anime", externalID)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("%d confirmed, %d added, %d conflicted\n", confirmed, added, conflicted)
|
|
|
|
}
|