/// <summary>Adds a <see cref="TraktEpisode" />, which will be added to the history post.</summary>
        /// <param name="episode">The Trakt episode, which will be added.</param>
        /// <param name="watchedAt">The datetime, when the given episode was watched. Will be converted to the Trakt UTC-datetime and -format.</param>
        /// <returns>The current <see cref="TraktSyncHistoryPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given episode is null.
        /// Thrown, if the given episode ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">Thrown, if the given episode has no valid ids set.</exception>
        public TraktSyncHistoryPostBuilder AddEpisode(TraktEpisode episode, DateTime watchedAt)
        {
            ValidateEpisode(episode);
            EnsureEpisodesListExists();

            return(AddEpisodeOrIgnore(episode, watchedAt) as TraktSyncHistoryPostBuilder);
        }
        public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Only_Translations_Property()
        {
            ITraktEpisode traktEpisode = new TraktEpisode
            {
                Translations = new List <TraktEpisodeTranslation>
                {
                    new TraktEpisodeTranslation
                    {
                        Title        = "german title",
                        Overview     = "german overview",
                        LanguageCode = "de"
                    },
                    new TraktEpisodeTranslation
                    {
                        Title        = "english title",
                        Overview     = "english overview",
                        LanguageCode = "en"
                    }
                }
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new EpisodeObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktEpisode);

                    stringWriter.ToString().Should().Be(@"{""translations"":[{""title"":""german title"",""overview"":""german overview"",""language"":""de""}," +
                                                        @"{""title"":""english title"",""overview"":""english overview"",""language"":""en""}]}");
                }
        }
Example #3
0
        private TraktRateEpisodes GetRateEpisodeData(TVDbEpisodeRatings episodeRatings, TVDbShow showInfo)
        {
            List <TraktEpisode> episodes = new List <TraktEpisode>();

            foreach (var episode in episodeRatings.Episodes)
            {
                // get season/episode info from showInfo object
                var tvdbEpisode = showInfo.Episodes.Find(e => e.Id == episode.Id);
                if (tvdbEpisode == null)
                {
                    continue;
                }

                var traktEpisode = new TraktEpisode
                {
                    Episode = tvdbEpisode.EpisodeNumber,
                    Season  = tvdbEpisode.SeasonNumber,
                    TVDbId  = episodeRatings.Show.Id,
                    Rating  = episode.UserRating,
                    Title   = showInfo.Show.Name
                };
                episodes.Add(traktEpisode);
            }

            TraktRateEpisodes episodeRateData = new TraktRateEpisodes
            {
                Username = AppSettings.TraktUsername,
                Password = AppSettings.TraktPassword,
                Episodes = episodes,
            };

            return(episodeRateData);
        }
Example #4
0
        private void Validate(TraktEpisode episode, TraktShow show)
        {
            if (episode == null)
            {
                throw new ArgumentNullException(nameof(episode), "episode must not be null");
            }

            if (episode.Ids == null || !episode.Ids.HasAnyId)
            {
                if (show == null)
                {
                    throw new ArgumentNullException(nameof(show), "episode ids not set or have no valid id - show must not be null");
                }

                if (string.IsNullOrEmpty(show.Title))
                {
                    throw new ArgumentException("episode ids not set or have no valid id  - show title not valid", nameof(show.Title));
                }

                if (episode.SeasonNumber < 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(episode.SeasonNumber), "episode ids not set or have no valid id  - episode season number not valid");
                }

                if (episode.Number <= 0)
                {
                    throw new ArgumentOutOfRangeException(nameof(episode.Number), "episode ids not set or have no valid id  - episode number not valid");
                }
            }
        }
