Airing anime page
This commit is contained in:
@ -1,46 +0,0 @@
|
||||
// package main
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// "sort"
|
||||
|
||||
// "github.com/animenotifier/arn"
|
||||
// "github.com/fatih/color"
|
||||
// )
|
||||
|
||||
// // AiringAnime ...
|
||||
// func AiringAnime() {
|
||||
// fmt.Println("Running background job: Airing Anime")
|
||||
|
||||
// animeList, err := arn.GetAiringAnime()
|
||||
|
||||
// if err != nil {
|
||||
// color.Red("Failed fetching airing anime")
|
||||
// color.Red(err.Error())
|
||||
// return
|
||||
// }
|
||||
|
||||
// sort.Sort(arn.AnimeByPopularity(animeList))
|
||||
|
||||
// // Convert to small anime list
|
||||
// var animeListSmall []*arn.AnimeSmall
|
||||
|
||||
// for _, anime := range animeList {
|
||||
// animeListSmall = append(animeListSmall, &arn.AnimeSmall{
|
||||
// ID: anime.ID,
|
||||
// Title: anime.Title,
|
||||
// Image: anime.Image,
|
||||
// Watching: anime.Watching,
|
||||
// })
|
||||
// }
|
||||
|
||||
// saveErr := arn.SetObject("Cache", "airingAnime", &arn.AiringAnimeCacheSmall{
|
||||
// Anime: animeListSmall,
|
||||
// })
|
||||
|
||||
// if saveErr != nil {
|
||||
// color.Red("Error saving airing anime")
|
||||
// color.Red(saveErr.Error())
|
||||
// return
|
||||
// }
|
||||
// }
|
39
jobs/airing-anime/airing-anime.go
Normal file
39
jobs/airing-anime/airing-anime.go
Normal file
@ -0,0 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func main() {
|
||||
color.Yellow("Caching airing anime")
|
||||
|
||||
animeList, err := arn.GetAiringAnime()
|
||||
|
||||
if err != nil {
|
||||
color.Red("Failed fetching airing anime")
|
||||
color.Red(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// sort.Slice
|
||||
|
||||
// Convert to small anime list
|
||||
cache := &arn.ListOfIDs{}
|
||||
|
||||
for _, anime := range animeList {
|
||||
cache.IDList = append(cache.IDList, anime.ID)
|
||||
}
|
||||
|
||||
println(len(cache.IDList))
|
||||
|
||||
saveErr := arn.SetObject("Cache", "airing anime", cache)
|
||||
|
||||
if saveErr != nil {
|
||||
color.Red("Error saving airing anime")
|
||||
color.Red(saveErr.Error())
|
||||
return
|
||||
}
|
||||
|
||||
color.Green("Finished.")
|
||||
}
|
18
jobs/main.go
18
jobs/main.go
@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
func main() {
|
||||
// Background jobs
|
||||
go func() {
|
||||
for {
|
||||
AiringAnime()
|
||||
time.Sleep(time.Duration(2) * time.Second)
|
||||
}
|
||||
}()
|
||||
|
||||
// Main loop
|
||||
for {
|
||||
time.Sleep(time.Duration(10) * time.Second)
|
||||
}
|
||||
}
|
@ -42,17 +42,18 @@ func sync(data *kitsu.Anime) {
|
||||
anime.EndDate = attr.EndDate
|
||||
anime.EpisodeCount = attr.EpisodeCount
|
||||
anime.EpisodeLength = attr.EpisodeLength
|
||||
anime.Status = attr.Status
|
||||
anime.NSFW = attr.Nsfw
|
||||
anime.Summary = arn.FixAnimeDescription(attr.Synopsis)
|
||||
|
||||
if data.Attributes.YoutubeVideoID != "" {
|
||||
if attr.YoutubeVideoID != "" {
|
||||
anime.Trailers = append(anime.Trailers, arn.AnimeTrailer{
|
||||
Service: "Youtube",
|
||||
VideoID: data.Attributes.YoutubeVideoID,
|
||||
VideoID: attr.YoutubeVideoID,
|
||||
})
|
||||
}
|
||||
|
||||
err := anime.Save()
|
||||
|
||||
status := ""
|
||||
|
||||
if err == nil {
|
||||
|
Reference in New Issue
Block a user