コード例 #1
0
 private void PublishMovieSkinProperties(TraktMovieSummary PopularItem)
 {
     GUICommon.SetMovieProperties(PopularItem);
 }
コード例 #2
0
        public static void ShowMovieTrailersMenu(TraktMovieSummary movie)
        {
            if (TraktHelper.IsTrailersAvailableAndEnabled)
            {

                CurrentMediaType = MediaType.Movie;
                CurrentMovie = movie;

                // check for parental controls
                if (PromptForPinCode)
                {
                    if (!GUIUtils.ShowPinCodeDialog(TraktSettings.ParentalControlsPinCode))
                    {
                        TraktLogger.Warning("Parental controls pin code has not successfully been entered. Window ID = {0}", GUIWindowManager.ActiveWindow);
                        return;
                    }
                }

                ShowMovieTrailersPluginMenu(movie);
                return;
            }
        }
コード例 #3
0
        public static void ShowMovieTrailersPluginMenu(TraktMovieSummary movie)
        {
            var images = TmdbCache.GetMovieImages(movie.Ids.Tmdb, true);

            var trailerItem = new MediaItem
            {
                IMDb = movie.Ids.Imdb.ToNullIfEmpty(),
                TMDb = movie.Ids.Tmdb.ToString(),
                Plot = movie.Overview,
                Poster = TmdbCache.GetMoviePosterFilename(images),
                Title = movie.Title,
                Year = movie.Year.GetValueOrDefault(0)
            };
            Trailers.Trailers.SearchForTrailers(trailerItem);
        }
コード例 #4
0
        internal static void SetMovieProperties(TraktMovieSummary movie)
        {
            if (movie == null) return;

            SetProperty("#Trakt.Movie.Id", movie.Ids.Trakt);
            SetProperty("#Trakt.Movie.ImdbId", movie.Ids.Imdb);
            SetProperty("#Trakt.Movie.TmdbId", movie.Ids.Tmdb);
            SetProperty("#Trakt.Movie.Slug", movie.Ids.Slug);
            SetProperty("#Trakt.Movie.Certification", movie.Certification);
            SetProperty("#Trakt.Movie.Overview", movie.Overview.ToNullIfEmpty() == null ? Translation.NoMovieSummary : movie.Overview.RemapHighOrderChars());
            SetProperty("#Trakt.Movie.Released", movie.Released);
            SetProperty("#Trakt.Movie.Language", Translation.GetLanguageFromISOCode(movie.Language));
            SetProperty("#Trakt.Movie.Runtime", movie.Runtime);
            SetProperty("#Trakt.Movie.Tagline", movie.Tagline);
            SetProperty("#Trakt.Movie.Title", movie.Title.RemapHighOrderChars());
            SetProperty("#Trakt.Movie.Trailer", movie.Trailer);
            SetProperty("#Trakt.Movie.Url", string.Format("http://trakt.tv/movies/{0}", movie.Ids.Slug));
            SetProperty("#Trakt.Movie.Year", movie.Year);
            SetProperty("#Trakt.Movie.Genres", TraktGenres.Translate(movie.Genres));
            SetProperty("#Trakt.Movie.InCollection", movie.IsCollected());
            SetProperty("#Trakt.Movie.InWatchList", movie.IsWatchlisted());
            SetProperty("#Trakt.Movie.Plays", movie.Plays());
            SetProperty("#Trakt.Movie.Watched", movie.IsWatched());
            SetProperty("#Trakt.Movie.Rating", movie.UserRating());
            SetProperty("#Trakt.Movie.Ratings.Percentage", movie.Rating.ToPercentage());
            SetProperty("#Trakt.Movie.Ratings.Votes", movie.Votes);
            SetProperty("#Trakt.Movie.Ratings.Icon", (movie.Rating >= 6) ? "love" : "hate");
        }
コード例 #5
0
        internal static bool RateMovie(TraktMovieSummary movie)
        {
            var rateObject = new TraktSyncMovieRated
            {
                Ids = new TraktMovieId
                {
                    Trakt = movie.Ids.Trakt,
                    Imdb = movie.Ids.Imdb.ToNullIfEmpty(),
                    Tmdb = movie.Ids.Tmdb
                },
                Title = movie.Title,
                Year = movie.Year,
                RatedAt = DateTime.UtcNow.ToISO8601()
            };

            int? prevRating = movie.UserRating();
            int newRating = 0;

            newRating = GUIUtils.ShowRateDialog<TraktSyncMovieRated>(rateObject);
            if (newRating == -1) return false;

            // If previous rating not equal to current rating then
            // update skin properties to reflect changes
            if (prevRating == newRating)
                return false;

            if (prevRating == null || prevRating == 0)
            {
                // add to ratings
                TraktCache.AddMovieToRatings(movie, newRating);
                movie.Votes++;
            }
            else if (newRating == 0)
            {
                // remove from ratings
                TraktCache.RemoveMovieFromRatings(movie);
                movie.Votes--;
            }
            else
            {
                // rating changed, remove then add
                TraktCache.RemoveMovieFromRatings(movie);
                TraktCache.AddMovieToRatings(movie, newRating);
            }

            // update ratings until next online update
            // if we have the ratings distribution we could calculate correctly
            if (movie.Votes == 0)
            {
                movie.Rating = 0;
            }
            else if (movie.Votes == 1 && newRating > 0)
            {
                movie.Rating = newRating;
            }

            return true;
        }
