func updateEpisodes(existingSeason *store.Season, newSeason Season) { for i, e := range existingSeason.Episodes { // Delete 'TBA' episodes. if e.Title == "TBA" { existingSeason.Episodes[i] = nil existingSeason.Episodes = append(existingSeason.Episodes[:i], existingSeason.Episodes[i+1:]...) } } if len(existingSeason.Episodes) == len(newSeason.Episodes) { return } for _, episode := range newSeason.Episodes { if !contains(existingSeason.Episodes, episode) { newEpisode := store.Episode{ Episode: episode.Episode, AirDate: episode.AirDate, Title: episode.Title, Pending: true, } existingSeason.Episodes = append(existingSeason.Episodes, &newEpisode) } } }
func addSeason(show *store.Show, season Season) { newSeason := store.Season{ Season: season.Season, } for _, episode := range season.Episodes { newEpisode := store.Episode{ Episode: episode.Episode, AirDate: episode.AirDate, Title: episode.Title, Pending: true, } newSeason.Episodes = append(newSeason.Episodes, &newEpisode) } show.Seasons = append(show.Seasons, &newSeason) }