New Kitsu import

This commit is contained in:
Eduard Urbach 2018-04-04 13:37:04 +02:00
parent 60f568b9b1
commit 1bc62ab105
2 changed files with 36 additions and 1 deletions

View File

@ -112,6 +112,7 @@ func getMatches(ctx *aero.Context) ([]*arn.KitsuMatch, string) {
// findAllMatches returns all matches for the anime inside an anilist anime list. // findAllMatches returns all matches for the anime inside an anilist anime list.
func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch { func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch {
allAnime := arn.AllAnime()
matches := []*arn.KitsuMatch{} matches := []*arn.KitsuMatch{}
for item := range library { for item := range library {
@ -122,7 +123,7 @@ func findAllMatches(library chan *kitsu.LibraryEntry) []*arn.KitsuMatch {
matches = append(matches, &arn.KitsuMatch{ matches = append(matches, &arn.KitsuMatch{
KitsuItem: item, KitsuItem: item,
ARNAnime: arn.FindKitsuAnime(item.Anime.ID), ARNAnime: arn.FindKitsuAnime(item.Anime.ID, allAnime),
}) })
} }

View File

@ -0,0 +1,34 @@
package main
import (
"fmt"
"sort"
"strconv"
"time"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() {
color.Yellow("Generating anime IDs")
defer color.Green("Finished")
defer arn.Node.Close()
allAnime := arn.AllAnime()
sort.Slice(allAnime, func(i, j int) bool {
aID, _ := strconv.Atoi(allAnime[i].ID)
bID, _ := strconv.Atoi(allAnime[j].ID)
return aID < bID
})
for counter, anime := range allAnime {
newID := arn.GenerateID("Anime")
fmt.Printf("[%d / %d] Old [%s] New [%s] %s\n", counter+1, len(allAnime), color.YellowString(anime.ID), color.GreenString(newID), anime)
anime.SetID(newID)
time.Sleep(100 * time.Millisecond)
}
}