示例#1
0
    internal static void RemoveEpisodeFromPausedData(TraktShow show, TraktEpisode episode)
    {
      if (_PausedEpisodes == null || show.Ids == null)
        return;

      var pausedEpisodes = _PausedEpisodes.ToList();
      pausedEpisodes.RemoveAll(e => (((e.Show.Ids.Trakt == show.Ids.Trakt) && e.Show.Ids.Trakt != null) || ((e.Show.Ids.Tvdb == show.Ids.Tvdb) && e.Show.Ids.Tvdb != null)) &&
                                    e.Episode.Season == episode.Season &&
                                    e.Episode.Number == episode.Number);

      // remove using Title + Year
      if (show.Ids.Trakt == null && show.Ids.Tvdb == null)
      {
        pausedEpisodes.RemoveAll(e => e.Show.Title.ToLowerInvariant() == show.Title.ToLowerInvariant() && e.Show.Year == show.Year &&
                                      e.Episode.Season == episode.Season &&
                                      e.Episode.Number == episode.Number);
      }

      _PausedEpisodes = pausedEpisodes;
    }
示例#2
0
    internal static void RemoveEpisodeFromCollection(TraktShow show, TraktEpisode episode)
    {
      if (_CollectedEpisodes == null || show.Ids == null)
        return;

      var collectedEpisodes = _CollectedEpisodes.ToList();
      collectedEpisodes.RemoveAll(e => (((e.ShowId == show.Ids.Trakt) && e.ShowId != null) || ((e.ShowTvdbId == show.Ids.Tvdb) && e.ShowTvdbId != null)) &&
                                       e.Season == episode.Season &&
                                       e.Number == episode.Number);

      // remove using Title + Year
      if (show.Ids.Trakt == null && show.Ids.Tvdb == null)
      {
        collectedEpisodes.RemoveAll(e => e.ShowTitle.ToLowerInvariant() == show.Title.ToLowerInvariant() && e.ShowYear == show.Year &&
                                         e.Season == episode.Season &&
                                         e.Number == episode.Number);
      }

      _CollectedEpisodes = collectedEpisodes;
    }
示例#3
0
    internal static void RemoveEpisodeFromRatings(TraktEpisode episode)
    {
      if (_RatedEpisodes == null || episode.Ids == null)
        return;

      var ratedEpisodes = _RatedEpisodes.ToList();
      ratedEpisodes.RemoveAll(e => ((e.Episode.Ids.Trakt == episode.Ids.Trakt) && e.Episode.Ids.Trakt != null) ||
                                   ((e.Episode.Ids.Imdb == episode.Ids.Imdb) && e.Episode.Ids.Imdb.ToNullIfEmpty() != null) ||
                                   ((e.Episode.Ids.Tvdb == episode.Ids.Tvdb) && e.Episode.Ids.Tvdb != null));

      _RatedEpisodes = ratedEpisodes;
    }
示例#4
0
    internal static void AddEpisodeToPausedData(TraktShow show, TraktEpisode episode, float progress)
    {
      var pausedEpisodes = (_PausedEpisodes ?? new List<TraktSyncPausedEpisode>()).ToList();

      var existingPausedEpisode = pausedEpisodes.FirstOrDefault(e => (((e.Show.Ids.Trakt == show.Ids.Trakt) && e.Show.Ids.Trakt != null) || ((e.Show.Ids.Tvdb == show.Ids.Tvdb) && e.Show.Ids.Tvdb != null)) &&
                                                                     e.Episode.Season == episode.Season &&
                                                                     e.Episode.Number == episode.Number);

      // if it exists already, increment the play count only
      if (existingPausedEpisode != null)
      {
        existingPausedEpisode.Progress = progress;
        existingPausedEpisode.PausedAt = DateTime.UtcNow.ToISO8601();
      }
      else
      {
        pausedEpisodes.Add(new TraktSyncPausedEpisode
        {
          PausedAt = DateTime.UtcNow.ToISO8601(),
          Progress = progress,
          Show = new TraktShow
          {
            Ids = show.Ids,
            Title = show.Title,
            Year = show.Year
          },
          Episode = new TraktEpisode
          {
            Ids = episode.Ids,
            Number = episode.Number,
            Season = episode.Season,
            Title = episode.Title
          }
        });
      }

      _PausedEpisodes = pausedEpisodes;
    }
示例#5
0
    internal static void RemoveEpisodeFromWatchlist(TraktEpisode episode)
    {
      if (_WatchListEpisodes == null || episode.Ids == null)
        return;

      var watchlistEpisodes = _WatchListEpisodes.ToList();
      watchlistEpisodes.RemoveAll(e => ((e.Episode.Ids.Trakt == episode.Ids.Trakt) && e.Episode.Ids.Trakt != null) ||
                                       ((e.Episode.Ids.Imdb == episode.Ids.Imdb) && e.Episode.Ids.Imdb != null) ||
                                       ((e.Episode.Ids.Tvdb == episode.Ids.Tvdb && e.Episode.Ids.Tvdb != null)));

      _WatchListEpisodes = watchlistEpisodes;
    }
