private TraktSyncRatingsPostBuilder AddMovieOrIgnore(TraktMovie movie, int?rating = null, DateTime?ratedAt = null)
        {
            if (ContainsMovie(movie))
            {
                return(this);
            }

            var ratingsMovie = new TraktSyncRatingsPostMovie();

            ratingsMovie.Ids   = movie.Ids;
            ratingsMovie.Title = movie.Title;
            ratingsMovie.Year  = movie.Year;

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

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

            (_ratingsPost.Movies as List <TraktSyncRatingsPostMovie>).Add(ratingsMovie);

            return(this);
        }
示例#2
0
        public TraktScrobbleModule_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"
            };

            Episode = new TraktEpisode
            {
                SeasonNumber = 1,
                Number       = 1,
                Ids          = new TraktEpisodeIds
                {
                    Trakt  = 16,
                    Tvdb   = 349232,
                    Imdb   = "tt0959621",
                    Tmdb   = 62085,
                    TvRage = 637041
                }
            };
        }
        private void ValidateMovie(TraktMovie movie)
        {
            if (movie == null)
            {
                throw new ArgumentNullException(nameof(movie), "movie must not be null");
            }

            if (string.IsNullOrEmpty(movie.Title))
            {
                throw new ArgumentException("movie title not valid", nameof(movie.Title));
            }

            if (movie.Year <= 0 || movie.Year.ToString().Length != 4)
            {
                throw new ArgumentOutOfRangeException(nameof(movie.Year), "movie year not valid");
            }

            if (movie.Ids == null)
            {
                throw new ArgumentNullException(nameof(movie.Ids), "movie ids must not be null");
            }

            if (!movie.Ids.HasAnyId)
            {
                throw new ArgumentException("movie ids have no valid id", nameof(movie.Ids));
            }
        }
        private void DismissRecommendation(TraktMovie movie)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktMovie dismissMovie = obj as TraktMovie;

                TraktMovieSlug syncMovie = new TraktMovieSlug
                {
                    UserName = TraktSettings.Username,
                    Password = TraktSettings.Password,
                    IMDbId   = dismissMovie.IMDBID,
                    TMDbId   = dismissMovie.TMDBID,
                    Title    = dismissMovie.Title,
                    Year     = dismissMovie.Year
                };

                TraktResponse response = TraktAPI.TraktAPI.DismissMovieRecommendation(syncMovie);
                TraktAPI.TraktAPI.LogTraktResponse <TraktResponse>(response);
                if (response != null && response.Status == "success")
                {
                    TraktHandlers.MovingPictures.UpdateCategoriesAndFilters();
                }
            })
            {
                IsBackground = true,
                Name         = "DismissRecommendation"
            };

            syncThread.Start(movie);
        }
示例#5
0
        private async void ViewMovie_Loaded(object sender, RoutedEventArgs e)
        {
            this.LayoutRoot.Opacity          = 1;
            this.MoviePanorama.SelectedIndex = lastIndex;
            String imdbId;

            NavigationContext.QueryString.TryGetValue("id", out imdbId);

            this.Movie = await movieController.getMovieByImdbId(imdbId);

            if (this.Movie != null)
            {
                if (!String.IsNullOrEmpty(this.Movie.GenresAsString))
                {
                    this.Movie.Genres = Movie.GenresAsString.Split('|');
                }

                App.MovieViewModel.UpdateMovieView(this.Movie);

                LoadBackgroundImage();
                ReloadAppBar();
            }
            else
            {
                ErrorManager.ShowConnectionErrorPopup();
            }
        }
