/// <summary> /// Load using Preview information.. /// </summary> /// <param name="selectedMovieInfo"></param> public void LoadMovieInfo(ref TmdbWrapper.Movies.Movie selectedMovieInfo) { lblTitle.Text = selectedMovieInfo.Title; if (selectedMovieInfo.ReleaseDate.HasValue) { lblReleaseDate.Text = selectedMovieInfo.ReleaseDate.Value.ToShortDateString(); lblReleaseDate.Text += AgeHelper.GetReleaseDateDelta(selectedMovieInfo.ReleaseDate.Value); } else { lblReleaseDate.Text = "TBD"; } lblRunTime.Text = selectedMovieInfo.Runtime.ToString() + " minutes"; lblRevenue.Text = selectedMovieInfo.Revenue.ToString("C0"); // Currency no cents. if (selectedMovieInfo.Homepage != null) { pbPoster.Tag = selectedMovieInfo.Homepage.AbsoluteUri; } else { pbPoster.Tag = null; } GetMoviePoster(ref selectedMovieInfo); //TmdbWrapper.Movies.ProductionCompany IReadOnlyList <TmdbWrapper.Movies.ProductionCompany> prodCos = selectedMovieInfo.ProductionCompanies; GetProductionCompanyLogos(prodCos); }
/// <summary> /// Function for use with Preview Data /// </summary> /// <param name="selectedMovieInfo"></param> private void GetMoviePoster(ref TmdbWrapper.Movies.Movie selectedMovieInfo) { if (selectedMovieInfo.PosterPath != null) { Uri posterUri = selectedMovieInfo.Uri(TmdbWrapper.Utilities.PosterSize.w185); var wc = new WebClient(); pbPoster.BackgroundImage = Image.FromStream(wc.OpenRead(posterUri)); //Read from the Internet } else { pbPoster.BackgroundImage = null; // would like broken camera image. } }
/// <summary> /// A movie is selected and it's just supposed to be the preview information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void lbMovies_SelectedIndexChanged(object sender, EventArgs e) { if (lbMovies.SelectedIndex >= 0) { lbActors.Items.Clear(); movieInfoTip1.Clear(); personInfoTip1.Clear(); TmdbSearch.MovieSummary ms = lbMovies.SelectedItem as TmdbSearch.MovieSummary; Movie m = null; // Need the Year or movies with same title will not show. if (ms.ReleaseDate.HasValue) { m = u.GetMovie(ms.Title, ms.ReleaseDate.Value.Year); } else { m = u.GetMovie(ms.Title); //movie Summary has no release year so try to get it without. Only issue for unreleased movies it seems } if (m == null) { selectedMovieSummary = lbMovies.SelectedItem as TmdbSearch.MovieSummary; //Could get Poster Path from here if faster response is desired.. Uri summaryPosterPath = selectedMovieSummary.Uri(TmdbWrapper.Utilities.PosterSize.w154); int summaryId = selectedMovieSummary.Id; //Get Full information for the movie from Web selectedMovieInfo = await selectedMovieSummary.MovieAsync(); movieInfoTip1.LoadMovieInfo(ref selectedMovieInfo); // Show info basic info } else { selectedMovieSummary = lbMovies.SelectedItem as TmdbSearch.MovieSummary; selectedMovieInfo = await selectedMovieSummary.MovieAsync(); selectedMovie = m; //Need for Person Info movieInfoTip1.LoadMovieInfo(ref selectedMovie, ref u); showActorsInMovie(selectedMovie); } } }
public async Task <bool> SaveFullInfo(TmdbWrapper.Movies.Movie selectedMovieInfo) { if (selectedMovieInfo == null) { return(false); } //The movie might already exist in the universe so this would replace it //This is a search Result for a specific movie selectedMovie = u.GetMovie(selectedMovieSummary.Id); if (selectedMovie != null) { if (MessageBox.Show("Replace " + selectedMovie.Title + " with web data?", "Confirm Replace", MessageBoxButtons.YesNo) == DialogResult.No) { return(false); } } //Clear or create selectedMovie = new Movie(selectedMovieInfo.Title, selectedMovieInfo.ReleaseDate.Value.Year); selectedMovie.BackdropPath = selectedMovieInfo.BackdropPath; selectedMovie.TmdbId = selectedMovieInfo.Id; selectedMovie.ImdbId = selectedMovieInfo.ImdbId; selectedMovie.OriginalTitle = selectedMovieInfo.OriginalTitle; selectedMovie.Overview = selectedMovieInfo.Overview; selectedMovie.PosterPath = selectedMovieInfo.PosterPath; selectedMovie.ReleaseDate = selectedMovieInfo.ReleaseDate; selectedMovie.Revenue = selectedMovieInfo.Revenue; selectedMovie.Runtime = selectedMovieInfo.Runtime; selectedMovie.HomePage = selectedMovieInfo.Homepage; //TODO - add remaining properties //Add Collection Id to movie ONLY if one exists if (selectedMovieInfo.BelongsToCollection != null) { //Add Collection ID to Movie //selectedMovie.CollectionId = selectedMovieInfo.BelongsToCollection.Id; MovieCollection mc = u.GetMovieCollection(selectedMovieInfo.Id); if (mc == null) { //Lookup selectedMovieInfo.BelongsToCollection.Id to see if it exists.. //Add Collection to Universe MovieCollection m = u.AddMovieCollection(selectedMovieInfo.BelongsToCollection.Name, selectedMovieInfo.BelongsToCollection.Id, selectedMovieInfo.BelongsToCollection.PosterPath, selectedMovieInfo.BelongsToCollection.BackdropPath); //ONly need to do this once per movie in the collection!! //update the parts of the collection below for Universe TmdbWrapper.Collections.Collection coll = await selectedMovieInfo.BelongsToCollection.CollectionAsync(); if (coll != null) { m.Overview = coll.Overview; //Update the Movie Collection Overview. foreach (TmdbWrapper.Collections.Part p in coll.Parts) { u.AddMovieToCollection(m.Id, p.Id); // Add the movie ids of the parts to the Movie Collection Part //m.Parts.Add(p.Id); // Add the movie ids of the parts to the Movie Collection Part } } else { Console.WriteLine("Should never be here! Movie Belongs to a collection but Collection is null!"); } } } //Add Production Companies - Already have foreach (var item in selectedMovieInfo.ProductionCompanies) { //Try to get the Production Company and see if it has been updated if Null or not updated then Do web lookup ProductionCompany pc = u.GetProductionCompany(item.Id); if (u.GetProductionCompany(item.Id) == null || pc.Updated == false) { TmdbWrapper.Companies.Company c = await item.CompanyAsync(); // await FindProductionCompany(item.Id); pc = new ProductionCompany(item.Name, item.Id, item.LogoPath, item.OriginCountry); pc.Description = c.Description; pc.Headquarters = c.Headquarters; pc.Homepage = c.Homepage; pc.Updated = true; // Flag so it will not cause a lookup again. //Add Parent Production Companies if (c.ParentCompany != null) { pc.ParentCompanyId = c.ParentCompany.Id; // This could change based on movie release data.. (before purchase of A by B) } u.AddProductionCompany(pc); } MovieProductionCompanyMap mpcm = new MovieProductionCompanyMap(); mpcm.MovieId = selectedMovieInfo.Id; mpcm.ProductionCompanyId = item.Id; u.MovieProductionCompanyMap.Add(mpcm); } //Get the Movie Credits Now. TmdbWrapper.Movies.Credits credits = await selectedMovieInfo.CreditsAsync(); //credits.Cast int personCount = 0; bool skip = false; int castLimit = 100; foreach (TmdbWrapper.Movies.CastPerson cp in credits.Cast) { //try //{ String cpCharacter = cp.Character; if (cpCharacter.Length == 0) // Seriously??!!?? { switch (cp.Gender) { case 0: cpCharacter = "Themself"; break; case 1: cpCharacter = "Herself"; break; case 2: cpCharacter = "Himself"; break; } } ////Add Character To Movie (Could be Alias able character so mapping would be necessary) Character c = u.AddCharacter(cpCharacter, selectedMovie.TmdbId, cp.Id, cp.CreditId, cp.CastId, cp.Order ); //} //catch (Exception err) //{ //} //Get full person Info //THis is a problem because TMDB will return delay if getting too many at once. //Also SERIOUSLY consider only getting the first 10% of the cast - but probably have them already from other movies.. //Need on demand. Person p = new Person(cp.Name); p.Id = cp.Id; p.ProfilePath = cp.ProfilePath; skip = false; //See if we already have the person in the list if (u.People.Select(o => o.Id == cp.Id).Contains(true)) { //Get the person and see if they have been updated with full information Person testPC = u.People.First(o => o.Id == cp.Id); if (testPC.Updated) { skip = true; } } if (!skip && personCount < 2) { Thread.Sleep(100); // Slow it down.. TmdbWrapper.Persons.Person tmdbPerson = await cp.PersonAsync(); p.HomePage = tmdbPerson.Homepage; p.Biography = tmdbPerson.Biography; p.Birthday = tmdbPerson.Birthday; p.Deathday = tmdbPerson.Deathday; p.PlaceOfBirth = tmdbPerson.PlaceOfBirth; p.Updated = true; personCount++; } bool personAdded = u.AddPerson(p); // Will fail to add existing person and add basic and updated people. if (--castLimit == 0) { break; } } ////credits.Crew - Adds significant numbers of People and data Entry #region Crew import int crewLimit = 10; foreach (TmdbWrapper.Movies.CrewPerson crewPerson in credits.Crew) { u.AddCrewMember(crewPerson, selectedMovie); if (--crewLimit == 0) { break; } } #endregion //Want this for movie search results.. TmdbWrapper.Movies.Trailers t = await selectedMovieInfo.TrailersAsync(); // Want to have.. does nothing now.. if (t != null && t.Youtube.Count > 0) { String firstSource = t.Youtube[0].Source; //https://www.youtube.com/watch?v=CmRih_VtVAs // Example of how to use the source. selectedMovie.TrailerLink = "https://www.youtube.com/watch?v=" + firstSource; } u.AddMovie(selectedMovie); //Verify This is OK... PersistenceBase.Save(PrivateData.GetRelativePath(@"\Cache\uinverse3.json"), u); return(true); }