public async Task Update(string path, AvailableTvShowImages images)
 {
     TvShowImages tvShowImages = await _tvShowFileService.GetShowImages(path);
     await UpdateImageIfNeeded(tvShowImages.Fanart, images.Fanarts);
     await UpdateImageIfNeeded(tvShowImages.Poster, images.Posters);
     await UpdateImageIfNeeded(tvShowImages.Banner, images.Banners);
     await UpdateSeasonImages(tvShowImages.Seasons, images.Seasons);
 }
Esempio n. 2
0
        public async Task Update(string path, AvailableTvShowImages images)
        {
            TvShowImages tvShowImages = await _tvShowFileService.GetShowImages(path);

            await UpdateImageIfNeeded(tvShowImages.Fanart, images.Fanarts);
            await UpdateImageIfNeeded(tvShowImages.Poster, images.Posters);
            await UpdateImageIfNeeded(tvShowImages.Banner, images.Banners);
            await UpdateSeasonImages(tvShowImages.Seasons, images.Seasons);
        }
        public async Task <AvailableSeasonImages> FindSeasonImages(string seasonPath)
        {
            string seriePath = _fileSystemService.GetParentFolder(seasonPath, 1);
            string serieId   = await GetSeriesId(seriePath);

            AvailableTvShowImages images = await FindImages(serieId);

            int seasonNumber = TvShowHelper.FindSeasonNumberFromFolder(seasonPath);

            AvailableSeasonImages result;

            return(images.Seasons.TryGetValue(seasonNumber, out result) ? result : new AvailableSeasonImages());
        }
Esempio n. 4
0
        public async Task FindImages_Always_ReturnsSeries()
        {
            // Arrange
            const string serieId = "78901";

            AvailableTvShowImages expectedImages = new AvailableTvShowImages
            {
                Banners = new List <Image> {
                    new Image {
                        Url = "http://thetvtdb.com/banner.jpg"
                    }
                },
                Fanarts = new List <Image> {
                    new Image {
                        Url = "http://thetvtdb.com/fanart.jpg"
                    }
                },
                Posters = new List <Image> {
                    new Image {
                        Url = "http://thetvtdb.com/poster.jpg"
                    }
                },
                Seasons = new Dictionary <int, AvailableSeasonImages>
                {
                    { 0, new AvailableSeasonImages
                      {
                          Banners = new List <Image> {
                              new Image {
                                  Url = "http://thetvdb.com/specials-banner.jpg"
                              }
                          },
                          Posters = new List <Image> {
                              new Image {
                                  Url = "http://thetvdb.com/specials-poster.jpg"
                              }
                          },
                      } }
                }
            };

            _metadataUpdater.FindImages(serieId)
            .Returns(expectedImages.ToTask());

            // Act
            AvailableTvShowImages images = await _service.FindImages(serieId);

            // Assert
            Assert.Equal(expectedImages, images);
        }
        public async Task Update_WhenImagesAlreadyExist_DoesntUpdateThem()
        {
            // Arrange
            AvailableTvShowImages availableImages = CreateAvailableImages();

            _fileSystemService.FileExists(Arg.Any <string>())
            .Returns(Task.FromResult(true));

            // Act
            await _service.Update(_path, availableImages);

            // Assert
            _fileSystemService.DidNotReceive()
            .DownloadImage(Arg.Any <string>(), Arg.Any <string>()).Async();
            _fileSystemService.DidNotReceive()
            .DownloadImage(Arg.Any <string>(), Arg.Any <string>()).Async();
        }
        private AvailableTvShowImages CreateAvailableTvShowImages()
        {
            AvailableTvShowImages images = new AvailableTvShowImages
            {
                Fanarts = OrderImages(_fanarts),
                Posters = OrderImages(_posters),
                Banners = OrderImages(_banners),
            };

            foreach (var season in _seasons.OrderBy(s => s.Key))
            {
                images.Seasons[season.Key] = new AvailableSeasonImages
                {
                    Banners = OrderImages(season.Value.Banners).ToList(),
                    Posters = OrderImages(season.Value.Posters).ToList()
                };
            }
            return(images);
        }
        public async Task Update_WhenImagesDontExist_UpdatesThem()
        {
            // Arrange
            AvailableTvShowImages availableImages = CreateAvailableImages();

            // Act
            await _service.Update(_path, availableImages);

            // Assert
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\fanart.jpg", "http://thetvdb.com/fanart1.jpg").Async();
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\poster.jpg", "http://thetvdb.com/poster1.jpg").Async();
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\banner.jpg", "http://thetvdb.com/banner1.jpg").Async();
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\season-specials-poster.jpg", "http://thetvdb.com/specials-poster.jpg").Async();
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\season-specials-banner.jpg", "http://thetvdb.com/specials-banner.jpg").Async();
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\season01-poster.jpg", "http://thetvdb.com/season01-poster.jpg").Async();
            _fileSystemService.Received()
            .DownloadImage(@"C:\Folder\TV Shows\Game of Thrones\season01-banner.jpg", "http://thetvdb.com/season01-banner.jpg").Async();
        }
        public async Task FindImages_Always_ReturnsSeries()
        {
            // Arrange
            const string serieId = "78901";

            AvailableTvShowImages expectedImages = new AvailableTvShowImages
            {
                Banners = new List<Image> { new Image { Url = "http://thetvtdb.com/banner.jpg" } },
                Fanarts = new List<Image> { new Image { Url = "http://thetvtdb.com/fanart.jpg" } },
                Posters = new List<Image> { new Image { Url = "http://thetvtdb.com/poster.jpg" } },
                Seasons = new Dictionary<int, AvailableSeasonImages>
                {
                    { 0, new AvailableSeasonImages
                        {
                            Banners = new List<Image> { new Image { Url = "http://thetvdb.com/specials-banner.jpg" } },
                            Posters = new List<Image> { new Image { Url = "http://thetvdb.com/specials-poster.jpg" } },
                        }
                    }
                }
            };
            _metadataUpdater.FindImages(serieId)
                .Returns(expectedImages.ToTask());

            // Act
            AvailableTvShowImages images = await _service.FindImages(serieId);

            // Assert
            Assert.Equal(expectedImages, images);
        }
 private AvailableTvShowImages CreateAvailableTvShowImages()
 {
     AvailableTvShowImages images = new AvailableTvShowImages
     {
         Fanarts = OrderImages(_fanarts),
         Posters = OrderImages(_posters),
         Banners = OrderImages(_banners),
     };
     foreach (var season in _seasons.OrderBy(s => s.Key))
     {
         images.Seasons[season.Key] = new AvailableSeasonImages
         {
             Banners = OrderImages(season.Value.Banners).ToList(),
             Posters = OrderImages(season.Value.Posters).ToList()
         };
     }
     return images;
 }
        private async Task UpdateImages(string path, string serieId)
        {
            AvailableTvShowImages images = await _metadataUpdater.FindImages(serieId);

            await _imagesService.Update(path, images);
        }