Removed SetID

This commit is contained in:
Eduard Urbach 2018-04-08 11:33:37 +02:00
parent b0539f42a5
commit 48b26f090c

View File

@ -1,36 +1,26 @@
package main package main
import (
"fmt"
"sort"
"strconv"
"time"
"github.com/animenotifier/arn"
"github.com/fatih/color"
)
func main() { func main() {
color.Yellow("Generating anime IDs") // color.Yellow("Generating anime IDs")
defer color.Green("Finished") // defer color.Green("Finished")
defer arn.Node.Close() // defer arn.Node.Close()
allAnime := arn.FilterAnime(func(anime *arn.Anime) bool { // allAnime := arn.FilterAnime(func(anime *arn.Anime) bool {
return len(anime.ID) < len("hw5heOmiR") // return len(anime.ID) < len("hw5heOmiR")
}) // })
sort.Slice(allAnime, func(i, j int) bool { // sort.Slice(allAnime, func(i, j int) bool {
aID, _ := strconv.Atoi(allAnime[i].ID) // aID, _ := strconv.Atoi(allAnime[i].ID)
bID, _ := strconv.Atoi(allAnime[j].ID) // bID, _ := strconv.Atoi(allAnime[j].ID)
return aID < bID // return aID < bID
}) // })
for counter, anime := range allAnime { // for counter, anime := range allAnime {
newID := arn.GenerateID("Anime") // 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) // 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) // anime.SetID(newID)
time.Sleep(100 * time.Millisecond) // time.Sleep(100 * time.Millisecond)
} // }
} }