Example #5
0
        private void Validate(TraktEpisode episode, TraktShow show)
        {
            if (episode == null)
            {
                throw new ArgumentNullException(nameof(episode), "episode must not be null");
            }

            if (episode.SeasonNumber < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(episode.SeasonNumber), "episode season number not valid");
            }

            if (episode.Number < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(episode.Number), "episode number not valid");
            }

            if (show == null)
            {
                throw new ArgumentNullException(nameof(show), "show must not be null");
            }

            if (string.IsNullOrEmpty(show.Title))
            {
                throw new ArgumentException("show title not valid", nameof(show.Title));
            }
        }
        public TraktCheckinsModule_Tests()
        {
            Movie = new TraktMovie
            {
                Title = "Guardians of the Galaxy",
                Year  = 2014,
                Ids   = new TraktMovieIds
                {
                    Trakt = 28,
                    Slug  = "guardians-of-the-galaxy-2014",
                    Imdb  = "tt2015381",
                    Tmdb  = 118340
                }
            };

            Episode = new TraktEpisode
            {
                Number       = 1,
                SeasonNumber = 1,
                Ids          = new TraktEpisodeIds
                {
                    Trakt  = 16,
                    Tvdb   = 349232,
                    Imdb   = "tt0959621",
                    Tmdb   = 62085,
                    TvRage = 637041
                }
            };

            Show = new TraktShow {
                Title = "Breaking Bad"
            };
        }
Example #7
0
        public TraktCommentsModule_Tests()
        {
            Movie = new TraktMovie
            {
                Title = "Guardians of the Galaxy",
                Year  = 2014,
                Ids   = new TraktMovieIds
                {
                    Trakt = 28,
                    Slug  = "guardians-of-the-galaxy-2014",
                    Imdb  = "tt2015381",
                    Tmdb  = 118340
                }
            };

            Show = new TraktShow
            {
                Title = "Breaking Bad",
                Ids   = new TraktShowIds
                {
                    Trakt  = 1388,
                    Slug   = "breaking bad",
                    Tvdb   = 81189,
                    Imdb   = "tt0903747",
                    Tmdb   = 1396,
                    TvRage = 18164
                }
            };

            Season = new TraktSeason
            {
                Ids = new TraktSeasonIds
                {
                    Trakt = 3950,
                    Tvdb  = 30272,
                    Tmdb  = 3572
                }
            };

            Episode = new TraktEpisode
            {
                Ids = new TraktEpisodeIds
                {
                    Trakt  = 73482,
                    Tvdb   = 349232,
                    Imdb   = "tt0959621",
                    Tmdb   = 62085,
                    TvRage = 637041
                }
            };

            List = new TraktList
            {
                Ids = new TraktListIds
                {
                    Trakt = 2228577,
                    Slug  = "oscars-2016"
                }
            };
        }
Example #8
0
        public async void LoadEpisodeData()
        {
            this.progressBarLoading.Visibility = System.Windows.Visibility.Visible;
            App.ShowViewModel.EpisodeItems.Clear();
            App.ShowViewModel.RefreshEpisodes();

            if (this.Show != null && this.Show.Seasons != null && this.Show.Seasons.Count > 0)
            {
                if (App.ShowViewModel.currentSeason <= this.Show.Seasons.Count)
                {
                    TraktEpisode[] episodes = await this.showController.getEpisodesOfSeason(Show, App.ShowViewModel.currentSeason);

                    if (episodes != null)
                    {
                        foreach (TraktEpisode episodeIt in episodes)
                        {
                            episodeIt.Tvdb = this.Show.tvdb_id;
                            TraktEpisode episode = episodeIt;

                            App.ShowViewModel.EpisodeItems.Add(new ListItemViewModel()
                            {
                                Name = episode.Title, ImageSource = (AppUser.Instance.SmallScreenshotsEnabled || (AppUser.Instance.ImagesWithWIFI && StorageController.IsConnectedToWifi())) ? episode.Images.Screen : null, Imdb = this.Show.tvdb_id + episode.Season + episode.Number, SubItemText = "Season " + episode.Season + ", Episode " + episode.Number, Episode = episode.Number, Season = episode.Season, Tvdb = episode.Tvdb, Watched = episode.Watched, Rating = episode.MyRatingAdvanced, InWatchList = episode.InWatchlist
                            });
                        }


                        App.ShowViewModel.RefreshEpisodes();
                    }
                }
            }

            this.progressBarLoading.Visibility = System.Windows.Visibility.Collapsed;
        }