示例#6
0
        public static bool IsMatch(BaseItem item, TraktMovie movie)
        {
            if (movie == null)
            {
                return(false);
            }
            var imdb = item.GetProviderId(MetadataProviders.Imdb);

            if (!string.IsNullOrWhiteSpace(imdb) &&
                string.Equals(imdb, movie?.ids.imdb, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            var tmdb = item.GetProviderId(MetadataProviders.Tmdb);

            if (!string.IsNullOrWhiteSpace(tmdb) && movie.ids.tmdb.HasValue && string.Equals(tmdb, movie.ids.tmdb.Value.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            if (item.Name == movie.title && item.ProductionYear == movie.year)
            {
                return(true);
            }

            return(false);
        }
示例#7
0
        /// <summary>Adds a <see cref="TraktMovie" />, which will be added to the history post.</summary>
        /// <param name="movie">The Trakt movie, which will be added.</param>
        /// <returns>The current <see cref="TraktSyncHistoryPostBuilder" /> instance.</returns>
        /// <exception cref="ArgumentNullException">
        /// Thrown, if the given movie is null.
        /// Thrown, if the given movie ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given movie has no valid ids set.
        /// Thrown, if the given movie has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncHistoryPostBuilder AddMovie(TraktMovie movie)
        {
            ValidateMovie(movie);
            EnsureMoviesListExists();

            return(AddMovieOrIgnore(movie));
        }
示例#8
0
        public async Task <TraktMovieCheckinPostResponse> CheckIntoMovieAsync([NotNull] TraktMovie movie, string appVersion = null, DateTime?appBuildDate = null,
                                                                              string message           = null, TraktSharing sharing = null,
                                                                              string foursquareVenueID = null, string foursquareVenueName = null)
        {
            Validate(movie);

            var requestBody = new TraktMovieCheckinPost
            {
                Movie = new TraktMovie
                {
                    Title = movie.Title,
                    Year  = movie.Year,
                    Ids   = movie.Ids
                },
                Message             = message,
                Sharing             = sharing,
                FoursquareVenueId   = foursquareVenueID,
                FoursquareVenueName = foursquareVenueName
            };

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

            if (appBuildDate.HasValue)
            {
                requestBody.AppDate = appBuildDate.Value.ToTraktDateString();
            }

            return(await QueryAsync(new TraktCheckinRequest <TraktMovieCheckinPostResponse, TraktMovieCheckinPost>(Client)
            {
                RequestBody = requestBody
            }));
        }
示例#9
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"
                }
            };
        }
        private TraktMovieScrobblePost CreateMovieScrobblePost(TraktMovie movie, float progress,
                                                               string appVersion = null, DateTime?appDate = null)
        {
            Validate(movie);
            ValidateProgress(progress);

            var movieScrobblePost = new TraktMovieScrobblePost
            {
                Movie = new TraktMovie
                {
                    Title = movie.Title,
                    Year  = movie.Year,
                    Ids   = movie.Ids
                },
                Progress = progress
            };

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

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

            return(movieScrobblePost);
        }
        public static T Convert <T>(TraktMovie traktMovie) where T : TraktMovie, new()
        {
            if (traktMovie == null)
            {
                return(null);
            }

            var movie = Activator.CreateInstance <T>();

            if (movie == null)
            {
                return(null);
            }

            movie.AvailableTranslationLanguageCodes = traktMovie.AvailableTranslationLanguageCodes ?? new List <string>();
            movie.Certification = traktMovie.Certification ?? string.Empty;
            movie.Genres        = traktMovie.Genres ?? new List <string>();
            movie.Homepage      = traktMovie.Homepage ?? string.Empty;
            movie.LanguageCode  = traktMovie.LanguageCode ?? string.Empty;
            movie.Overview      = traktMovie.Overview ?? string.Empty;
            movie.Rating        = traktMovie.Rating ?? 0.0f;
            movie.Runtime       = traktMovie.Runtime ?? 0;
            movie.Tagline       = traktMovie.Tagline ?? string.Empty;
            movie.Title         = traktMovie.Title ?? string.Empty;
            movie.Trailer       = traktMovie.Trailer ?? string.Empty;
            movie.Votes         = traktMovie.Votes ?? 0;
            movie.Year          = traktMovie.Year ?? 1900;
            movie.Ids           = traktMovie.Ids;
            movie.Released      = traktMovie.Released;
            movie.UpdatedAt     = traktMovie.UpdatedAt;

            movie.Images = GetImages(traktMovie);

            return(movie as T);
        }
        private TraktMovieSync CreateMovieSyncData(TraktMovie movie)
        {
            if (movie == null)
            {
                return(null);
            }

            TraktMovieSync.Movie syncMovie = new TraktMovieSync.Movie
            {
                IMDBID = movie.IMDBID,
                Title  = movie.Title,
                Year   = movie.Year
            };

            TraktMovieSync syncData = new TraktMovieSync
            {
                UserName  = TraktSettings.Username,
                Password  = TraktSettings.Password,
                MovieList = new List <TraktMovieSync.Movie> {
                    syncMovie
                }
            };

            return(syncData);
        }
示例#13
0
        /// <summary>
        /// Fetches the movie from Trakt when not available in the local database, once fetched
        /// the local database will be used to fetch the data without a network connection.
        /// </summary>
        /// <param name="IMDB">The IMDB of the movie.</param>
        /// <returns>The TraktMovie object. If there is a network/database error, NULL will be returned.</returns>
        internal async Task <TraktMovie> getMovieByIMDB(String IMDB)
        {
            try
            {
                if (!this.DatabaseExists())
                {
                    this.CreateDatabase();
                }

                if (this.Movies.Where(t => t.imdb_id == IMDB).Count() > 0)
                {
                    Debug.WriteLine("Fetching movie " + IMDB + " from DB.");
                    TraktMovie movie = this.Movies.Where(t => t.imdb_id == IMDB).FirstOrDefault();
                    saveMovie(movie);

                    return(movie);
                }
                else
                {
                    return(await getMovieByIMDBThroughTrakt(IMDB));
                }
            }
            catch (OperationCanceledException)
            {
                GoogleAnalytics.EasyTracker.GetTracker().SendException("OperationCanceledException in getMovieByIMDB(" + IMDB + ").", false);
            }
            catch (InvalidOperationException)
            {
                GoogleAnalytics.EasyTracker.GetTracker().SendException("InvalidOperationException in getMovieByIMDB(" + IMDB + ").", false);
            }

            return(TraktMovie.NULLMOVIE);
        }
示例#14
0
        /// <summary>
        /// Save/update a movie to the local database.
        /// </summary>
        /// <param name="traktMovie">The TraktMovie object.</param>
        /// <returns>Returns TRUE when saving/updating was successfull. If it fails, FALSE is returned.</returns>
        internal Boolean saveMovie(TraktMovie traktMovie)
        {
            try
            {
                traktMovie.LastOpenedTime = DateTime.Now;

                if (!this.DatabaseExists())
                {
                    this.CreateDatabase();
                }

                if (this.Movies.Where(t => t.imdb_id == traktMovie.imdb_id).Count() == 0)
                {
                    this.Movies.InsertOnSubmit(traktMovie);
                }

                Debug.WriteLine("Saving movie " + traktMovie.Title + " to DB.");

                this.SubmitChanges(ConflictMode.FailOnFirstConflict);

                return(true);
            }
            catch (OperationCanceledException)
            { GoogleAnalytics.EasyTracker.GetTracker().SendException("OperationCanceledException in saveMovie(" + traktMovie.Title + ").", false); }
            catch (InvalidOperationException)
            { GoogleAnalytics.EasyTracker.GetTracker().SendException("InvalidOperationException in saveMovie(" + traktMovie.Title + ").", false); }

            return(false);
        }
示例#15
0
        private void OnMovieSelected(GUIListItem item, GUIControl parent)
        {
            TraktMovie movie = item.TVTag as TraktMovie;

            PublishMovieSkinProperties(movie);
            GUIImageHandler.LoadFanart(backdrop, movie.Images.FanartImageFilename);
        }
示例#16
0
        /// <summary>Adds a <see cref="TraktMovie" />, which will be added to the collection post.</summary>
        /// <param name="movie">The Trakt movie, which will be added.</param>
        /// <param name="metadata">An <see cref="TraktMetadata" /> instance, containing metadata about the given movie.</param>
        /// <param name="collectedAt">The datetime, when the given movie 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 movie is null.
        /// Thrown, if the given movie ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given movie has no valid ids set.
        /// Thrown, if the given movie has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncCollectionPostBuilder AddMovie(TraktMovie movie, TraktMetadata metadata, DateTime collectedAt)
        {
            ValidateMovie(movie);
            EnsureMoviesListExists();

            return(AddMovieOrIgnore(movie, metadata, collectedAt));
        }
示例#17
0
        public void Test_TraktPost_SyncWatchlistPostBuilder_WithMovie()
        {
            ITraktMovie movie = new TraktMovie
            {
                Title = "movie title",
                Year  = 2020,
                Ids   = new TraktMovieIds
                {
                    Trakt = 1,
                    Slug  = "movie-title",
                    Imdb  = "ttmovietitle",
                    Tmdb  = 1
                }
            };

            ITraktSyncWatchlistPost syncWatchlistPost = TraktPost.NewSyncWatchlistPost()
                                                        .WithMovie(movie)
                                                        .Build();

            syncWatchlistPost.Should().NotBeNull();
            syncWatchlistPost.Movies.Should().NotBeNull().And.HaveCount(1);

            ITraktSyncWatchlistPostMovie postMovie = syncWatchlistPost.Movies.ToArray()[0];

            postMovie.Title = "movie title";
            postMovie.Year  = 2020;
            postMovie.Ids.Should().NotBeNull();
            postMovie.Ids.Trakt.Should().Be(1U);
            postMovie.Ids.Slug.Should().Be("movie-title");
            postMovie.Ids.Imdb.Should().Be("ttmovietitle");
            postMovie.Ids.Tmdb.Should().Be(1U);

            syncWatchlistPost.Shows.Should().NotBeNull().And.BeEmpty();
            syncWatchlistPost.Episodes.Should().NotBeNull().And.BeEmpty();
        }
示例#18
0
        private TraktSyncCollectionPostBuilder AddMovieOrIgnore(TraktMovie movie, TraktMetadata metadata = null,
                                                                DateTime?collectedAt = null)
        {
            if (ContainsMovie(movie))
            {
                return(this);
            }

            var collectionMovie = new TraktSyncCollectionPostMovie();

            collectionMovie.Ids   = movie.Ids;
            collectionMovie.Title = movie.Title;
            collectionMovie.Year  = movie.Year;

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

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

            (_collectionPost.Movies as List <TraktSyncCollectionPostMovie>).Add(collectionMovie);

            return(this);
        }
        /// <summary>Adds a <see cref="TraktMovie" />, which will be added to the history post.</summary>
        /// <param name="movie">The Trakt movie, which will be added.</param>
        /// <param name="watchedAt">The datetime, when the given movie 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 movie is null.
        /// Thrown, if the given movie ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given movie has no valid ids set.
        /// Thrown, if the given movie has an year set, which has more or less than four digits.
        /// </exception>
        public TraktSyncHistoryPostBuilder AddMovie(TraktMovie movie, DateTime watchedAt)
        {
            ValidateMovie(movie);
            EnsureMoviesListExists();

            return(AddMovieOrIgnore(movie, watchedAt) as TraktSyncHistoryPostBuilder);
        }
        public async Task <TraktMovieScrobblePostResponse> StopMovieAsync([NotNull] TraktMovie movie, float progress,
                                                                          string appVersion = null, DateTime?appBuildDate = null)
        {
            var requestBody = CreateMovieScrobblePost(movie, progress, appVersion, appBuildDate);

            return(await QueryAsync(CreateScrobbleStopRequest <TraktMovieScrobblePostResponse, TraktMovieScrobblePost>(requestBody)));
        }
        public void Test_TraktPost_SyncRatingsPostBuilder_AddMovieWithNotes()
        {
            ITraktMovie movie = new TraktMovie
            {
                Title = "movie title",
                Year  = 2020,
                Ids   = new TraktMovieIds
                {
                    Trakt = 1,
                    Slug  = "movie-title",
                    Imdb  = "ttmovietitle",
                    Tmdb  = 1
                }
            };

            ITraktSyncRecommendationsPost syncRecommendationsPost = TraktPost.NewSyncRecommendationsPost()
                                                                    .AddMovieWithNotes(movie, TEST_NOTES)
                                                                    .Build();

            syncRecommendationsPost.Should().NotBeNull();
            syncRecommendationsPost.Movies.Should().NotBeNull().And.HaveCount(1);

            ITraktSyncRecommendationsPostMovie postMovie = syncRecommendationsPost.Movies.ToArray()[0];

            postMovie.Title = "movie title";
            postMovie.Year  = 2020;
            postMovie.Ids.Should().NotBeNull();
            postMovie.Ids.Trakt.Should().Be(1U);
            postMovie.Ids.Slug.Should().Be("movie-title");
            postMovie.Ids.Imdb.Should().Be("ttmovietitle");
            postMovie.Ids.Tmdb.Should().Be(1U);
            postMovie.Notes.Should().Be(TEST_NOTES);

            syncRecommendationsPost.Shows.Should().NotBeNull().And.BeEmpty();
        }
示例#22
0
        public void Test_TraktPost_UserCustomListItemsPostBuilder_WithMovie()
        {
            ITraktMovie movie = new TraktMovie
            {
                Ids = new TraktMovieIds
                {
                    Trakt = 1,
                    Slug  = "movie-title",
                    Imdb  = "ttmovietitle",
                    Tmdb  = 1
                }
            };

            ITraktUserCustomListItemsPost userCustomListItemsPost = TraktPost.NewUserCustomListItemsPost()
                                                                    .WithMovie(movie)
                                                                    .Build();

            userCustomListItemsPost.Should().NotBeNull();
            userCustomListItemsPost.Movies.Should().NotBeNull().And.HaveCount(1);

            ITraktUserCustomListItemsPostMovie postMovie = userCustomListItemsPost.Movies.ToArray()[0];

            postMovie.Ids.Should().NotBeNull();
            postMovie.Ids.Trakt.Should().Be(1U);
            postMovie.Ids.Slug.Should().Be("movie-title");
            postMovie.Ids.Imdb.Should().Be("ttmovietitle");
            postMovie.Ids.Tmdb.Should().Be(1U);

            userCustomListItemsPost.Shows.Should().NotBeNull().And.BeEmpty();
            userCustomListItemsPost.People.Should().NotBeNull().And.BeEmpty();
        }
        public void Test_TraktPost_UserHiddenItemsPostBuilder_WithMovie()
        {
            ITraktMovie movie = new TraktMovie
            {
                Title = "movie title",
                Year  = 2020,
                Ids   = new TraktMovieIds
                {
                    Trakt = 1,
                    Slug  = "movie-title",
                    Imdb  = "ttmovietitle",
                    Tmdb  = 1
                }
            };

            ITraktUserHiddenItemsPost userHiddenItemsPost = TraktPost.NewUserHiddenItemsPost()
                                                            .WithMovie(movie)
                                                            .Build();

            userHiddenItemsPost.Should().NotBeNull();
            userHiddenItemsPost.Movies.Should().NotBeNull().And.HaveCount(1);

            ITraktUserHiddenItemsPostMovie postMovie = userHiddenItemsPost.Movies.ToArray()[0];

            postMovie.Title = "movie title";
            postMovie.Year  = 2020;
            postMovie.Ids.Should().NotBeNull();
            postMovie.Ids.Trakt.Should().Be(1U);
            postMovie.Ids.Slug.Should().Be("movie-title");
            postMovie.Ids.Imdb.Should().Be("ttmovietitle");
            postMovie.Ids.Tmdb.Should().Be(1U);

            userHiddenItemsPost.Shows.Should().NotBeNull().And.BeEmpty();
            userHiddenItemsPost.Seasons.Should().NotBeNull().And.BeEmpty();
        }
        public void TestTraktMovieCommentPostWriteJson()
        {
            var comment = "this is a comment";
            var spoiler = true;
            var sharing = new TraktSharing {
                Facebook = true, Twitter = true, Tumblr = true
            };

            var movieTitle   = "Guardians of the Galaxy";
            var movieYear    = 2014;
            var movieTraktId = 28U;
            var movieSlug    = "guardiangs-of-the-galaxy-2014";
            var movieImdb    = "tt2015381";
            var movieTmdb    = 118340U;

            var movie = new TraktMovie
            {
                Title = movieTitle,
                Year  = movieYear,
                Ids   = new TraktMovieIds
                {
                    Trakt = movieTraktId,
                    Slug  = movieSlug,
                    Imdb  = movieImdb,
                    Tmdb  = movieTmdb
                }
            };

            var movieComment = new TraktMovieCommentPost
            {
                Comment = comment,
                Spoiler = spoiler,
                Sharing = sharing,
                Movie   = movie
            };

            var strJson = JsonConvert.SerializeObject(movieComment);

            strJson.Should().NotBeNullOrEmpty();

            var movieCommentFromJson = JsonConvert.DeserializeObject <TraktMovieCommentPost>(strJson);

            movieCommentFromJson.Should().NotBeNull();
            movieCommentFromJson.Comment.Should().Be(comment);
            movieCommentFromJson.Spoiler.Should().Be(spoiler);
            movieCommentFromJson.Sharing.Should().NotBeNull();
            movieCommentFromJson.Sharing.Facebook.Should().BeTrue();
            movieCommentFromJson.Sharing.Twitter.Should().BeTrue();
            movieCommentFromJson.Sharing.Tumblr.Should().BeTrue();

            movieCommentFromJson.Movie.Should().NotBeNull();
            movieCommentFromJson.Movie.Title.Should().Be(movieTitle);
            movieCommentFromJson.Movie.Year.Should().Be(movieYear);
            movieCommentFromJson.Movie.Ids.Should().NotBeNull();
            movieCommentFromJson.Movie.Ids.Trakt.Should().Be(movieTraktId);
            movieCommentFromJson.Movie.Ids.Slug.Should().Be(movieSlug);
            movieCommentFromJson.Movie.Ids.Imdb.Should().Be(movieImdb);
            movieCommentFromJson.Movie.Ids.Tmdb.Should().Be(movieTmdb);
        }
        /// <summary>Adds a <see cref="TraktMovie" />, which will be added to the ratings post.</summary>
        /// <param name="movie">The Trakt movie, which will be added.</param>
        /// <param name="rating">A rating from 1 to 10 for the given movie.</param>
        /// <param name="ratedAt">The datetime, when the given movie 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 movie is null.
        /// Thrown, if the given movie ids are null.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// Thrown, if the given movie has no valid ids set.
        /// Thrown, if the given movie has an year set, which has more or less than four digits.
        /// </exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown, if the given rating is not between 1 and 10.</exception>
        public TraktSyncRatingsPostBuilder AddMovie(TraktMovie movie, int rating, DateTime ratedAt)
        {
            ValidateMovie(movie);
            ValidateRating(rating);
            EnsureMoviesListExists();

            return(AddMovieOrIgnore(movie, rating, ratedAt));
        }
示例#26
0
        public Boolean updateMovie(TraktMovie movie)
        {
            if (movie != null)
            {
                return(movieDao.saveMovie(movie));
            }

            return(false);
        }
示例#27
0
        public void loadRecent()
        {
            if (!Loading)
            {
                this.EmptyRecent.Visibility = System.Windows.Visibility.Collapsed;
                this.indicator = App.ShowLoading(this);
                this.Loading   = true;
                App.ViewModel.clearRecent();
                TraktShow[]  shows  = showController.getRecentShows();
                TraktMovie[] movies = movieController.getRecentMovies();

                List <Object> mergedList = new List <object>();
                mergedList.AddRange(shows);
                mergedList.AddRange(movies);

                mergedList.Sort((x, y) => DateTime.Compare(DateTime.Parse(y.ToString()), (DateTime.Parse(x.ToString()))));

                foreach (Object movieOrShow in mergedList)
                {
                    if (App.ViewModel.RecentItems.Count == 12)
                    {
                        break;
                    }

                    if (typeof(TraktShow) == movieOrShow.GetType())
                    {
                        TraktShow         show     = (TraktShow)movieOrShow;
                        ListItemViewModel newModel = new ListItemViewModel()
                        {
                            ImageSource = show.Images.Poster, Tvdb = show.tvdb_id, Type = "show"
                        };
                        App.ViewModel.RecentItems.Add(newModel);
                        newModel.LoadPosterImage();
                    }
                    else
                    {
                        TraktMovie        movie    = (TraktMovie)movieOrShow;
                        ListItemViewModel newModel = new ListItemViewModel()
                        {
                            ImageSource = movie.Images.Poster, Imdb = movie.imdb_id, Type = "movie"
                        };
                        App.ViewModel.RecentItems.Add(newModel);
                        newModel.LoadPosterImage();
                    }
                }

                if (App.ViewModel.RecentItems.Count == 0)
                {
                    this.EmptyRecent.Visibility = System.Windows.Visibility.Visible;
                }

                App.ViewModel.NotifyPropertyChanged("RecentItems");

                this.indicator.IsVisible = false;
                this.Loading             = false;
            }
        }
        private void OnMovieSelected(GUIListItem item, GUIControl parent)
        {
            PreviousSelectedIndex = Facade.SelectedListItemIndex;

            TraktMovie movie = item.TVTag as TraktMovie;

            PublishMovieSkinProperties(movie);
            GUIImageHandler.LoadFanart(backdrop, movie.Images.Fanart.LocalImageFilename(ArtworkType.MovieFanart));
        }
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the main overlay to add to poster
            TraktMovie       movie       = TVTag as TraktMovie;
            MainOverlayImage mainOverlay = MainOverlayImage.None;

            if (movie.InWatchList)
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }
            if (movie.InCollection)
            {
                mainOverlay |= MainOverlayImage.Library;
            }

            // we never show rating movies in Recommendations
            RatingOverlayImage ratingOverlay = RatingOverlayImage.None;

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = mainOverlay.ToString().Replace(", ", string.Empty) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay);
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected((int)TraktGUIWindows.RecommendationsMovies, ItemId);
        }
