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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
episodes.Merge(shoboiEpisodes)
|
episodes = episodes.Merge(shoboiEpisodes)
|
||||||
|
|
||||||
// AnimeTwist
|
// AnimeTwist
|
||||||
twistEpisodes, err := anime.TwistEpisodes()
|
twistEpisodes, err := anime.TwistEpisodes()
|
||||||
@ -412,7 +412,7 @@ func (anime *Anime) RefreshEpisodes() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
episodes.Merge(twistEpisodes)
|
episodes = episodes.Merge(twistEpisodes)
|
||||||
|
|
||||||
// Count number of available episodes
|
// Count number of available episodes
|
||||||
newAvailableCount := episodes.AvailableCount()
|
newAvailableCount := episodes.AvailableCount()
|
||||||
@ -487,8 +487,10 @@ func (anime *Anime) RefreshEpisodes() error {
|
|||||||
// Save new episode ID list
|
// Save new episode ID list
|
||||||
episodeIDs := make([]string, len(episodes))
|
episodeIDs := make([]string, len(episodes))
|
||||||
|
|
||||||
for index := range episodes {
|
for index, episode := range episodes {
|
||||||
episodeIDs[index] = episodes[index].ID
|
episodeIDs[index] = episode.ID
|
||||||
|
episode.AnimeID = anime.ID
|
||||||
|
episode.Save()
|
||||||
}
|
}
|
||||||
|
|
||||||
anime.EpisodeIDs = episodeIDs
|
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.
|
// 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 {
|
for index, episode := range b {
|
||||||
if index >= len(episodes) {
|
if index >= len(episodes) {
|
||||||
episodes = append(episodes, episode)
|
episodes = append(episodes, episode)
|
||||||
@ -36,6 +36,8 @@ func (episodes EpisodeList) Merge(b EpisodeList) {
|
|||||||
episodes[index].Merge(episode)
|
episodes[index].Merge(episode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return episodes
|
||||||
}
|
}
|
||||||
|
|
||||||
// HumanReadable returns a text representation of the anime episodes.
|
// HumanReadable returns a text representation of the anime episodes.
|
||||||
|
Loading…
Reference in New Issue
Block a user