Updated episode refresh
This commit is contained in:
parent
384ec41bbf
commit
cdfb66657a
10
arn/Anime.go
10
arn/Anime.go
@ -403,7 +403,7 @@ func (anime *Anime) RefreshEpisodes() error {
|
||||
return err
|
||||
}
|
||||
|
||||
episodes.Merge(shoboiEpisodes)
|
||||
episodes = episodes.Merge(shoboiEpisodes)
|
||||
|
||||
// AnimeTwist
|
||||
twistEpisodes, err := anime.TwistEpisodes()
|
||||
@ -412,7 +412,7 @@ func (anime *Anime) RefreshEpisodes() error {
|
||||
return err
|
||||
}
|
||||
|
||||
episodes.Merge(twistEpisodes)
|
||||
episodes = episodes.Merge(twistEpisodes)
|
||||
|
||||
// Count number of available episodes
|
||||
newAvailableCount := episodes.AvailableCount()
|
||||
@ -487,8 +487,10 @@ func (anime *Anime) RefreshEpisodes() error {
|
||||
// Save new episode ID list
|
||||
episodeIDs := make([]string, len(episodes))
|
||||
|
||||
for index := range episodes {
|
||||
episodeIDs[index] = episodes[index].ID
|
||||
for index, episode := range episodes {
|
||||
episodeIDs[index] = episode.ID
|
||||
episode.AnimeID = anime.ID
|
||||
episode.Save()
|
||||
}
|
||||
|
||||
anime.EpisodeIDs = episodeIDs
|
||||
|
@ -28,7 +28,7 @@ func (episodes EpisodeList) Find(episodeNumber int) (*Episode, int) {
|
||||
}
|
||||
|
||||
// Merge combines the data of both episode lists to one.
|
||||
func (episodes EpisodeList) Merge(b EpisodeList) {
|
||||
func (episodes EpisodeList) Merge(b EpisodeList) EpisodeList {
|
||||
for index, episode := range b {
|
||||
if index >= len(episodes) {
|
||||
episodes = append(episodes, episode)
|
||||
@ -36,6 +36,8 @@ func (episodes EpisodeList) Merge(b EpisodeList) {
|
||||
episodes[index].Merge(episode)
|
||||
}
|
||||
}
|
||||
|
||||
return episodes
|
||||
}
|
||||
|
||||
// HumanReadable returns a text representation of the anime episodes.
|
||||
|
Loading…
Reference in New Issue
Block a user