コード例 #1
0
 private bool GetResults(IEnumerable <TmdbMovie> searchResults)
 {
     foreach (var item in searchResults)
     {
         if (item == null)
         {
             continue;
         }
         if (FileManager.CancellationPending)
         {
             return(ResultsList.Count != 0);
         }
         // get movie info
         MovieInfo movieInfo = GetMovieInfo(item);
         if (string.IsNullOrEmpty(movieInfo.IMDBID) && !IsValidYear(movieInfo.Year))
         {
             continue;
         }
         // having the tmdbid, call getimages
         var imagesData = api.GetMovieImages(item.id, "ALL");
         // posters
         if (imagesData.posters.Any())
         {
             foreach (var poster in imagesData.posters.OrderByDescending(x => x.vote_average))
             {
                 var imageUrl = string.Format("{0}{1}{2}", configuration.images.base_url, "original", poster.file_path);
                 AddResultItem(item.id.ToString(CultureInfo.InvariantCulture), movieInfo, imageUrl);
             }
         }
         else
         {
             // no poster found, add anyway the movie without image
             if (!string.IsNullOrEmpty(movieInfo.Name))
             {
                 AddResultItem(item.id.ToString(CultureInfo.InvariantCulture), movieInfo, null);
             }
         }
         // backdrops
         if (imagesData.backdrops.Any())
         {
             foreach (var backdrop in imagesData.backdrops.OrderByDescending(x => x.vote_average))
             {
                 var thumbUrl    = string.Format("{0}{1}{2}", configuration.images.base_url, configuration.images.backdrop_sizes.First(), backdrop.file_path);
                 var originalUrl = string.Format("{0}{1}{2}", configuration.images.base_url, "original", backdrop.file_path);
                 var bi          = new BackdropItem(item.id.ToString(CultureInfo.InvariantCulture), item.imdb_id, CollectorName, thumbUrl, originalUrl);
                 bi.SetSize(backdrop.width.ToString(CultureInfo.InvariantCulture), backdrop.height.ToString(CultureInfo.InvariantCulture));
                 BackdropsList.Add(bi);
             }
         }
     }
     return(ResultsList.Count != 0);
 }
コード例 #2
0
        public void GetMovieImages()
        {
            var result = api.GetMovieImages(49049);

            Assert.Greater(result.posters.Count, 0);

            foreach (var picture in result.posters)
            {
                Console.WriteLine(
                    picture.file_path + " - " + picture.width + "x" + picture.height + " - " +
                    picture.aspect_ratio + " - " + picture.iso_639_1);
            }

            Console.WriteLine();
            Console.WriteLine();

            foreach (var picture in result.backdrops)
            {
                Console.WriteLine(
                    picture.file_path + " - " + picture.width + "x" + picture.height + " - " +
                    picture.aspect_ratio + " - " + picture.iso_639_1);
            }
        }
コード例 #3
0
 public TmdbMovieImages getImagesById(int mid)
 {
     return(api.GetMovieImages(mid));
 }