downloader/anime_episode_cache.go

24 lines
566 B
Go

package main
import (
"git.milar.in/milarin/anilist"
"git.milar.in/nyaanime/model"
)
var AnimeEpisodeCache = map[anilist.MediaID]map[int]model.AnimeEpisode{}
func GetAnimeEpisode(anime *anilist.Media, episode int) model.AnimeEpisode {
if _, ok := AnimeEpisodeCache[anime.ID]; !ok {
AnimeEpisodeCache[anime.ID] = map[int]model.AnimeEpisode{}
}
if _, ok := AnimeEpisodeCache[anime.ID][episode]; !ok {
AnimeEpisodeCache[anime.ID][episode] = model.AnimeEpisode{
Anime: anime,
Episode: episode,
}
}
return AnimeEpisodeCache[anime.ID][episode]
}