Example #9
0
        /// <summary>Adds a <see cref="TraktEpisode" />, which will be added to the collection post.</summary>
        /// <param name="episode">The Trakt episode, which will be added.</param>
        /// <returns>The current <see cref="TraktSyncCollectionPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given episode is null.
        /// Thrown, if the given episode ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">Thrown, if the given episode has no valid ids set.</exception>
        public TraktSyncCollectionPostBuilder AddEpisode(TraktEpisode episode)
        {
            ValidateEpisode(episode);
            EnsureEpisodesListExists();

            return(AddEpisodeOrIgnore(episode));
        }
Example #10
0
        public void updateEpisode(TraktEpisode traktEpisode)
        {
            foreach (ListItemViewModel model in EpisodeItems)
            {
                if (!String.IsNullOrEmpty(model.Season))
                {
                    if (model.Season.Equals(traktEpisode.Season) && model.Episode.Equals(traktEpisode.Number))
                    {
                        model.Watched     = traktEpisode.Watched;
                        model.InWatchList = traktEpisode.InWatchlist;
                        model.Rating      = traktEpisode.MyRatingAdvanced;
                    }
                }
            }

            if (UnWatchedEpisodeItems != null)
            {
                foreach (ListItemViewModel subModel in UnWatchedEpisodeItems)
                {
                    if (!String.IsNullOrEmpty(subModel.Season))
                    {
                        if (subModel.Season.Equals(traktEpisode.Season) && subModel.Episode.Equals(traktEpisode.Number))
                        {
                            if (traktEpisode.Watched)
                            {
                                UnWatchedEpisodeItems.Remove(subModel);
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #11
0
        /// <summary>Adds a <see cref="TraktEpisode" />, which will be added to the collection post.</summary>
        /// <param name="episode">The Trakt episode, which will be added.</param>
        /// <param name="metadata">An <see cref="TraktMetadata" /> instance, containing metadata about the given episode.</param>
        /// <param name="collectedAt">The datetime, when the given episode was collected. Will be converted to the Trakt UTC-datetime and -format.</param>
        /// <returns>The current <see cref="TraktSyncCollectionPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given episode is null.
        /// Thrown, if the given episode ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">Thrown, if the given episode has no valid ids set.</exception>
        public TraktSyncCollectionPostBuilder AddEpisode(TraktEpisode episode, TraktMetadata metadata, DateTime collectedAt)
        {
            ValidateEpisode(episode);
            EnsureEpisodesListExists();

            return(AddEpisodeOrIgnore(episode, metadata, collectedAt));
        }
        public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Only_Translations_Property()
        {
            ITraktEpisode traktEpisode = new TraktEpisode
            {
                Translations = new List <TraktEpisodeTranslation>
                {
                    new TraktEpisodeTranslation
                    {
                        Title        = "german title",
                        Overview     = "german overview",
                        LanguageCode = "de"
                    },
                    new TraktEpisodeTranslation
                    {
                        Title        = "english title",
                        Overview     = "english overview",
                        LanguageCode = "en"
                    }
                }
            };

            var    traktJsonWriter = new EpisodeObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktEpisode);

            json.Should().Be(@"{""translations"":[{""title"":""german title"",""overview"":""german overview"",""language"":""de""}," +
                             @"{""title"":""english title"",""overview"":""english overview"",""language"":""en""}]}");
        }
Example #13
0
        private async void LoadEpisode()
        {
            if (!LoadingActive)
            {
                LoadingActive = true;
                String id;
                String season;
                String episodeNr;
                NavigationContext.QueryString.TryGetValue("id", out id);
                NavigationContext.QueryString.TryGetValue("season", out season);
                NavigationContext.QueryString.TryGetValue("episode", out episodeNr);

                LayoutRoot.Opacity = 1;

                show = await showController.getShowByTVDBID(id);

                episode = await episodeController.getEpisodeByTvdbAndSeasonInfo(id, season, episodeNr, show);

                if (episode != null)
                {
                    DateTime airTime = new DateTime(1970, 1, 1, 0, 0, 9, DateTimeKind.Utc);
                    airTime = airTime.AddSeconds(episode.FirstAired);

                    int daysSinceRelease = (DateTime.Now - airTime).Days;

                    App.EpisodeViewModel.UpdateEpisodeView(episode, show);
                    App.EpisodeViewModel.IsDataLoaded = true;
                    LoadBackgroundImage(show);
                    LoadScreenImage(episode);

                    InitAppBar();
                }
                LoadingActive = false;
            }
        }
        private TraktSyncCollectionPostBuilder AddEpisodeOrIgnore(TraktEpisode episode, TraktMetadata metadata = null,
                                                                  DateTime?collectedAt = null)
        {
            if (ContainsEpisode(episode))
            {
                return(this);
            }

            var collectionEpisode = new TraktSyncCollectionPostEpisode();

            collectionEpisode.Ids = episode.Ids;

            if (metadata != null)
            {
                collectionEpisode.Metadata = metadata;
            }

            if (collectedAt.HasValue)
            {
                collectionEpisode.CollectedAt = collectedAt.Value.ToUniversalTime();
            }

            (_collectionPost.Episodes as List <TraktSyncCollectionPostEpisode>).Add(collectionEpisode);

            return(this);
        }
Example #15
0
        /// <summary>Adds a <see cref="TraktEpisode" />, which will be added to the history remove post.</summary>
        /// <param name="episode">The Trakt episode, which will be added.</param>
        /// <returns>The current <see cref="TraktSyncHistoryRemovePostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given episode is null.
        /// Thrown, if the given episode ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">Thrown, if the given episode has no valid ids set.</exception>
        public TraktSyncHistoryRemovePostBuilder AddEpisode(TraktEpisode episode)
        {
            ValidateEpisode(episode);
            EnsureEpisodesListExists();

            return(AddEpisodeOrIgnore(episode));
        }
        private TraktSyncRatingsPostBuilder AddEpisodeOrIgnore(TraktEpisode episode, int?rating = null, DateTime?ratedAt = null)
        {
            if (ContainsEpisode(episode))
            {
                return(this);
            }

            var ratingsEpisode = new TraktSyncRatingsPostEpisode();

            ratingsEpisode.Ids = episode.Ids;

            if (rating.HasValue)
            {
                ratingsEpisode.Rating = rating;
            }

            if (ratedAt.HasValue)
            {
                ratingsEpisode.RatedAt = ratedAt.Value.ToUniversalTime();
            }

            (_ratingsPost.Episodes as List <TraktSyncRatingsPostEpisode>).Add(ratingsEpisode);

            return(this);
        }
Example #17
0
 public async Task Test_EpisodeObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
 {
     var           traktJsonWriter = new EpisodeObjectJsonWriter();
     ITraktEpisode traktEpisode    = new TraktEpisode();
     Func <Task>   action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktEpisode);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
        public void Test_TraktPost_SyncRatingsPostBuilder_AddRatedEpisode_And_RatedAt()
        {
            ITraktEpisode episode = new TraktEpisode
            {
                Ids = new TraktEpisodeIds
                {
                    Trakt  = 1,
                    Imdb   = "ttepisodetitle",
                    Tmdb   = 1,
                    Tvdb   = 1,
                    TvRage = 1
                }
            };

            ITraktSyncRatingsPost syncRatingsPost = TraktPost.NewSyncRatingsPost()
                                                    .AddRatedEpisode(episode).WithRating(RATING, RATED_AT)
                                                    .Build();

            syncRatingsPost.Should().NotBeNull();
            syncRatingsPost.Episodes.Should().NotBeNull().And.HaveCount(1);

            ITraktSyncRatingsPostEpisode postEpisode = syncRatingsPost.Episodes.ToArray()[0];

            postEpisode.Ids.Should().NotBeNull();
            postEpisode.Ids.Trakt.Should().Be(1U);
            postEpisode.Ids.Imdb.Should().Be("ttepisodetitle");
            postEpisode.Ids.Tmdb.Should().Be(1U);
            postEpisode.Ids.Tvdb.Should().Be(1U);
            postEpisode.Ids.TvRage.Should().Be(1U);
            postEpisode.Rating.Should().Be(RATING);
            postEpisode.RatedAt.Should().Be(RATED_AT);

            syncRatingsPost.Movies.Should().NotBeNull().And.BeEmpty();
            syncRatingsPost.Shows.Should().NotBeNull().And.BeEmpty();
        }
Example #19
0
        public async Task <TraktEpisodeScrobblePostResponse> StopEpisodeAsync([NotNull] TraktEpisode episode, float progress,
                                                                              string appVersion = null, DateTime?appBuildDate = null)
        {
            var requestBody = CreateEpisodeScrobblePost(episode, progress, null, appVersion, appBuildDate);

            return(await QueryAsync(CreateScrobbleStopRequest <TraktEpisodeScrobblePostResponse, TraktEpisodeScrobblePost>(requestBody)));
        }
        public async Task Test_TraktCommentsModule_PostEpisodeComment_ArgumentExceptions()
        {
            ITraktEpisode episode = new TraktEpisode
            {
                Ids = new TraktEpisodeIds
                {
                    Trakt  = 73482,
                    Tvdb   = 349232,
                    Imdb   = "tt0959621",
                    Tmdb   = 62085,
                    TvRage = 637041
                }
            };

            ITraktEpisodeCommentPost episodeCommentPost = new TraktEpisodeCommentPost
            {
                Episode = episode,
                Comment = COMMENT_TEXT
            };

            string postJson = await TestUtility.SerializeObject(episodeCommentPost);

            postJson.Should().NotBeNullOrEmpty();

            TraktClient client = TestUtility.GetOAuthMockClient(POST_EPISODE_COMMENT_URI, postJson, COMMENT_POST_RESPONSE_JSON);

            Func <Task <TraktResponse <ITraktCommentPostResponse> > > act = () => client.Comments.PostEpisodeCommentAsync(null, COMMENT_TEXT);

            act.Should().Throw <ArgumentNullException>();

            episode.Ids = null;

            act = () => client.Comments.PostEpisodeCommentAsync(episode, COMMENT_TEXT);
            act.Should().Throw <ArgumentNullException>();

            episode.Ids = new TraktEpisodeIds();

            act = () => client.Comments.PostEpisodeCommentAsync(episode, COMMENT_TEXT);
            act.Should().Throw <ArgumentException>();

            episode.Ids = new TraktEpisodeIds
            {
                Trakt  = 73482,
                Tvdb   = 349232,
                Imdb   = "tt0959621",
                Tmdb   = 62085,
                TvRage = 637041
            };

            act = () => client.Comments.PostEpisodeCommentAsync(episode, null);
            act.Should().Throw <ArgumentException>();

            act = () => client.Comments.PostEpisodeCommentAsync(episode, string.Empty);
            act.Should().Throw <ArgumentException>();

            const string comment = "one two three four";

            act = () => client.Comments.PostEpisodeCommentAsync(episode, comment);
            act.Should().Throw <ArgumentOutOfRangeException>();
        }
Example #21
0
        private TraktEpisodeScrobblePost CreateEpisodeScrobblePost(TraktEpisode episode, float progress, TraktShow show = null,
                                                                   string appVersion = null, DateTime?appDate = null)
        {
            Validate(episode, show);
            ValidateProgress(progress);

            var episodeScrobblePost = new TraktEpisodeScrobblePost
            {
                Episode = new TraktEpisode
                {
                    Ids          = episode.Ids,
                    SeasonNumber = episode.SeasonNumber,
                    Number       = episode.Number
                },
                Show = show != null ? new TraktShow {
                    Title = show.Title
                } : null,
                Progress = progress
            };

            if (!string.IsNullOrEmpty(appVersion))
            {
                episodeScrobblePost.AppVersion = appVersion;
            }

            if (appDate.HasValue)
            {
                episodeScrobblePost.AppDate = appDate.Value.ToTraktDateString();
            }

            return(episodeScrobblePost);
        }
        public void Test_TraktPost_SyncHistoryPostBuilder_AddWatchedEpisode()
        {
            ITraktEpisode episode = new TraktEpisode
            {
                Ids = new TraktEpisodeIds
                {
                    Trakt  = 1,
                    Imdb   = "ttepisodetitle",
                    Tmdb   = 1,
                    Tvdb   = 1,
                    TvRage = 1
                }
            };

            ITraktSyncHistoryPost syncHistoryPost = TraktPost.NewSyncHistoryPost()
                                                    .AddWatchedEpisode(episode).WatchedAt(WATCHED_AT)
                                                    .Build();

            syncHistoryPost.Should().NotBeNull();
            syncHistoryPost.Episodes.Should().NotBeNull().And.HaveCount(1);

            ITraktSyncHistoryPostEpisode postEpisode = syncHistoryPost.Episodes.ToArray()[0];

            postEpisode.Ids.Should().NotBeNull();
            postEpisode.Ids.Trakt.Should().Be(1U);
            postEpisode.Ids.Imdb.Should().Be("ttepisodetitle");
            postEpisode.Ids.Tmdb.Should().Be(1U);
            postEpisode.Ids.Tvdb.Should().Be(1U);
            postEpisode.Ids.TvRage.Should().Be(1U);
            postEpisode.WatchedAt.Should().Be(WATCHED_AT);

            syncHistoryPost.Movies.Should().NotBeNull().And.BeEmpty();
            syncHistoryPost.Shows.Should().NotBeNull().And.BeEmpty();
        }
Example #23
0
 public void deleteEpisode(TraktEpisode traktEpisode)
 {
     if (traktEpisode != null)
     {
         showDao.deleteEpisodeBySeasonInfo(traktEpisode.Tvdb, traktEpisode.Season, traktEpisode.Number);
     }
 }
        public void Test_EpisodeObjectJsonWriter_WriteObject_StringWriter_Exceptions()
        {
            var                   traktJsonWriter = new EpisodeObjectJsonWriter();
            ITraktEpisode         traktEpisode    = new TraktEpisode();
            Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktEpisode);

            action.Should().Throw <ArgumentNullException>();
        }
        /// <summary>Adds a <see cref="TraktEpisode" />, which will be added to the ratings post.</summary>
        /// <param name="episode">The Trakt episode, which will be added.</param>
        /// <param name="rating">A rating from 1 to 10 for the given episode.</param>
        /// <param name="ratedAt">The datetime, when the given episode was rated. Will be converted to the Trakt UTC-datetime and -format.</param>
        /// <returns>The current <see cref="TraktSyncRatingsPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given episode is null.
        /// Thrown, if the given episode ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">Thrown, if the given episode has no valid ids set.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown, if the given rating is not between 1 and 10.</exception>
        public TraktSyncRatingsPostBuilder AddEpisode(TraktEpisode episode, int rating, DateTime ratedAt)
        {
            ValidateEpisode(episode);
            ValidateRating(rating);
            EnsureEpisodesListExists();

            return(AddEpisodeOrIgnore(episode, rating, ratedAt));
        }
Example #26
0
 public static bool IsMatch(BaseItem item, TraktEpisode episode)
 {
     return
         (MatchIds(item.GetProviderId(MetadataProviders.Tvdb), episode.ids.tvdb) ||
          MatchIds(item.GetProviderId(MetadataProviders.Imdb), episode.ids.imdb) ||
          MatchIds(item.GetProviderId(MetadataProviders.Tmdb), episode.ids.tmdb) ||
          MatchIds(item.GetProviderId(MetadataProviders.TvRage), episode.ids.tvrage));
 }
        public async Task Test_EpisodeObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktEpisode traktEpisode = new TraktEpisode
            {
                SeasonNumber = 1,
                Number       = 1,
                Title        = "title",
                Ids          = new TraktEpisodeIds
                {
                    Trakt  = 123456,
                    Tvdb   = 234567,
                    Imdb   = "345678",
                    Tmdb   = 456789,
                    TvRage = 567890
                },
                NumberAbsolute = 1,
                Overview       = "overview",
                Runtime        = 60,
                Rating         = 8.45672f,
                Votes          = 8925,
                FirstAired     = FIRST_AIRED,
                UpdatedAt      = UPDATED_AT,
                AvailableTranslationLanguageCodes = new List <string>
                {
                    "en",
                    "de"
                },
                Translations = new List <TraktEpisodeTranslation>
                {
                    new TraktEpisodeTranslation
                    {
                        Title        = "german title",
                        Overview     = "german overview",
                        LanguageCode = "de"
                    },
                    new TraktEpisodeTranslation
                    {
                        Title        = "english title",
                        Overview     = "english overview",
                        LanguageCode = "en"
                    }
                }
            };

            var    traktJsonWriter = new EpisodeObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktEpisode);

            json.Should().Be(@"{""season"":1,""number"":1,""title"":""title""," +
                             @"""ids"":{""trakt"":123456,""tvdb"":234567,""imdb"":""345678"",""tmdb"":456789,""tvrage"":567890}," +
                             @"""number_abs"":1,""overview"":""overview""," +
                             @"""runtime"":60,""rating"":8.45672,""votes"":8925," +
                             $"\"first_aired\":\"{FIRST_AIRED.ToTraktLongDateTimeString()}\"," +
                             $"\"updated_at\":\"{UPDATED_AT.ToTraktLongDateTimeString()}\"," +
                             @"""available_translations"":[""en"",""de""]," +
                             @"""translations"":[{""title"":""german title"",""overview"":""german overview"",""language"":""de""}," +
                             @"{""title"":""english title"",""overview"":""english overview"",""language"":""en""}]}");
        }
Example #28
0
        private async System.Threading.Tasks.Task updateOtherViews()
        {
            this.episode = await episodeController.getEpisodeByTvdbAndSeasonInfo(this.show.tvdb_id, this.episode.Season, this.episode.Number, this.show);

            if (App.ShowViewModel != null && !String.IsNullOrEmpty(App.ShowViewModel.Tvdb) && App.ShowViewModel.Tvdb.Equals(this.show.tvdb_id))
            {
                App.ShowViewModel.updateEpisode(this.episode);
            }
        }
Example #29
0
        private ITraktEpisode ExtractTraktEpisode(MediaItem episodeMediaItem)
        {
            ITraktEpisode episode = new TraktEpisode
            {
                Number       = MediaItemAspectsUtl.GetEpisodeIndex(episodeMediaItem),
                SeasonNumber = MediaItemAspectsUtl.GetSeasonIndex(episodeMediaItem)
            };

            return(episode);
        }
Example #30
0
 /// <summary>Add a new comment to an episode. If you add a review, it needs to be at least 200 words. Also make sure to allow and encourage spoilers to be indicated in your app.</summary>
 /// <param name="episode">The episode</param>
 /// <param name="comment">The comment</param>
 /// <param name="spoiler">Set to <c>true</c> if the comment contains spoilers</param>
 /// <param name="review">Set to <c>true</c> if the comment is a review</param>
 /// <returns>See summary</returns>
 public async Task <TraktComment> PostEpisodeCommentAsync(TraktEpisode episode, string comment, bool?spoiler = null, bool?review = null)
 {
     return(await SendAsync(new TraktCommentsPostEpisodeRequest(Client) {
         RequestBody = new TraktEpisodeComment {
             Episode = episode,
             Comment = comment,
             Spoiler = spoiler,
             Review = review
         }
     }));
 }