Updated RefreshEpisodes
This commit is contained in:
parent
bd7292e2b2
commit
23b6032393
50
arn/Anime.go
50
arn/Anime.go
@ -427,7 +427,7 @@ func (anime *Anime) RefreshEpisodes() error {
|
|||||||
episodes := anime.Episodes()
|
episodes := anime.Episodes()
|
||||||
|
|
||||||
// Save number of available episodes for comparison later
|
// Save number of available episodes for comparison later
|
||||||
oldAvailableCount := episodes.AvailableCount()
|
// oldAvailableCount := episodes.AvailableCount()
|
||||||
|
|
||||||
// Shoboi
|
// Shoboi
|
||||||
shoboiEpisodes, err := anime.ShoboiEpisodes()
|
shoboiEpisodes, err := anime.ShoboiEpisodes()
|
||||||
@ -439,36 +439,36 @@ func (anime *Anime) RefreshEpisodes() error {
|
|||||||
episodes = episodes.Merge(shoboiEpisodes)
|
episodes = episodes.Merge(shoboiEpisodes)
|
||||||
|
|
||||||
// AnimeTwist
|
// AnimeTwist
|
||||||
twistEpisodes, err := anime.TwistEpisodes()
|
// twistEpisodes, err := anime.TwistEpisodes()
|
||||||
|
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
return err
|
// return err
|
||||||
}
|
// }
|
||||||
|
|
||||||
episodes = episodes.Merge(twistEpisodes)
|
// episodes = episodes.Merge(twistEpisodes)
|
||||||
|
|
||||||
// Count number of available episodes
|
// Count number of available episodes
|
||||||
newAvailableCount := episodes.AvailableCount()
|
// newAvailableCount := episodes.AvailableCount()
|
||||||
|
|
||||||
if anime.Status != "finished" && newAvailableCount > oldAvailableCount {
|
// if anime.Status != "finished" && newAvailableCount > oldAvailableCount {
|
||||||
// New episodes have been released.
|
// // New episodes have been released.
|
||||||
// Notify all users who are watching the anime.
|
// // Notify all users who are watching the anime.
|
||||||
go func() {
|
// go func() {
|
||||||
for _, user := range anime.UsersWatchingOrPlanned() {
|
// for _, user := range anime.UsersWatchingOrPlanned() {
|
||||||
if !user.Settings().Notification.AnimeEpisodeReleases {
|
// if !user.Settings().Notification.AnimeEpisodeReleases {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
|
|
||||||
user.SendNotification(&PushNotification{
|
// user.SendNotification(&PushNotification{
|
||||||
Title: anime.Title.ByUser(user),
|
// Title: anime.Title.ByUser(user),
|
||||||
Message: "Episode " + strconv.Itoa(newAvailableCount) + " has been released!",
|
// Message: "Episode " + strconv.Itoa(newAvailableCount) + " has been released!",
|
||||||
Icon: anime.ImageLink("medium"),
|
// Icon: anime.ImageLink("medium"),
|
||||||
Link: "https://notify.moe" + anime.Link(),
|
// Link: "https://notify.moe" + anime.Link(),
|
||||||
Type: NotificationTypeAnimeEpisode,
|
// Type: NotificationTypeAnimeEpisode,
|
||||||
})
|
// })
|
||||||
}
|
// }
|
||||||
}()
|
// }()
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Number remaining episodes
|
// Number remaining episodes
|
||||||
startNumber := 0
|
startNumber := 0
|
||||||
|
Loading…
Reference in New Issue
Block a user