Added mappings

This commit is contained in:
Eduard Urbach 2017-07-07 15:44:06 +02:00
parent 6d130bcdea
commit ac8aa301c1

View File

@ -14,7 +14,7 @@ func main() {
color.Yellow("Syncing Anime")
// Get a stream of all anime
allAnime := kitsu.StreamAnime()
allAnime := kitsu.StreamAnimeWithMappings()
// Iterate over the stream
for anime := range allAnime {
@ -77,6 +77,22 @@ func sync(data *kitsu.Anime) {
anime.Title.Japanese = attr.Titles.JaJp
}
// Import mappings
for _, mapping := range data.Mappings {
switch mapping.Attributes.ExternalSite {
case "myanimelist/anime":
anime.AddMapping("myanimelist/anime", mapping.Attributes.ExternalID, "")
case "anidb":
anime.AddMapping("anidb/anime", mapping.Attributes.ExternalID, "")
case "thetvdb/series":
anime.AddMapping("thetvdb/anime", mapping.Attributes.ExternalID, "")
case "thetvdb/season":
// Ignore
default:
color.Yellow("Unknown mapping: %s %s", mapping.Attributes.ExternalSite, mapping.Attributes.ExternalID)
}
}
// NSFW
if attr.Nsfw {
anime.NSFW = 1