Added basics for twist.moe background job

This commit is contained in:
Eduard Urbach 2017-07-09 23:22:31 +02:00
parent 0ab9433eb2
commit ced1790c35

38
jobs/twist/twist.go Normal file
View File

@ -0,0 +1,38 @@
package main
import (
"sort"
"strconv"
"github.com/animenotifier/arn"
"github.com/animenotifier/twist"
"github.com/fatih/color"
)
func main() {
// Replace this with ID list from twist.moe later
animeIDs := []string{
"13274",
"10902",
}
for _, animeID := range animeIDs {
feed, err := twist.GetFeedByKitsuID(animeID)
if err != nil {
color.Red("Error querying ID %s: %v", animeID, err)
continue
}
episodes := feed.Episodes
// Sort by episode number
sort.Slice(episodes, func(a, b int) bool {
epsA, _ := strconv.Atoi(episodes[a].Number)
epsB, _ := strconv.Atoi(episodes[b].Number)
return epsA < epsB
})
arn.PrettyPrint(episodes)
}
}