Ejemplo n.º 1
0
        private void MediaInfoLoadButton_Click(object sender, RoutedEventArgs e)
        {
            string searchMedia = MediaTitleInfo.Text;
            if (string.IsNullOrEmpty(searchMedia)) return;

            string selectedLang = (string) SearchLanguage.SelectedValue;
            if (string.IsNullOrEmpty(selectedLang))
                selectedLang = "en";

            string selectedCertCountry = (string) RatingCountry.SelectedValue;
            if (string.IsNullOrEmpty(selectedCertCountry))
                selectedCertCountry = "us";

            AppSettings.MovieDBLastLanguage = selectedLang;
            AppSettings.MovieDBLastRatingCountry = selectedCertCountry;

            TMDbClient client = new TMDbClient(MovieDBApiKey);

            FileInfo configXml = new FileInfo("TMDbconfig.xml");
            if (configXml.Exists && configXml.LastWriteTimeUtc >= DateTime.UtcNow.AddHours(-1))
            {
                Log.Info("TMDbClient: Using stored config");
                string xml = File.ReadAllText(configXml.FullName, Encoding.Unicode);

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(xml);

                client.SetConfig(TMDbSerializer.Deserialize<TMDbConfig>(xmlDoc));
            }
            else
            {
                Log.Info("TMDbClient: Getting new config");
                client.GetConfig();

                Log.Info("TMDbClient: Storing config");
                XmlDocument xmlDoc = TMDbSerializer.Serialize(client.Config);
                File.WriteAllText(configXml.FullName, xmlDoc.OuterXml, Encoding.Unicode);
            }

            SearchContainer<SearchMovie> movieList = client.SearchMovie(searchMedia, selectedLang);
            if (movieList == null || movieList.TotalResults <= 0) return;

            SearchMovie resultMovie = new SearchMovie();
            if (movieList.TotalResults > 1)
            {
                MovieDBMultipleSelection selectWindow = new MovieDBMultipleSelection
                    {
                        Owner = this,
                        SearchResults = movieList
                    };
                if (selectWindow.ShowDialog() == true)
                    resultMovie = selectWindow.SelectionResult;
            }
            else
                resultMovie = movieList.Results.First();

            if (resultMovie.Id == 0) return;

            Movie searchResult = client.GetMovie(resultMovie.Id, selectedLang);
            ImagesWithId imageList = client.GetMovieImages(resultMovie.Id);
            Casts movieCasts = client.GetMovieCasts(resultMovie.Id);
            KeywordsContainer movieKeywords = client.GetMovieKeywords(resultMovie.Id);
            Trailers movieTrailers = client.GetMovieTrailers(resultMovie.Id);
            Releases movieReleases = client.GetMovieReleases(resultMovie.Id);

            if (searchResult == null) return;

            MovieTitle.Text = searchResult.Title;
            MovieOriginalTitle.Text = searchResult.OriginalTitle;

            Genre.Text = searchResult.Genres != null
                             ? string.Join(" / ", searchResult.Genres.ConvertAll(input => input.Name))
                             : string.Empty;

            Rating.Text = searchResult.VoteAverage.ToString("g");
            Runtime.Text = searchResult.Runtime.ToString("g");
            Votes.Text = searchResult.VoteCount.ToString("g");
            Year.Text = searchResult.ReleaseDate.Year.ToString("g");
            Tagline.Text = searchResult.Tagline;
            Plot.Text = searchResult.Overview;

            if (movieKeywords != null && movieKeywords.Keywords != null)
                Keywords.Text = string.Join(", ", movieKeywords.Keywords.ConvertAll(input => input.Name));
            else
                Keywords.Text = string.Empty;

            ImdbId.Text = searchResult.ImdbId;

            Country.Text = searchResult.ProductionCountries != null
                               ? string.Join(" / ", searchResult.ProductionCountries.ConvertAll(input => input.Name))
                               : string.Empty;

            if (movieCasts != null && movieCasts.Crew != null)
            {
                Director.Text = string.Join(" / ",
                                            movieCasts.Crew.Where(crew => crew.Job == "Director")
                                                      .ToList()
                                                      .ConvertAll(input => input.Name));
                Writers.Text = string.Join(" / ",
                                           movieCasts.Crew.Where(crew => crew.Job == "Writer" || crew.Job == "Screenplay")
                                                     .ToList()
                                                     .ConvertAll(input => input.Name));
            }
            else
            {
                Director.Text = string.Empty;
                Writers.Text = string.Empty;
            }

            Studio.Text = searchResult.ProductionCompanies != null
                              ? string.Join(" / ", searchResult.ProductionCompanies.ConvertAll(input => input.Name))
                              : string.Empty;

            SetName.Text = searchResult.BelongsToCollection != null
                               ? string.Join(" / ", searchResult.BelongsToCollection.ConvertAll(input => input.Name))
                               : string.Empty;

            if (movieTrailers != null && movieTrailers.Youtube != null && movieTrailers.Youtube.Count > 0)
                Trailer.Text = "plugin://plugin.video.youtube/?action=play_video&amp;videoid=" +
                               movieTrailers.Youtube.First().Source;
            else
                Trailer.Text = string.Empty;

            Country selCountry =
                movieReleases.Countries.Single(country => country.Iso_3166_1.ToLowerInvariant() == selectedCertCountry) ??
                movieReleases.Countries.Single(country => country.Iso_3166_1.ToLowerInvariant() == "us");

            MovieDBCertCountry certCountry =
                MovieDBCertCountries.CountryList.Single(country => country.CountryName == selectedCertCountry);

            MPAARating.Text = certCountry.Prefix + selCountry.Certification;

            // loading image sizes
            string posterOriginal = client.Config.Images.PosterSizes.Last();

            string posterPreview = client.Config.Images.PosterSizes.Count >= 2
                                       ? client.Config.Images.PosterSizes[client.Config.Images.PosterSizes.Count - 2]
                                       : client.Config.Images.PosterSizes.Last();

            string backdropOriginal = client.Config.Images.BackdropSizes.Last();

            string backdropPreview = client.Config.Images.BackdropSizes.Count >= 3
                                         ? client.Config.Images.BackdropSizes[
                                             client.Config.Images.BackdropSizes.Count - 3]
                                         : client.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 = client.GetImageUrl(posterOriginal, searchResult.PosterPath).AbsoluteUri,
                    UrlPreview = client.GetImageUrl(posterPreview, searchResult.PosterPath).AbsoluteUri
                });
            _backdropsList.Add(new MovieDBImageInfo
                {
                    Title = "Default",
                    UrlOriginal = client.GetImageUrl(backdropOriginal, searchResult.BackdropPath).AbsoluteUri,
                    UrlPreview = client.GetImageUrl(backdropPreview, searchResult.BackdropPath).AbsoluteUri
                });

            int cnt = 1;
            foreach (ImageData poster in imageList.Posters)
            {
                _postersList.Add(new MovieDBPosterImage
                    {
                        Title = "Online image " + cnt,
                        UrlOriginal = client.GetImageUrl(posterOriginal, poster.FilePath).AbsoluteUri,
                        UrlPreview = client.GetImageUrl(posterPreview, poster.FilePath).AbsoluteUri
                    });
                cnt++;
            }
            PosterList.ItemsSource = _postersList;
            PosterList.SelectedIndex = 0;

            cnt = 1;
            foreach (ImageData backdrop in imageList.Backdrops)
            {
                _backdropsList.Add(new MovieDBImageInfo
                {
                    Title = "Online image " + cnt,
                    UrlOriginal = client.GetImageUrl(backdropOriginal, backdrop.FilePath).AbsoluteUri,
                    UrlPreview = client.GetImageUrl(backdropPreview, backdrop.FilePath).AbsoluteUri
                });
                cnt++;
            }
            BackdropList.ItemsSource = _backdropsList;
            BackdropList.SelectedIndex = 0;

            foreach (Cast cast in movieCasts.Cast)
            {
                _castList.Casts.Add(new MovieDBCast
                    {
                        Name = cast.Name,
                        Role = cast.Character,
                        Thumbnail = client.GetImageUrl("original", cast.ProfilePath).AbsoluteUri
                    });
            }
            CastListView.ItemsSource = _castList.Casts;
        }
