Example #1
0
    internal static void AddEpisodeToWatchlist(TraktShowSummary show, TraktEpisodeSummary episode)
    {
      var watchlistEpisodes = (_WatchListEpisodes ?? new List<TraktEpisodeWatchList>()).ToList();

      watchlistEpisodes.Add(new TraktEpisodeWatchList
      {
        ListedAt = DateTime.UtcNow.ToISO8601(),
        Show = show,
        Episode = episode
      });

      _WatchListEpisodes = watchlistEpisodes;
    }
Example #2
0
    public static int Plays(this TraktSeasonSummary season, TraktShowSummary show)
    {
      var watchedEpisodes = WatchedEpisodes;
      if (watchedEpisodes == null)
        return 0;

      // sum up all the plays per episode in season
      return watchedEpisodes.Where(e => e.ShowId == show.Ids.Trakt && e.Season == season.Number).Sum(e => e.Plays);
    }
Example #3
0
    public static bool IsCollected(this TraktSeasonSummary season, TraktShowSummary show)
    {
      if (season.EpisodeCount == 0 || season.EpisodeAiredCount == 0)
        return false;

      var collectedEpisodes = CollectedEpisodes;
      if (collectedEpisodes == null)
        return false;

      // check that the seasons aired episode count >= episodes watched in season
      // trakt does not include specials in count, nor should we
      int collectedEpisodeCount = collectedEpisodes.Where(e => (((e.ShowId == show.Ids.Trakt) && e.ShowId != null) || ((e.ShowTvdbId == show.Ids.Tvdb) && show.Ids.Tvdb != null)) &&
                                                               e.Season == season.Number).Count();
      return collectedEpisodeCount >= season.EpisodeAiredCount;
    }
Example #4
0
    public static int? UserRating(this TraktSeasonSummary season, TraktShowSummary show)
    {
      if (RatedSeasons == null)
        return null;

      var ratedSeason = RatedSeasons.FirstOrDefault(s => ((((s.Show.Ids.Trakt == show.Ids.Trakt) && s.Show.Ids.Trakt != null) || ((s.Show.Ids.Tvdb == show.Ids.Tvdb) && show.Ids.Tvdb != null))) &&
                                                         s.Season.Number == season.Number);


      if (ratedSeason == null)
        return null;

      return ratedSeason.Rating;
    }
Example #5
0
    public static bool IsWatchlisted(this TraktSeasonSummary season, TraktShowSummary show)
    {
      if (WatchListSeasons == null)
        return false;

      return WatchListSeasons.Any(s => ((((s.Show.Ids.Trakt == show.Ids.Trakt) && s.Show.Ids.Trakt != null) || ((s.Show.Ids.Tvdb == show.Ids.Tvdb) && show.Ids.Tvdb != null))) &&
                                       s.Season.Number == season.Number);
    }