fixed bug where app panics if anime doesn't exist on Simkl

This commit is contained in:
John O'Keefe 2024-09-16 19:11:23 -04:00
parent a24a187c7f
commit 74afb317d1

View File

@ -268,6 +268,10 @@ func (a *App) SimklSearch(aniListAnime MediaList) SimklAnime {
log.Printf("Failed at unmarshal, %s\n", err)
}
if len(anime) == 0 {
return result
}
for _, watchListAnime := range SimklWatchList.Anime {
id := watchListAnime.Show.Ids.Simkl
if id == anime[0].Ids.Simkl {
@ -275,7 +279,7 @@ func (a *App) SimklSearch(aniListAnime MediaList) SimklAnime {
}
}
if reflect.DeepEqual(result, SimklSearchType{}) && len(anime) > 0 {
if reflect.DeepEqual(result, SimklAnime{}) && len(anime) > 0 {
result.Show.Title = anime[0].Title
result.Show.Poster = anime[0].Poster
result.Show.Ids.Simkl = anime[0].Ids.Simkl