コード例 #6
0
        /// <summary>
        /// Checks if a selected movie exists locally and plays movie or
        /// jumps to corresponding plugin details view
        /// </summary>
        /// <param name="jumpTo">false if movie should be played directly</param>
        internal static void CheckAndPlayMovie(bool jumpTo, TraktMovieSummary movie)
        {
            if (movie == null) return;

            CurrentMediaType = MediaType.Movie;
            CurrentMovie = movie;

            // check for parental controls
            if (PromptForPinCode)
            {
                if (!GUIUtils.ShowPinCodeDialog(TraktSettings.ParentalControlsPinCode))
                {
                    TraktLogger.Warning("Parental controls pin code has not successfully been entered. Window ID = {0}", GUIWindowManager.ActiveWindow);
                    return;
                }
            }

            TraktLogger.Info("Attempting to play movie. Title = '{0}', Year = '{1}', IMDb ID = '{2}'", movie.Title, movie.Year.ToLogString(), movie.Ids.Imdb.ToLogString());
            bool handled = false;

            if (TraktHelper.IsMovingPicturesAvailableAndEnabled)
            {
                TraktLogger.Info("Checking if any movie to watch in MovingPictures");
                int? movieid = null;

                // Find Movie ID in MovingPictures
                // Movie list is now cached internally in MovingPictures so it will be fast
                bool movieExists = TraktHandlers.MovingPictures.FindMovieID(movie.Title, movie.Year.GetValueOrDefault(), movie.Ids.Imdb, ref movieid);

                if (movieExists)
                {
                    TraktLogger.Info("Found movie in MovingPictures with movie ID '{0}'", movieid.ToString());
                    if (jumpTo)
                    {
                        string loadingParameter = string.Format("movieid:{0}", movieid);
                        // Open MovingPictures Details view so user can play movie
                        GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MovingPictures, loadingParameter);
                    }
                    else
                    {
                        TraktHandlers.MovingPictures.PlayMovie(movieid);
                    }
                    handled = true;
                }
            }

            // check if its in My Videos database
            if (TraktSettings.MyVideos >= 0 && handled == false)
            {
                TraktLogger.Info("Checking if any movie to watch in My Videos");
                IMDBMovie imdbMovie = null;
                if (TraktHandlers.MyVideos.FindMovieID(movie.Title, movie.Year.GetValueOrDefault(), movie.Ids.Imdb, ref imdbMovie))
                {
                    // Open My Videos Video Info view so user can play movie
                    if (jumpTo)
                    {
                        GUIVideoInfo videoInfo = (GUIVideoInfo)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIDEO_INFO);
                        videoInfo.Movie = imdbMovie;
                        GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_VIDEO_INFO);
                    }
                    else
                    {
                        GUIVideoFiles.PlayMovie(imdbMovie.ID, false);
                    }
                    handled = true;
                }
            }

            // check if its in My Films database
            if (TraktHelper.IsMyFilmsAvailableAndEnabled && handled == false)
            {
                TraktLogger.Info("Checking if any movie to watch in My Films");
                int? movieid = null;
                string config = null;
                if (TraktHandlers.MyFilmsHandler.FindMovie(movie.Title, movie.Year.GetValueOrDefault(), movie.Ids.Imdb, ref movieid, ref config))
                {
                    // Open My Films Details view so user can play movie
                    if (jumpTo)
                    {
                        string loadingParameter = string.Format("config:{0}|movieid:{1}", config, movieid);
                        GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyFilms, loadingParameter);
                    }
                    else
                    {
                        // TraktHandlers.MyFilms.PlayMovie(config, movieid); // TODO: Add Player Class to MyFilms
                        string loadingParameter = string.Format("config:{0}|movieid:{1}|play:{2}", config, movieid, "true");
                        GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyFilms, loadingParameter);
                    }
                    handled = true;
                }
            }

            if (TraktHelper.IsTrailersAvailableAndEnabled && handled == false)
            {
                TraktLogger.Info("There were no movies found in local plugin databases. Attempting to search and/or play trailer(s) from the Trailers plugin");
                ShowMovieTrailersPluginMenu(movie);
                handled = true;
            }
        }
コード例 #7
0
 private void PublishMovieSkinProperties(TraktMovieSummary movie)
 {
     GUICommon.SetMovieProperties(movie);
 }
コード例 #8
0
 public static void ShowMovieShouts(TraktMovieSummary movie)
 {
     var images = TmdbCache.GetMovieImages(movie.Ids.Tmdb, true);
     ShowMovieShouts(movie.Title, movie.Year, movie.Ids.Imdb, movie.Ids.Trakt, movie.IsWatched(), TmdbCache.GetMovieBackdropFilename(images), TmdbCache.GetMovieBackdropUrl(images));
 }