public static async Task <ImdbInfo> GetImdbInfo(string imdbId) { string response = await ImdbClient.GetStringAsync(String.Format(UrlFormat, imdbId)); int start = response.IndexOf('('); int end = response.LastIndexOf(')'); string json = response.Substring(start + 1, end - start - 1); return(JsonConvert.DeserializeObject <ImdbInfo>(json)); }
private MovieManager() { tClient = new TClient(); imdbClient = new ImdbClient(); oClient = new OClient(); tmdbApiKey = tClient.Key; youTubeClient = new YouTubeService(new BaseClientService.Initializer() { ApiKey = "AIzaSyDFaNumZ4ZE3hDY-yDQi9VY_WDEYrS3xvo", ApplicationName = "Google Play Android Developer" }); }
static Program() { var client = new ImdbClient(); var dateTimeProvider = new DateTimeProvider(); var htmlParserStrategy = new HtmlParserStrategyFactory(); var cacheTvShowIds = new PersistantCache <string>("Cache/TvShowIds"); var cacheIgnoredTvShows = new PersistantCache <string>("Cache/IgnoredTvShows"); var cacheLatestAiredSeasons = new PersistantCache <int>("Cache/LatestAiredSeasons"); _seasonChecker = new SeasonChecker(client, htmlParserStrategy, cacheTvShowIds, cacheIgnoredTvShows, cacheLatestAiredSeasons, dateTimeProvider); _notificationService = new FileNotificationService(); _tvShowRepository = new FileTvShowRepository(new FileSystem()); }
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; }