/// <summary> /// Wandelt das den genannten DateTime-Objekt um /// </summary> /// <param name="value">Wert</param> /// <param name="targetType">Der sendente Type</param> /// <param name="parameter">[Es gibt keine Parameter]</param> /// <param name="culture"></param> /// <returns>Das formatierte Datum</returns> public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { int?Result = value as int?; if (value != null) { try { if (!Caching.ImagesTvShowSearch.ContainsKey((int)Result)) { ImagesWithId Bla = ApiHelper.Global.Client.GetTvShowImages((int)Result); if (Bla.Posters.Count > 0) { Uri ImgUri = ApiHelper.Global.Client.GetImageUrl("w92", Bla.Posters[0].FilePath); BitmapImage Temp = new BitmapImage(ImgUri); Caching.ImagesTvShowSearch.Add((int)Result, Temp); return(Temp); } } else { return(Caching.ImagesTvShowSearch[(int)Result]); } } catch (Exception e) { Debug.WriteLine(e.Message); } } return(new BitmapImage()); }
public void TestMoviesGetMovieImages() { ImagesWithId resp = _config.Client.GetMovieImages(AGoodDayToDieHard); Assert.IsNotNull(resp); ImageData backdrop = resp.Backdrops.SingleOrDefault(s => s.FilePath == "/17zArExB7ztm6fjUXZwQWgGMC9f.jpg"); Assert.IsNotNull(backdrop); Assert.IsTrue(Math.Abs(1.77777777777778 - backdrop.AspectRatio) < double.Epsilon); Assert.AreEqual("/17zArExB7ztm6fjUXZwQWgGMC9f.jpg", backdrop.FilePath); Assert.AreEqual(1080, backdrop.Height); Assert.AreEqual("xx", backdrop.Iso_639_1); Assert.IsTrue(backdrop.VoteAverage > 0); Assert.IsTrue(backdrop.VoteCount > 0); Assert.AreEqual(1920, backdrop.Width); ImageData poster = resp.Posters.SingleOrDefault(s => s.FilePath == "/c2SQMd00CCGTiDxGXVqA2J9lmzF.jpg"); Assert.IsNotNull(poster); Assert.IsTrue(Math.Abs(0.666666666666667 - poster.AspectRatio) < double.Epsilon); Assert.AreEqual("/c2SQMd00CCGTiDxGXVqA2J9lmzF.jpg", poster.FilePath); Assert.AreEqual(1500, poster.Height); Assert.AreEqual("en", poster.Iso_639_1); Assert.IsTrue(poster.VoteAverage > 0); Assert.IsTrue(poster.VoteCount > 0); Assert.AreEqual(1000, poster.Width); }
public static List <MovieDB_Movie_Result> Search(string criteria) { List <MovieDB_Movie_Result> results = new List <MovieDB_Movie_Result>(); try { TMDbClient client = new TMDbClient(apiKey); SearchContainer <SearchMovie> resultsTemp = client.SearchMovie(criteria); Console.WriteLine("Got {0} of {1} results", resultsTemp.Results.Count, resultsTemp.TotalResults); foreach (SearchMovie result in resultsTemp.Results) { MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result(); Movie movie = client.GetMovie(result.Id); ImagesWithId imgs = client.GetMovieImages(result.Id); searchResult.Populate(movie, imgs); results.Add(searchResult); SaveMovieToDatabase(searchResult, false, false); } } catch (Exception ex) { logger.Error("Error in MovieDB Search: " + ex.Message); } return(results); }
public void TestMoviesGetMovieImages() { //GetMovieImages(int id, string language) ImagesWithId resp = _config.Client.GetMovieImages(AGoodDayToDieHard); Assert.IsNotNull(resp); }
public static List <MovieDB_Movie_Result> SearchWithTVShowID(int id, bool isTrakt) { List <MovieDB_Movie_Result> results = new List <MovieDB_Movie_Result>(); try { TMDbClient client = new TMDbClient(apiKey); TvShow result = client.GetTvShow(id, TvShowMethods.Images, null); if (result != null) { logger.Info("Got TMDB results for id: {0} | show name: {1}", id, result.Name); MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result(); Movie movie = client.GetMovie(result.Id); ImagesWithId imgs = client.GetMovieImages(result.Id); searchResult.Populate(movie, imgs); results.Add(searchResult); SaveMovieToDatabase(searchResult, true, isTrakt); } } catch (Exception ex) { logger.Error("Error in MovieDB Search: " + ex.Message); } return(results); }
public void TestTvShowGetImagesWithImageLanguage() { ImagesWithId resp = Config.Client.GetTvShowImagesAsync(IdHelper.BreakingBad, language: "en-US", includeImageLanguage: "en").Result; Assert.True(resp.Backdrops.Count > 0); Assert.True(resp.Posters.Count > 0); }
public void TestMoviesGetMovieImages() { ImagesWithId resp = Config.Client.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard).Result; Assert.NotNull(resp); ImageData backdrop = resp.Backdrops.SingleOrDefault(s => s.FilePath == "/17zArExB7ztm6fjUXZwQWgGMC9f.jpg"); Assert.NotNull(backdrop); Assert.True(Math.Abs(1.77777777777778 - backdrop.AspectRatio) < double.Epsilon); Assert.True(TestImagesHelpers.TestImagePath(backdrop.FilePath), "backdrop.FilePath was not a valid image path, was: " + backdrop.FilePath); Assert.Equal(1080, backdrop.Height); Assert.Equal("xx", backdrop.Iso_639_1); Assert.True(backdrop.VoteAverage > 0); Assert.True(backdrop.VoteCount > 0); Assert.Equal(1920, backdrop.Width); ImageData poster = resp.Posters.SingleOrDefault(s => s.FilePath == "/c2SQMd00CCGTiDxGXVqA2J9lmzF.jpg"); Assert.NotNull(poster); Assert.True(Math.Abs(0.666666666666667 - poster.AspectRatio) < double.Epsilon); Assert.True(TestImagesHelpers.TestImagePath(poster.FilePath), "poster.FilePath was not a valid image path, was: " + poster.FilePath); Assert.Equal(1500, poster.Height); Assert.Equal("en", poster.Iso_639_1); Assert.True(poster.VoteAverage > 0); Assert.True(poster.VoteCount > 0); Assert.Equal(1000, poster.Width); }
public void TestMoviesGetMovieImagesWithImageLanguage() { ImagesWithId resp = Config.Client.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard, language: "en-US", includeImageLanguage: "en").Result; Assert.True(resp.Backdrops.Count > 0); Assert.True(resp.Posters.Count > 0); }
public void TestTvShowSeparateExtrasImages() { ImagesWithId images = Config.Client.GetTvShowImagesAsync(IdHelper.BreakingBad).Result; Assert.NotNull(images); Assert.NotNull(images.Backdrops); Assert.NotNull(images.Posters); }
public void TestTvShowSeparateExtrasImages() { ImagesWithId images = _config.Client.GetTvShowImages(BreakingBad).Result; Assert.IsNotNull(images); Assert.IsNotNull(images.Backdrops); Assert.IsNotNull(images.Posters); }
public void TestCollectionsImages() { // Get config _config.Client.GetConfig(); // Test image url generator ImagesWithId images = _config.Client.GetCollectionImages(JamesBondCollection); Assert.AreEqual(JamesBondCollection, images.Id); TestImagesHelpers.TestImages(_config, images); }
public void TestMoviesImages() { // Get config _config.Client.GetConfig(); // Test image url generator ImagesWithId images = _config.Client.GetMovieImages(AGoodDayToDieHard); Assert.AreEqual(AGoodDayToDieHard, images.Id); TestImagesHelpers.TestImages(_config, images); }
public void TestMoviesImages() { // Get config Config.Client.GetConfigAsync().Sync(); // Test image url generator ImagesWithId images = Config.Client.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard).Result; Assert.Equal(IdHelper.AGoodDayToDieHard, images.Id); TestImagesHelpers.TestImages(Config, images); }
public void TestCollectionsImages() { // Get config Config.Client.GetConfig(); // Test image url generator ImagesWithId images = Config.Client.GetCollectionImagesAsync(IdHelper.JamesBondCollection).Result; Assert.Equal(IdHelper.JamesBondCollection, images.Id); TestImagesHelpers.TestImages(Config, images); }
public async Task TestTvShowGetImagesWithImageLanguageAsync() { ImagesWithId images = await TMDbClient.GetTvShowImagesAsync(IdHelper.BreakingBad, "en-US", "en"); TestImagesHelpers.TestImagePaths(images); ImageData backdrop = images.Backdrops.Single(s => s.FilePath == "/otCnAN1edreRudT5E2OHk8beiDu.jpg"); ImageData poster = images.Posters.Single(s => s.FilePath == "/ggFHVNu6YYI5L9pCfOacjizRGt.jpg"); await Verify(new { backdrop, poster }); }
public async void TestMoviesGetMovieImagesWithImageLanguage() { ImagesWithId images = await TMDbClient.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard, "en-US", "en"); TestImagesHelpers.TestImagePaths(images); ImageData backdrop = images.Backdrops.Single(s => s.FilePath == "/js3J4SBiRfLvmRzaHoTA2tpKROw.jpg"); ImageData poster = images.Posters.Single(s => s.FilePath == "/9Zq88w35f1PpM22TIbf2amtjHD6.jpg"); await Verify(new { backdrop, poster }); }
public async void TestMoviesGetMovieImages() { ImagesWithId resp = await TMDbClient.GetMovieImagesAsync(IdHelper.AGoodDayToDieHard); TestImagesHelpers.TestImagePaths(resp); ImageData backdrop = resp.Backdrops.Single(s => s.FilePath == "/js3J4SBiRfLvmRzaHoTA2tpKROw.jpg"); ImageData poster = resp.Posters.Single(s => s.FilePath == "/c4G6lW5hAWmwveThfLSqs52yHB1.jpg"); await Verify(new { backdrop, poster }); }
public async Task TestTvShowSeparateExtrasImagesAsync() { ImagesWithId images = await TMDbClient.GetTvShowImagesAsync(IdHelper.BreakingBad); TestImagesHelpers.TestImagePaths(images); ImageData backdrop = images.Backdrops.Single(s => s.FilePath == "/tsRy63Mu5cu8etL1X7ZLyf7UP1M.jpg"); ImageData poster = images.Posters.Single(s => s.FilePath == "/ggFHVNu6YYI5L9pCfOacjizRGt.jpg"); await Verify(new { backdrop, poster }); }
public void TestMoviesGetMovieImagesWithAdditionalLanguages() { // if a default language has been set - generic (non tagged) images won't be returned // therefore the include_image_language exists // see API: Image Languages var orgLang = _config.Client.DefaultLanguage; _config.Client.DefaultLanguage = "de"; ImagesWithId respDefault = _config.Client.GetMovieImages(MadMaxFuryRoad).Result; ImagesWithId respInclude = _config.Client.GetMovieImages(MadMaxFuryRoad, true).Result; Assert.IsNotNull(respDefault); Assert.IsNotNull(respInclude); // expect respInclude to contain more backdrops than respDefault Assert.IsTrue(respInclude.Backdrops.Count() > respDefault.Backdrops.Count()); }
public PeliculaViewModel() { this.repo = new RepositoryMyMovieList(); session = App.Locator.SessionService; if (Pelicula == null) { Pelicula = new Movie(); } if (Actores == null) { Actores = new Credits(); } if (Imagenes == null) { Imagenes = new ImagesWithId(); } }
public void TestTvShowSeparateExtrasImagesWithNoLanguage() { ImagesWithId imagesDefault = _config.Client.GetTvShowImages(GameOfThrones, "en").Result; Assert.IsNotNull(imagesDefault); Assert.IsNotNull(imagesDefault.Backdrops); Assert.IsNotNull(imagesDefault.Posters); // again with default var imagesGeneric = _config.Client.GetTvShowImages(GameOfThrones, "en", true).Result; Assert.IsNotNull(imagesGeneric); Assert.IsNotNull(imagesGeneric.Backdrops); Assert.IsNotNull(imagesGeneric.Posters); // expect to be more with non-lanuage enabled Assert.IsTrue(imagesGeneric.Backdrops.Count() > imagesDefault.Backdrops.Count()); }
public bool Populate(Movie movie, ImagesWithId imgs) { try { Images = new List <MovieDB_Image_Result>(); MovieID = movie.Id; MovieName = movie.Title; OriginalName = movie.Title; Overview = movie.Overview; Rating = movie.VoteAverage; if (imgs != null && imgs.Backdrops != null) { foreach (ImageData img in imgs.Backdrops) { MovieDB_Image_Result imageResult = new MovieDB_Image_Result(); if (imageResult.Populate(img, "backdrop")) { Images.Add(imageResult); } } } if (imgs != null && imgs.Posters != null) { foreach (ImageData img in imgs.Posters) { MovieDB_Image_Result imageResult = new MovieDB_Image_Result(); if (imageResult.Populate(img, "poster")) { Images.Add(imageResult); } } } } catch (Exception ex) { logger.Error(ex, ex.ToString()); return(false); } return(true); }
public static void UpdateMovieInfo(ISession session, int movieID, bool saveImages) { try { TMDbClient client = new TMDbClient(apiKey); Movie movie = client.GetMovie(movieID); ImagesWithId imgs = client.GetMovieImages(movieID); MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result(); searchResult.Populate(movie, imgs); // save to the DB SaveMovieToDatabase(session, searchResult, saveImages, false); } catch (Exception ex) { logger.Error(ex, "Error in ParseBanners: " + ex.ToString()); } }
public async Task <ImagesWithId> ImagenesPelicula(int idpelicula) { String peticion = "api/Peliculas/ImagenesPelicula/" + idpelicula; Uri uri = new Uri(this.urlapi + peticion); HttpClient client = this.GetHttpClient(); HttpResponseMessage response = await client.GetAsync(uri); if (response.IsSuccessStatusCode) { String json = await response.Content.ReadAsStringAsync(); ImagesWithId imagenes = JsonConvert.DeserializeObject <ImagesWithId>(json); return(imagenes); } else { return(null); } }
private void GetMovieDBInfo(string searchMedia, string selectedLang, string fallbackLang, string selectedCertCountry, string fallbackCertCountry) { InitLists(); SearchContainer <SearchMovie> movieList = _tmDbClient.SearchMovie(searchMedia, selectedLang); if (movieList == null || movieList.TotalResults <= 0) { movieList = _tmDbClient.SearchMovie(searchMedia, fallbackLang); } if (movieList == null || movieList.TotalResults <= 0) { return; } SearchMovie resultMovie = new SearchMovie(); if (movieList.TotalResults > 1) { DBMultipleSelection selectWindow = new DBMultipleSelection { Owner = this, MovieDBSearchResults = movieList }; if (selectWindow.ShowDialog() == true) { resultMovie = selectWindow.MovieDBSelectionResult; } } else { resultMovie = movieList.Results.First(); } if (resultMovie.Id == 0) { return; } Movie searchResult = _tmDbClient.GetMovie(resultMovie.Id, selectedLang) ?? _tmDbClient.GetMovie(resultMovie.Id, fallbackLang); if (searchResult == null) { return; } ImagesWithId imageList = _tmDbClient.GetMovieImages(resultMovie.Id); Casts movieCasts = _tmDbClient.GetMovieCasts(resultMovie.Id); KeywordsContainer movieKeywords = _tmDbClient.GetMovieKeywords(resultMovie.Id); Trailers movieTrailers = _tmDbClient.GetMovieTrailers(resultMovie.Id); Releases movieReleases = _tmDbClient.GetMovieReleases(resultMovie.Id); MovieTitle.Text = searchResult.Title; MovieOriginalTitle.Text = searchResult.OriginalTitle; MovieGenre.Text = searchResult.Genres != null ? string.Join(" / ", searchResult.Genres.ConvertAll(input => input.Name)) : string.Empty; MovieRuntime.Text = searchResult.Runtime.ToString("g"); if (AppSettings.MovieDBRatingSource == 0) { MovieRating.Text = searchResult.VoteAverage.ToString("g"); MovieVotes.Text = searchResult.VoteCount.ToString("g"); } else { ImdbClient imdb = new ImdbClient(); ImdbMovieData movieData = imdb.GetMovieById(searchResult.ImdbId); MovieRating.Text = movieData.Rating.ToString("g"); MovieVotes.Text = movieData.RatingCount.ToString("g"); } MovieYear.Text = searchResult.ReleaseDate.Year.ToString("g"); MovieTagline.Text = searchResult.Tagline; MoviePlot.Text = searchResult.Overview; if (movieKeywords != null && movieKeywords.Keywords != null) { MovieKeywords.Text = string.Join(", ", movieKeywords.Keywords.ConvertAll(input => input.Name)); } else { MovieKeywords.Text = string.Empty; } MovieImdbId.Text = searchResult.ImdbId; MovieCountry.Text = searchResult.ProductionCountries != null ? string.Join(" / ", searchResult.ProductionCountries.ConvertAll(input => input.Name)) : string.Empty; if (movieCasts != null && movieCasts.Crew != null) { MovieDirector.Text = string.Join(" / ", movieCasts.Crew.Where(crew => crew.Job == "Director") .ToList() .ConvertAll(input => input.Name)); MovieWriters.Text = string.Join(" / ", movieCasts.Crew.Where( crew => crew.Job == "Writer" || crew.Job == "Screenplay") .ToList() .ConvertAll(input => input.Name)); } else { MovieDirector.Text = string.Empty; MovieWriters.Text = string.Empty; } MovieStudio.Text = searchResult.ProductionCompanies != null ? string.Join(" / ", searchResult.ProductionCompanies.ConvertAll(input => input.Name)) : string.Empty; MovieSetName.Text = searchResult.BelongsToCollection != null ? string.Join(" / ", searchResult.BelongsToCollection.ConvertAll(input => input.Name)) : string.Empty; if (movieTrailers != null && movieTrailers.Youtube != null && movieTrailers.Youtube.Count > 0) { MovieTrailer.Text = "plugin://plugin.video.youtube/?action=play_video&videoid=" + movieTrailers.Youtube.First().Source; } else { MovieTrailer.Text = string.Empty; } Country selCountry = movieReleases.Countries.SingleOrDefault(country => country.Iso_3166_1.ToLowerInvariant() == selectedCertCountry); string certPrefix = AppSettings.MovieDBPreferredCertPrefix; if (selCountry == null) { selCountry = movieReleases.Countries.SingleOrDefault( country => country.Iso_3166_1.ToLowerInvariant() == fallbackCertCountry); certPrefix = AppSettings.MovieDBFallbackCertPrefix; } if (selCountry == null) { selCountry = movieReleases.Countries.First(); certPrefix = string.Empty; } MovieMPAARating.Text = certPrefix + selCountry.Certification; // loading image sizes string posterOriginal = _tmDbClient.Config.Images.PosterSizes.Last(); string posterPreview = _tmDbClient.Config.Images.PosterSizes.Count >= 2 ? _tmDbClient.Config.Images.PosterSizes[_tmDbClient.Config.Images.PosterSizes.Count - 2] : _tmDbClient.Config.Images.PosterSizes.Last(); string backdropOriginal = _tmDbClient.Config.Images.BackdropSizes.Last(); string backdropPreview = _tmDbClient.Config.Images.BackdropSizes.Count >= 3 ? _tmDbClient.Config.Images.BackdropSizes[ _tmDbClient.Config.Images.BackdropSizes.Count - 3] : _tmDbClient.Config.Images.BackdropSizes.Last(); // remove duplicate entries imageList.Backdrops.RemoveAt(imageList.Backdrops.FindIndex(data => data.FilePath == searchResult.BackdropPath)); imageList.Posters.RemoveAt(imageList.Posters.FindIndex(data => data.FilePath == searchResult.PosterPath)); // create image lists _postersList.Add(new MovieDBPosterImage { Title = "Default", UrlOriginal = _tmDbClient.GetImageUrl(posterOriginal, searchResult.PosterPath).AbsoluteUri, UrlPreview = _tmDbClient.GetImageUrl(posterPreview, searchResult.PosterPath).AbsoluteUri }); _backdropsList.Add(new MovieDBImageInfo { Title = "Default", UrlOriginal = _tmDbClient.GetImageUrl(backdropOriginal, searchResult.BackdropPath).AbsoluteUri, UrlPreview = _tmDbClient.GetImageUrl(backdropPreview, searchResult.BackdropPath).AbsoluteUri }); int cnt = 1; foreach (ImageData poster in imageList.Posters) { _postersList.Add(new MovieDBPosterImage { Title = "Online image " + cnt, UrlOriginal = _tmDbClient.GetImageUrl(posterOriginal, poster.FilePath).AbsoluteUri, UrlPreview = _tmDbClient.GetImageUrl(posterPreview, poster.FilePath).AbsoluteUri }); cnt++; } MoviePosterList.ItemsSource = _postersList; MoviePosterList.SelectedIndex = 0; cnt = 1; foreach (ImageData backdrop in imageList.Backdrops) { _backdropsList.Add(new MovieDBImageInfo { Title = "Online image " + cnt, UrlOriginal = _tmDbClient.GetImageUrl(backdropOriginal, backdrop.FilePath).AbsoluteUri, UrlPreview = _tmDbClient.GetImageUrl(backdropPreview, backdrop.FilePath).AbsoluteUri }); cnt++; } MovieBackdropList.ItemsSource = _backdropsList; MovieBackdropList.SelectedIndex = 0; foreach (Cast cast in movieCasts.Cast) { _castList.Casts.Add(new MovieDBCast { Name = cast.Name, Role = cast.Character, Thumbnail = _tmDbClient.GetImageUrl("original", cast.ProfilePath).AbsoluteUri }); } MovieCastListView.ItemsSource = _castList.Casts; ResultTabControl.SelectedIndex = 1; }
public async Task TestCollectionsImagesAsync() { ImagesWithId images = await TMDbClient.GetCollectionImagesAsync(IdHelper.BackToTheFutureCollection); TestImagesHelpers.TestImagePaths(images); }