예제 #1
0
        /// <summary>
        /// Constructor to interface directly with the TMDB movie type.
        /// </summary>
        /// <param name="toSet"></param>
        public Movie(TmdbMovie movie)
        {
            TMDBHelper      tmdbHelper = new TMDBHelper();
            TmdbMovieImages image      = tmdbHelper.getImagesById(movie.id);

            string posterLocation = "";

            try
            {
                posterLocation = image.posters[0].file_path;
            }

            catch
            {
                posterLocation = "NONE";
            }

            description   = movie.overview;
            imageLocation = posterLocation;
            mid           = movie.id;
            name          = movie.title;
            onlineRating  = movie.vote_average;
            userRating    = 0.0;
            year          = movie.release_date;
            genres        = movie.genres;
        }
예제 #2
0
 static void RemoveMovieImagesFromCache(TmdbMovieImages images)
 {
     if (images != null)
     {
         Movies.RemoveAll(m => m.Id == images.Id);
     }
 }
예제 #3
0
 static void RemoveMovieImagesFromCache(TmdbMovieImages images)
 {
     if (images != null)
     {
         TmdbMovieImages ignored;
         Movies.TryRemove(images.Id, out ignored);
     }
 }
예제 #4
0
 static void AddMovieImagesToCache(TmdbMovieImages images)
 {
     if (images != null)
     {
         images.RequestAge = DateTime.Now.ToString();
         Movies.TryAdd(images.Id, images);
     }
 }
예제 #5
0
        private void GetPosters(Job job)
        {
            MakeProgress("Getting poster images...");

            foreach (var movie in job.Movies)
            {
                var tmdbMovieImages = new TmdbMovieImages();

                try
                {
                    if (string.IsNullOrEmpty(_rootImageUrl))
                    {
                        _rootImageUrl = Configuration.images.base_url + "original";
                    }
                    tmdbMovieImages = _tmdbApi.GetMovieImages(movie.Id, null);
                    var posterLanguages = (tmdbMovieImages.posters.Select(poster => poster.iso_639_1).ToList());
                    posterLanguages = posterLanguages.Distinct().ToList();

                    if (posterLanguages.Count == 0)
                    {
                        tmdbMovieImages = _tmdbApi.GetMovieImages(movie.Id, "en");
                    }
                }
                catch (Exception ex)
                {
                    HandleTmdbError(ex);
                }

                if (tmdbMovieImages == null)
                {
                    continue;
                }

                foreach (var poster in tmdbMovieImages.posters)
                {
                    poster.file_path = _rootImageUrl + poster.file_path;

                    if (movie.CoverArtImages.OfType <RemoteCoverArt>().All(x => x.Uri != poster.file_path))
                    {
                        movie.CoverArtImages.Add(new RemoteCoverArt
                        {
                            Uri      = _rootImageUrl + poster.file_path,
                            Language = Language.FromCode(poster.iso_639_1)
                        });
                    }
                }
            }
        }
예제 #6
0
        public static string GetMovieBackdropUrl(TmdbMovieImages images)
        {
            if (images == null || images.Backdrops == null)
            {
                return(null);
            }

            var movieBackdrop = images.Backdrops.FirstOrDefault();

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

            // return the desired resolution
            return(TraktSettings.TmdbConfiguration.Images.BaseUrl + (TraktSettings.DownloadFullSizeFanart ? "original" : TraktSettings.TmdbPreferredBackdropSize) + movieBackdrop.FilePath);
        }
예제 #7
0
        public static string GetMoviePosterUrl(TmdbMovieImages images)
        {
            if (images == null || images.Posters == null)
            {
                return(null);
            }

            var moviePoster = images.Posters.LocalisedImage();

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

            // return the desired resolution
            return(TraktSettings.TmdbConfiguration.Images.BaseUrl + TraktSettings.TmdbPreferredPosterSize + moviePoster.FilePath);
        }
예제 #8
0
        public static string GetMovieBackdropFilename(TmdbMovieImages images)
        {
            if (images == null || images.Backdrops == null)
            {
                return(null);
            }

            var movieBackdrop = images.Backdrops.FirstOrDefault();

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

            // create filename based on desired resolution
            return(Path.Combine(Config.GetFolder(Config.Dir.Thumbs), @"Trakt\Movies\Backdrops\") +
                   images.Id + "_" + (TraktSettings.DownloadFullSizeFanart ? "original" : TraktSettings.TmdbPreferredBackdropSize) + "_" + movieBackdrop.FilePath.TrimStart('/'));
        }
예제 #9
0
        public static string GetMoviePosterFilename(TmdbMovieImages images)
        {
            if (images == null || images.Posters == null)
            {
                return(null);
            }

            var moviePoster = images.Posters.LocalisedImage();

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

            // create filename based on desired resolution
            return(Path.Combine(Config.GetFolder(Config.Dir.Thumbs), @"Trakt\Movies\Posters\") +
                   images.Id + "_" + TraktSettings.TmdbPreferredPosterSize + "_" + moviePoster.FilePath.TrimStart('/'));
        }