fixed map indexing for anime episodes
This commit is contained in:
parent
6adf6f276d
commit
a541267c20
23
anime_episode_cache.go
Normal file
23
anime_episode_cache.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
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]
|
||||||
|
}
|
@ -58,7 +58,6 @@ func GetTorrents() ([]model.Torrent, error) {
|
|||||||
|
|
||||||
// goquery can't parse the link tag for some reason
|
// goquery can't parse the link tag for some reason
|
||||||
// therefore I have to get around this bug by exploiting regex
|
// therefore I have to get around this bug by exploiting regex
|
||||||
|
|
||||||
matches := torrentLinkRegex.FindStringSubmatch(s.Text())
|
matches := torrentLinkRegex.FindStringSubmatch(s.Text())
|
||||||
link := matches[0]
|
link := matches[0]
|
||||||
id := matches[1]
|
id := matches[1]
|
2
go.mod
2
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
git.milar.in/milarin/slices v0.0.6
|
git.milar.in/milarin/slices v0.0.6
|
||||||
git.milar.in/milarin/tprint v0.0.7
|
git.milar.in/milarin/tprint v0.0.7
|
||||||
git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6
|
git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6
|
||||||
git.milar.in/nyaanime/model v0.0.0-20230115221845-51c282652aef
|
git.milar.in/nyaanime/model v0.0.0-20230117081612-d3fc649dad67
|
||||||
git.milar.in/nyaanime/parsers v0.0.0-20230115232356-54a23b868d71
|
git.milar.in/nyaanime/parsers v0.0.0-20230115232356-54a23b868d71
|
||||||
github.com/PuerkitoBio/goquery v1.8.0
|
github.com/PuerkitoBio/goquery v1.8.0
|
||||||
github.com/fatih/color v1.13.0
|
github.com/fatih/color v1.13.0
|
||||||
|
4
go.sum
4
go.sum
@ -16,6 +16,10 @@ git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6 h1:6GmcKt0TaHxATG
|
|||||||
git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6/go.mod h1:cLuIBDTtpXdzprOIsz73r6ZCE5s0k+o6HA7fH9OuW/M=
|
git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6/go.mod h1:cLuIBDTtpXdzprOIsz73r6ZCE5s0k+o6HA7fH9OuW/M=
|
||||||
git.milar.in/nyaanime/model v0.0.0-20230115221845-51c282652aef h1:Bp1cMHgGnz5SAVWSL1hk1w7F75LGAkfwHqoTZnNQNbY=
|
git.milar.in/nyaanime/model v0.0.0-20230115221845-51c282652aef h1:Bp1cMHgGnz5SAVWSL1hk1w7F75LGAkfwHqoTZnNQNbY=
|
||||||
git.milar.in/nyaanime/model v0.0.0-20230115221845-51c282652aef/go.mod h1:kPWLDvFrhc1Uf77gxsBOxNeJ5JTVF2HhVs1IdVcw0tg=
|
git.milar.in/nyaanime/model v0.0.0-20230115221845-51c282652aef/go.mod h1:kPWLDvFrhc1Uf77gxsBOxNeJ5JTVF2HhVs1IdVcw0tg=
|
||||||
|
git.milar.in/nyaanime/model v0.0.0-20230117081410-7701a09a0de0 h1:70QTQYoF3OYkJur6gCygb9D+2awYv2gNjWdWMCl/8FU=
|
||||||
|
git.milar.in/nyaanime/model v0.0.0-20230117081410-7701a09a0de0/go.mod h1:kPWLDvFrhc1Uf77gxsBOxNeJ5JTVF2HhVs1IdVcw0tg=
|
||||||
|
git.milar.in/nyaanime/model v0.0.0-20230117081612-d3fc649dad67 h1:p69LqaWzN/2zsgw45tR1XbFxyayu9ffVlikiKE2ibRw=
|
||||||
|
git.milar.in/nyaanime/model v0.0.0-20230117081612-d3fc649dad67/go.mod h1:kPWLDvFrhc1Uf77gxsBOxNeJ5JTVF2HhVs1IdVcw0tg=
|
||||||
git.milar.in/nyaanime/parsers v0.0.0-20230115231942-89b759a7829f h1:xJiFxbLRKyb+43Yfv3UaZO1GiRGAsakebz6mHKUaRdI=
|
git.milar.in/nyaanime/parsers v0.0.0-20230115231942-89b759a7829f h1:xJiFxbLRKyb+43Yfv3UaZO1GiRGAsakebz6mHKUaRdI=
|
||||||
git.milar.in/nyaanime/parsers v0.0.0-20230115231942-89b759a7829f/go.mod h1:fqiJqSWxh1YVJkKhvQql/21HmQzv4elhC3SpH/2TybI=
|
git.milar.in/nyaanime/parsers v0.0.0-20230115231942-89b759a7829f/go.mod h1:fqiJqSWxh1YVJkKhvQql/21HmQzv4elhC3SpH/2TybI=
|
||||||
git.milar.in/nyaanime/parsers v0.0.0-20230115232356-54a23b868d71 h1:BwWlk7UuQ/Ii97/XUVijujH4nkYJwZ0dHpghQ04hQeo=
|
git.milar.in/nyaanime/parsers v0.0.0-20230115232356-54a23b868d71 h1:BwWlk7UuQ/Ii97/XUVijujH4nkYJwZ0dHpghQ04hQeo=
|
||||||
|
@ -42,12 +42,8 @@ func ParseTorrentsByAnimeEp(torrents []model.Torrent) map[model.AnimeEpisode][]*
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
animeEpisode := model.AnimeEpisode{
|
animeEp := GetAnimeEpisode(parsedTorrent.Anime, parsedTorrent.Episode)
|
||||||
Anime: parsedTorrent.Anime,
|
torrentsByAnimeEp[animeEp] = append(torrentsByAnimeEp[animeEp], parsedTorrent)
|
||||||
Episode: parsedTorrent.Episode,
|
|
||||||
}
|
|
||||||
|
|
||||||
torrentsByAnimeEp[animeEpisode] = append(torrentsByAnimeEp[animeEpisode], parsedTorrent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return torrentsByAnimeEp
|
return torrentsByAnimeEp
|
||||||
|
Loading…
Reference in New Issue
Block a user