downloader/anime_episode_cache.go

24 lines
566 B
Go
Raw Normal View History

2023-01-17 09:25:03 +01:00
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]
}