Ejemplo n.º 2
0
        private static void ProcessImages(TMDbClient client, IEnumerable<ImageData> images, IEnumerable<string> sizes)
        {
            // Displays basic information about each image, as well as all the possible adresses for it.
            // All images should be available in all the sizes provided by the configuration.

            foreach (ImageData imageData in images)
            {
                Console.WriteLine(imageData.FilePath);
                Console.WriteLine("\t " + imageData.Width + "x" + imageData.Height);

                // Calculate the images path
                // There are multiple resizing available for each image, directly from TMDb.
                // There's always the "original" size if you're in doubt which to choose.
                foreach (string size in sizes)
                {
                    Uri imageUri = client.GetImageUrl(size, imageData.FilePath);
                    Console.WriteLine("\t -> " + imageUri);
                }

                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        static public bool DownloadMovieDetails(VideoTags videoTags)
        {
            // The new v3 database is accessed via the TMDbLib API's
            try
            {
                TMDbClient client = new TMDbClient(MCEBUDDY_TMDB_APIKey);
                List<SearchMovie> movieSearch = new List<SearchMovie>();
                Movie movieMatch = null;

                // TODO: Add support for multiple language searches
                if (String.IsNullOrWhiteSpace(videoTags.imdbId)) // If dont' have a specific movieId specified, look up the movie details
                {
                    if (videoTags.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) // Release date narrow down
                    {
                        // The information is stored on the server using the network timezone
                        // So we assume that the show being converted was recorded locally and is converted locally so the timezones match
                        DateTime dt = videoTags.OriginalBroadcastDateTime.ToLocalTime();
                        movieSearch = client.SearchMovie(videoTags.Title.Trim().ToLower(), 0, true, dt.Year).Results;
                    }
                    else // Title Check
                        movieSearch = client.SearchMovie(videoTags.Title.Trim().ToLower(), 0, true, 0).Results;
                }
                else // Specific ID
                {
                    movieMatch = client.GetMovie(videoTags.imdbId); // We have a specific movie to work with
                }

                if (movieMatch == null) // If we haven't forced a movie match
                {
                    foreach (SearchMovie movieResult in movieSearch) // Cycle through all possible combinations
                    {
                        Movie movie = client.GetMovie(movieResult.Id);
                        List<AlternativeTitle> akaValues = null;
                        if (movie.AlternativeTitles != null)
                            akaValues = movie.AlternativeTitles.Titles;
                        bool akaMatch = false;
                        string title = videoTags.Title;
                        if (akaValues != null) // Check if there are any AKA names to match
                            akaMatch = akaValues.Any(s => (String.Compare(s.Title.Trim(), title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) == 0 ? true : false));

                        // Get and match Movie name (check both titles and aka values)
                        if (String.Compare(movie.Title.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters
                            if (String.Compare(movie.OriginalTitle.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters
                                if (!akaMatch) // check for aka value matches
                                    continue; // No match in name

                        // If we got here, then we found a match
                        movieMatch = movie;
                        break; // We are done here
                    }
                }

                if (movieMatch != null) // We have a match
                {
                    if (!String.IsNullOrWhiteSpace(videoTags.imdbId)) // Match names only if the movie imdb id is not forced, else take what is returned by moviedb
                        videoTags.Title = movieMatch.Title; // Take what is forced for the imdb movie id

                    // Get Movie Id
                    videoTags.tmdbId = movieMatch.Id.ToString();

                    videoTags.IsMovie = true; // this is a movie

                    // Get Overview
                    string overview = movieMatch.Overview;
                    if (!String.IsNullOrWhiteSpace(overview) && String.IsNullOrWhiteSpace(videoTags.Description))
                        videoTags.Description = overview;

                    // Get original release date
                    if (movieMatch.ReleaseDate != null)
                    {
                        DateTime releaseDate = (DateTime)movieMatch.ReleaseDate;
                        if (releaseDate > GlobalDefs.NO_BROADCAST_TIME)
                            if ((videoTags.OriginalBroadcastDateTime <= GlobalDefs.NO_BROADCAST_TIME) || (videoTags.OriginalBroadcastDateTime.Date > releaseDate.Date)) // Sometimes the metadata from the video recordings are incorrect and report the recorded date (which is more recent than the release date) then use MovieDB dates, MovieDB Dates are more reliable than video metadata usually
                                videoTags.OriginalBroadcastDateTime = releaseDate; // MovieDB stores time in network (local) timezone
                    }

                    // Get Genres
                    List<string> genres = new List<string>();
                    foreach (Genre genre in movieMatch.Genres)
                    {
                        genres.Add(genre.Name);
                    }
                    if (genres.Count > 0)
                    {
                        if (videoTags.Genres != null)
                        {
                            if (videoTags.Genres.Length == 0)
                                videoTags.Genres = genres.ToArray();
                        }
                        else
                            videoTags.Genres = genres.ToArray();
                    }

                    // Download the banner file
                    client.GetConfig(); // First we need to get the config
                    VideoMetaData.DownloadBannerFile(videoTags, client.GetImageUrl("original", movieMatch.PosterPath).OriginalString); // Get bannerfile

                    return true; // home free, we're good
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Match the series information by Episode name
        /// </summary>
        private static bool MatchByEpisodeName(TMDbClient client, VideoTags videoTags, TvShow tvShow)
        {
            if (String.IsNullOrWhiteSpace(videoTags.SubTitle))
                return false; //Nothing to match here


            // Cycle through all Seasons and Episodes looking for a match
            for (int sNo = 0; sNo <= tvShow.NumberOfSeasons; sNo++)
            {
                TvSeason season = client.GetTvSeason(tvShow.Id, sNo);
                if (season == null || season.Episodes == null)
                    continue;

                for (int eNo = 0; eNo <= season.Episodes.Count; eNo++)
                {
                    TvEpisode episode = client.GetTvEpisode(tvShow.Id, sNo, eNo);
                    if (episode == null)
                        continue;

                    string episodeName = episode.Name;

                    if (!String.IsNullOrWhiteSpace(episodeName))
                    {
                        if (String.Compare(videoTags.SubTitle.Trim(), episodeName.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) == 0) // Compare the episode names (case / special characters / whitespace can change very often)
                        {
                            int episodeNo = episode.EpisodeNumber;
                            int seasonNo = season.SeasonNumber;
                            string episodeOverview = episode.Overview;
                            string overview = season.Overview;
                            string tvdbID = (episode.ExternalIds != null ? (episode.ExternalIds.TvdbId != null ? episode.ExternalIds.TvdbId.ToString() : "") : "");
                            string imdbID = (episode.ExternalIds != null ? episode.ExternalIds.ImdbId : "");
                            string tmdbID = (tvShow.Id != 0 ? tvShow.Id.ToString() : "");
                            string network = (tvShow.Networks != null ? String.Join(";", tvShow.Networks.Select(s => s.Name)) : "");
                            DateTime premiereDate = GlobalDefs.NO_BROADCAST_TIME;
                            if (tvShow.FirstAirDate != null)
                                premiereDate = (DateTime)tvShow.FirstAirDate;
                            List<string> genres = (tvShow.Genres != null ? tvShow.Genres.Select(s => s.Name).ToList() : new List<string>());
                            DateTime firstAired = (episode.AirDate != null ? episode.AirDate : GlobalDefs.NO_BROADCAST_TIME);
                            string mediaCredits = (tvShow.Credits != null ? ((tvShow.Credits.Cast != null) ? String.Join(";", tvShow.Credits.Cast.Select(s => s.Name)) : "") : "");

                            client.GetConfig(); // First we need to get the config
                            VideoMetaData.DownloadBannerFile(videoTags, client.GetImageUrl("original", tvShow.PosterPath).OriginalString); // Get bannerfile

                            if ((episodeNo != 0) && (videoTags.Episode == 0)) videoTags.Episode = episodeNo;
                            if ((seasonNo != 0) && (videoTags.Season == 0)) videoTags.Season = seasonNo;
                            if (!String.IsNullOrWhiteSpace(episodeOverview) && String.IsNullOrWhiteSpace(videoTags.Description)) videoTags.Description = episodeOverview;
                            else if (!String.IsNullOrWhiteSpace(overview) && (String.IsNullOrWhiteSpace(videoTags.Description))) videoTags.Description = overview;
                            if (!String.IsNullOrWhiteSpace(tvdbID) && String.IsNullOrWhiteSpace(videoTags.tvdbId)) videoTags.tvdbId = tvdbID;
                            if (!String.IsNullOrWhiteSpace(imdbID) && String.IsNullOrWhiteSpace(videoTags.imdbId)) videoTags.imdbId = imdbID;
                            if (!String.IsNullOrWhiteSpace(tmdbID) && String.IsNullOrWhiteSpace(videoTags.tmdbId)) videoTags.tmdbId = tmdbID;
                            if (!String.IsNullOrWhiteSpace(network) && String.IsNullOrWhiteSpace(videoTags.Network)) videoTags.Network = network;
                            if (!String.IsNullOrWhiteSpace(mediaCredits) && String.IsNullOrWhiteSpace(videoTags.MediaCredits)) videoTags.MediaCredits = mediaCredits;
                            if (premiereDate > GlobalDefs.NO_BROADCAST_TIME)
                                if ((videoTags.SeriesPremiereDate <= GlobalDefs.NO_BROADCAST_TIME) || (videoTags.SeriesPremiereDate.Date > premiereDate.Date)) // Sometimes the metadata from the video recordings are incorrect and report the recorded date (which is more recent than the release date) then use TVDB dates, TVDB Dates are more reliable than video metadata usually
                                    videoTags.SeriesPremiereDate = premiereDate; // TVDB stores time in network (local) timezone
                            if (genres.Count > 0)
                            {
                                if (videoTags.Genres != null)
                                {
                                    if (videoTags.Genres.Length == 0)
                                        videoTags.Genres = genres.ToArray();
                                }
                                else
                                    videoTags.Genres = genres.ToArray();
                            }

                            if (firstAired > GlobalDefs.NO_BROADCAST_TIME)
                                if ((videoTags.OriginalBroadcastDateTime <= GlobalDefs.NO_BROADCAST_TIME) || (videoTags.OriginalBroadcastDateTime.Date > firstAired.Date)) // Sometimes the metadata from the video recordings are incorrect and report the recorded date (which is more recent than the release date) then use TVDB dates, TVDB Dates are more reliable than video metadata usually
                                    videoTags.OriginalBroadcastDateTime = firstAired; // TVDB stores time in network (local) timezone

                            return true; // Found a match got all the data, we're done here
                        }
                    }
                }
            }

            return false; // nothing matches
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Download the movie background image
        /// </summary>
        /// <param name="imdbCode">The unique identifier of a movie</param>
        /// <param name="cancellationToken">cancellationToken</param>
        public async Task<Tuple<string, IEnumerable<Exception>>> DownloadMovieBackgroundImageAsync(string imdbCode,
            CancellationTokenSource cancellationToken)
        {
            List<Exception> ex = new List<Exception>();
            string backgroundImage = String.Empty;

            TMDbClient tmDbclient = new TMDbClient(Constants.TmDbClientId);
            tmDbclient.GetConfig();

            try
            {
                TMDbLib.Objects.Movies.Movie movie = tmDbclient.GetMovie(imdbCode, MovieMethods.Images);
                if (movie.ImdbId != null)
                {
                    Uri imageUri = tmDbclient.GetImageUrl(Constants.BackgroundImageSizeTmDb,
                        movie.Images.Backdrops.Aggregate((i1, i2) => i1.VoteAverage > i2.VoteAverage ? i1 : i2).FilePath);

                    try
                    {
                        Tuple<string, Exception> res =
                            await
                                DownloadFileAsync(imdbCode, imageUri, Constants.FileType.BackgroundImage,
                                    cancellationToken.Token);

                        if (res != null)
                        {
                            if (res.Item2 == null)
                            {
                                backgroundImage = Constants.BackgroundMovieDirectory + imdbCode +
                                                  Constants.ImageFileExtension;
                            }
                            else
                            {
                                ex.Add(res.Item2);
                            }
                        }
                        else
                        {
                            ex.Add(new Exception());
                        }
                    }
                    catch (WebException webException)
                    {
                        ex.Add(webException);
                    }
                    catch (TaskCanceledException e)
                    {
                        ex.Add(e);
                    }
                }
                else
                {
                    ex.Add(new Exception());
                }
            }
            catch (Exception e)
            {
                ex.Add(e);
            }

            return new Tuple<string, IEnumerable<Exception>>(backgroundImage, ex);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            using (new SecurityDisabler())
            {
                Sitecore.Configuration.Settings.Indexing.Enabled = false;
                IndexCustodian.PauseIndexing();
                TMDbClient client = new TMDbClient("a7e29a282bb192663ce78f3574cf7a24");
                client.GetConfig();

                var master = Factory.GetDatabase("master");
                var movieContainer = master.GetItem(new ID("{46294884-8157-4828-9FD1-83B6E8EAFEA0}"));
                //movieContainer.DeleteChildren();
                var folderItem = master.GetItem(new ID("{A87A00B1-E6DB-45AB-8B54-636FEC3B5523}"));
                var movieTemplateItem = master.GetItem(new ID("{7D2F4318-029A-461B-854E-FD7CFB4C4F6A}"));
                var genresContainer = master.GetItem(new ID("{1A3786F4-68C0-47A5-A9D5-462765FE7C3E}"));
                var listItem = master.GetItem(new ID("{EB8C2C7A-FE2B-4E9A-8859-D4EBD9CD94D1}"));
                var productionCompaniesContainer = master.GetItem(new ID("{7A968F6F-7A21-4977-815C-581A9DC3EF5A}"));
                var productionCountriesContainer = master.GetItem(new ID("{2E421735-1C21-4648-8CC9-118B68B150C8}"));
                var pageID = 0;
                var totalPages = client.GetMovieList(MovieListType.TopRated, pageID).TotalPages;
                while (pageID <= totalPages)
                {
                    var movies = client.GetMovieList(MovieListType.TopRated, pageID);
                    pageID++;
                    foreach (var movie in movies.Results)
                    {
                        litMessage.Text += String.Format("{0} -> {1}<br/>", movie.OriginalTitle,
                            !movie.Title.Equals(movie.OriginalTitle) ? movie.Title : "");
                        var movieExt = client.GetMovie(movie.Id, MovieMethods.Credits);
                        
                        var sitecoreTitle = ItemUtil.ProposeValidItemName(movieExt.Title.Trim().ToLower());
                        var firstLetter = ItemUtil.ProposeValidItemName(sitecoreTitle.Substring(0, 1));

                        Item subFolder = movieContainer.Children.FirstOrDefault(x => x.Name == firstLetter);
                        if (subFolder == null)
                            subFolder = movieContainer.Add(firstLetter, new TemplateID(folderItem.ID));
                        if (subFolder.Children.FirstOrDefault(x => x.Name == sitecoreTitle) != null)
                            continue;
                        var movieItem = subFolder.Add(sitecoreTitle, new TemplateID(movieTemplateItem.ID));
                        movieItem.Editing.BeginEdit();
                        movieItem["Original title"] = movieExt.OriginalTitle;
                        movieItem["Title"] = movieExt.Title;
                        movieItem["Tagline"] = movieExt.Tagline;
                        movieItem["Body"] = movieExt.Overview;
                        movieItem["Vote average"] = movieExt.VoteAverage.ToString("00.00");
                        movieItem["Vote count"] = movieExt.VoteCount.ToString();
                        var genresField = (MultilistField) movieItem.Fields["Genres"];

                        foreach (var genre in movieExt.Genres)
                        {
                            var genreSitecoreName = ItemUtil.ProposeValidItemName(genre.Name.Trim().ToLower());
                            var genreItem = genresContainer.Children.FirstOrDefault(x => x.Name == genreSitecoreName);
                            if (genreItem == null)
                            {
                                genreItem = genresContainer.Add(genreSitecoreName, new TemplateID(listItem.ID));
                                genreItem.Editing.BeginEdit();
                                genreItem["Id"] = genre.Id.ToString();
                                genreItem["Name"] = genre.Name;
                                genreItem.Editing.EndEdit();
                            }
                            genresField.Add(genreItem.ID.ToString());
                        }
                        movieItem["Tmdb Id"] = movieExt.Id.ToString();
                        movieItem["Imdb Id"] = movieExt.ImdbId;
                        movieItem["Runtime"] = movieExt.Runtime.GetValueOrDefault().ToString();
                        movieItem["Status"] = movieExt.Status;
                        movieItem["Release date"] = DateUtil.ToIsoDate(movieExt.ReleaseDate.GetValueOrDefault());

                        var productionCompaniesField = (MultilistField) movieItem.Fields["Production companies"];

                        foreach (var productionCompany in movieExt.ProductionCompanies)
                        {
                            var productionCompanySitecoreName =
                                ItemUtil.ProposeValidItemName(productionCompany.Name.Trim().ToLower());
                            var productionCompanyItem =
                                productionCompaniesContainer.Children.FirstOrDefault(
                                    x => x.Name == productionCompanySitecoreName);
                            if (productionCompanyItem == null)
                            {
                                productionCompanyItem = productionCompaniesContainer.Add(productionCompanySitecoreName,
                                    new TemplateID(listItem.ID));
                                productionCompanyItem.Editing.BeginEdit();
                                productionCompanyItem["Id"] = productionCompany.Id.ToString();
                                productionCompanyItem["Name"] = productionCompany.Name;
                                productionCompanyItem.Editing.EndEdit();
                            }
                            productionCompaniesField.Add(productionCompanyItem.ID.ToString());
                        }
                        var productionCountriesField = (MultilistField) movieItem.Fields["Production countries"];

                        foreach (var productionCountry in movieExt.ProductionCountries)
                        {
                            var productionCountrySitecoreName =
                                ItemUtil.ProposeValidItemName(productionCountry.Name.Trim().ToLower());
                            var productionCountryItem =
                                productionCountriesContainer.Children.FirstOrDefault(
                                    x => x.Name == productionCountrySitecoreName);
                            if (productionCountryItem == null)
                            {
                                productionCountryItem = productionCountriesContainer.Add(productionCountrySitecoreName,
                                    new TemplateID(listItem.ID));
                                productionCountryItem.Editing.BeginEdit();
                                productionCountryItem["Id"] = productionCountry.Iso_3166_1;
                                productionCountryItem["Name"] = productionCountry.Name;
                                productionCountryItem.Editing.EndEdit();
                            }
                            productionCountriesField.Add(productionCountryItem.ID.ToString());
                        }
                        var posterUri = client.GetImageUrl("original", movie.PosterPath);
                        if (!String.IsNullOrEmpty(movie.PosterPath))
                        {
                            var mediaItem = AddFile(posterUri, sitecoreTitle, movie.PosterPath.Replace("/", ""));
                            if (mediaItem != null)
                            {
                                Sitecore.Data.Fields.ImageField imageField = movieItem.Fields["Image"];
                                imageField.MediaID = mediaItem.ID;
                            }
                        }
                        movieItem["Menu title"] = movie.Title;
                        movieItem["SEO title"] = movie.Title;
                        movieItem.Editing.EndEdit();
                    }
                }
                IndexCustodian.ResumeIndexing();
                Sitecore.Configuration.Settings.Indexing.Enabled = true;
                IndexCustodian.RebuildAll();
            }}