示例#30
0
        void OnSearchResultSelected(GUIListItem item, GUIControl parent)
        {
            TorrentMatch selectedmatch = item.AlbumInfoTag as TorrentMatch;

            Thread backdrop = new Thread(delegate()
            {
                if (!string.IsNullOrEmpty(selectedmatch.tvdb))
                {
                    TraktShow show = TraktAPI.SeriesOverview(selectedmatch.tvdb);
                    if (!string.IsNullOrEmpty(show.Title))
                    {
                        GUIPropertyManager.SetProperty("#MyTorrents.Backdrop", show.Images.Fanart);
                        GUIPropertyManager.SetProperty("#MyTorrents.Poster", show.Images.Poster);
                        GUIPropertyManager.SetProperty("#MyTorrents.Title", show.Title);
                        GUIPropertyManager.SetProperty("#MyTorrents.Year", show.Year.ToString());
                        GUIPropertyManager.SetProperty("#MyTorrents.Summary", show.Overview);
                        GUIPropertyManager.SetProperty("#MyTorrents.Runtime", show.Runtime.ToString());
                        GUIPropertyManager.SetProperty("#MyTorrents.Certification", show.Certification);
                        GUIPropertyManager.SetProperty("#MyTorrents.Rating", show.Rating);
                    }
                }
                else if (!string.IsNullOrEmpty(selectedmatch.imdb))
                {
                    TraktMovie movie = TraktAPI.MovieOverview("tt" + Convert.ToInt32(selectedmatch.imdb).ToString("0000000"));
                    if (!string.IsNullOrEmpty(movie.Title))
                    {
                        GUIPropertyManager.SetProperty("#MyTorrents.Backdrop", movie.Images.Fanart);
                        GUIPropertyManager.SetProperty("#MyTorrents.Poster", movie.Images.Poster);
                        GUIPropertyManager.SetProperty("#MyTorrents.Title", movie.Title);
                        GUIPropertyManager.SetProperty("#MyTorrents.Year", movie.Year);
                        GUIPropertyManager.SetProperty("#MyTorrents.Summary", movie.Overview);
                        GUIPropertyManager.SetProperty("#MyTorrents.Runtime", movie.Runtime.ToString());
                        GUIPropertyManager.SetProperty("#MyTorrents.Certification", movie.Certification);
                        GUIPropertyManager.SetProperty("#MyTorrents.Rating", movie.Rating);
                        GUIPropertyManager.SetProperty("#MyTorrents.Trailer", movie.Trailer);
                    }
                }
                else
                {
                    GUIPropertyManager.SetProperty("#MyTorrents.Backdrop", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Poster", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Title", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Year", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Summary", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Runtime", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Certification", "");
                    GUIPropertyManager.SetProperty("#MyTorrents.Rating", "");
                }
            })
            {
                IsBackground = true,
                Name         = "MyTorrent Backdrop Lookup"
            };

            backdrop.Start();
        }
        private static bool MoviesMatch(TraktMovie traktMovie, WatchlistMovie watchlistMovie)
        {
            // Try matching by ids first
            if (watchlistMovie.TraktId == traktMovie.Ids.Trakt) { return true; }

            // Fall back to title and year match (but only if we don't know the Trakt id)
            if (watchlistMovie.TraktId == 0 && watchlistMovie.Title == traktMovie.Title && watchlistMovie.Year == (traktMovie.Year ?? 0)) { return true; }

            return false;
        }