/// <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; }
static void RemoveMovieImagesFromCache(TmdbMovieImages images) { if (images != null) { Movies.RemoveAll(m => m.Id == images.Id); } }
static void RemoveMovieImagesFromCache(TmdbMovieImages images) { if (images != null) { TmdbMovieImages ignored; Movies.TryRemove(images.Id, out ignored); } }
static void AddMovieImagesToCache(TmdbMovieImages images) { if (images != null) { images.RequestAge = DateTime.Now.ToString(); Movies.TryAdd(images.Id, images); } }
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) }); } } } }
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); }
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); }
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('/')); }
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('/')); }