44 lines
897 B
Go
Raw Normal View History

2017-07-01 23:44:10 +00:00
package main
import (
"fmt"
2017-07-09 13:56:40 +00:00
"github.com/animenotifier/anilist"
2017-07-01 23:44:10 +00:00
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
var userName = "Akyoto"
var allAnime []*arn.Anime
func init() {
allAnime, _ = arn.AllAnime()
}
func main() {
2017-07-09 13:56:40 +00:00
arn.PanicOnError(anilist.Authorize())
println(anilist.AccessToken)
2017-07-01 23:44:10 +00:00
user, _ := arn.GetUserByNick(userName)
2017-07-09 13:56:40 +00:00
animeList, err := anilist.GetAnimeList(user.Accounts.AniList.Nick)
2017-07-01 23:44:10 +00:00
arn.PanicOnError(err)
importList(animeList.Lists.Watching)
importList(animeList.Lists.Completed)
}
2017-07-09 13:56:40 +00:00
func importList(animeListItems []*anilist.AnimeListItem) {
2017-07-01 23:44:10 +00:00
imported := []*arn.Anime{}
for _, item := range animeListItems {
anime := arn.FindAniListAnime(item.Anime, allAnime)
if anime != nil {
fmt.Println(item.Anime.TitleRomaji, "=>", anime.Title.Romaji)
imported = append(imported, anime)
}
}
color.Green("%d / %d", len(imported), len(animeListItems))
}