示例#6
0
    internal static void AddEpisodeToCollection(TraktShow show, TraktEpisode episode)
    {
      var collectedEpisodes = (_CollectedEpisodes ?? new List<EpisodeCollected>()).ToList();

      collectedEpisodes.Add(new EpisodeCollected
      {
        Number = episode.Number,
        Season = episode.Season,
        ShowId = show.Ids.Trakt,
        ShowImdbId = show.Ids.Imdb,
        ShowTvdbId = show.Ids.Tvdb,
        ShowTitle = show.Title,
        ShowYear = show.Year,
        CollectedAt = DateTime.UtcNow.ToISO8601()
      });

      _CollectedEpisodes = collectedEpisodes;
    }
示例#7
0
    internal static void AddEpisodeToRatings(TraktShow show, TraktEpisode episode, int rating)
    {
      var ratedEpisodes = (_RatedEpisodes ?? new List<TraktEpisodeRated>()).ToList();

      ratedEpisodes.Add(new TraktEpisodeRated
      {
        RatedAt = DateTime.UtcNow.ToISO8601(),
        Rating = rating,
        Show = new TraktShow
        {
          Ids = show.Ids,
          Title = show.Title,
          Year = show.Year
        },
        Episode = new TraktEpisode
        {
          Ids = episode.Ids,
          Number = episode.Number,
          Season = episode.Season,
          Title = episode.Title
        }
      });

      _RatedEpisodes = ratedEpisodes;
    }
示例#8
0
    internal static void AddEpisodeToWatchHistory(TraktShow show, TraktEpisode episode)
    {
      var watchedEpisodes = (_WatchedEpisodes ?? new List<EpisodeWatched>()).ToList();

      var existingWatchedEpisode = watchedEpisodes.FirstOrDefault(e => (((e.ShowId == show.Ids.Trakt) && e.ShowId != null) || ((e.ShowTvdbId == show.Ids.Tvdb) && e.ShowTvdbId != null)) &&
                                                                       e.Season == episode.Season &&
                                                                       e.Number == episode.Number);

      // if it exists already, increment the play count only
      if (existingWatchedEpisode != null)
      {
        existingWatchedEpisode.Plays++;
        existingWatchedEpisode.WatchedAt = DateTime.UtcNow.ToISO8601();
      }
      else
      {
        watchedEpisodes.Add(new EpisodeWatched
        {
          Number = episode.Number,
          Season = episode.Season,
          ShowId = show.Ids.Trakt,
          ShowImdbId = show.Ids.Imdb,
          ShowTvdbId = show.Ids.Tvdb,
          ShowTitle = show.Title,
          ShowYear = show.Year,
          Plays = 1,
          WatchedAt = DateTime.UtcNow.ToISO8601()
        });
      }

      _WatchedEpisodes = watchedEpisodes;

      // now remove from watchlist and paused state since it will be removed from online in these cases
      RemoveEpisodeFromWatchlist(episode);
      RemoveEpisodeFromPausedData(show, episode);
      RemoveShowFromWatchlist(show);
    }
示例#9
0
    public static TraktSyncResponse RemoveEpisodeFromWatchlist(TraktEpisode episode)
    {
      var episodes = new TraktSyncEpisodes
      {
        Episodes = new List<TraktEpisode>() { episode }
      };

      return RemoveEpisodesFromWatchlist(episodes);
    }
示例#10
0
    public static TraktSyncResponse AddEpisodeToWatchlist(TraktEpisode episode)
    {
      var episodes = new TraktSyncEpisodes
      {
        Episodes = new List<TraktEpisode>() { episode }
      };

      return AddEpisodesToWatchlist(episodes);
    }
示例#11
0
    /// <summary>
    /// UnRate a single episode on trakt.tv
    /// </summary>
    public static TraktSyncResponse RemoveEpisodeFromRatings(TraktEpisode episode)
    {
      var episodes = new TraktSyncEpisodes
      {
        Episodes = new List<TraktEpisode>() { new TraktEpisode { Ids = episode.Ids } }
      };

      return RemoveEpisodesFromRatings(episodes);
    }
示例#12
0
    public static TraktSyncResponse RemoveEpisodeFromCollection(TraktEpisode episode)
    {
      var episodes = new TraktSyncEpisodes
      {
        Episodes = new List<TraktEpisode>() { episode }
      };

      return RemoveEpisodesFromCollecton(episodes);
    }