private void frmGraphView_Load(object sender, EventArgs e) { LoadImages(PrivateData.GetRelativePath(@"\Cache\Images\")); // Load all known images for use in the Graph u = PersistenceBase.Load <Universe>(PrivateData.GetRelativePath(@"\Cache\uinverse3.json")); refreshLists(); //viewer.Graph = SetViewAll(); lblSelectedNode.Text = "Selected Node: " + selectedNode; }
private void btnLoadFranchise_Click(object sender, EventArgs e) { u = PersistenceBase.Load <Universe>(PrivateData.GetRelativePath(@"\Cache\uinverse3.json")); lbActors.Items.Clear(); lbCharacters.Items.Clear(); tbActor.Clear(); tbCharacter.Clear(); lbMovies.Items.Clear(); refreshLists(); }
/// <summary> /// This function was created to avoid multiple google searches since it is limited to 100 a day. /// Saving the search results to File and loading from it saves the search and helps to figure out how to refine /// as well as developing the desired feature of being able to crop / scale and save for Character Profile and Icon (for graph) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLoadFromFile_Click(object sender, EventArgs e) { if (lbCharacters.SelectedIndex >= 0) { //todo - prefer Jared Leto as The Joker in Suicide Squad.json to just character name as they could be duplicates //Need same lookup as CharacterImageMaker to do that.. string query = lbCharacters.SelectedItem.ToString(); string filePath = PrivateData.GetAppPath() + @"\Private\" + query.Replace("/", "_") + ".json"; if (File.Exists(filePath)) { CharacterImageSearchResults cisr = PersistenceBase.Load <CharacterImageSearchResults>(filePath); foreach (CharacterImageSearchResult r in cisr.CharacterImageSearchResultsList) { string tFilter = r.Title.ToLower(); if (tFilter.Contains("toys") || tFilter.Contains("tv") || tFilter.Contains("collectibles") || tFilter.Contains("figure") || tFilter.Contains("halloween")) { continue; //skip this one } createImage(r.ThumbnailLink, r.ImageLink, r.ThumbnailWidth, r.ThumbnailHeight); } } } }
private void btnSaveUniverse_Click(object sender, EventArgs e) { PersistenceBase.Save(PrivateData.GetRelativePath(@"\Cache\uinverse3.json"), u); }
/// <summary> /// Initialize The Movie DB /// </summary> private async static void initTMDB() { //There needs to be a global location for this as it await TheMovieDb.Initialise(PrivateData.GetTMDBApiKey(), "en-US", true); }
public WelcomeForm() { InitializeComponent(); //Since this is a demo This is loaded for the full data universe u = PersistenceBase.Load <Universe>(PrivateData.GetRelativePath(@"\Cache\uinverse3.json")); }
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); }
public CharacterFinder() { InitializeComponent(); u = PersistenceBase.Load <Universe>(PrivateData.GetRelativePath(@"\Cache\uinverse3.json")); //InitTheMovieDb(); }
private void button1_Click(object sender, EventArgs e) { flpThumbNails.Controls.Clear(); //Example Image Search using Google API //Get my private API key string apiKey = PrivateData.GetGoogleApiKey(); //Image Search engine.. Can change to other search engines string searchEngineId = PrivateData.GetGoogleSearchId(); //Base Query Movie m = u.GetMovie(cbMovie.SelectedItem.ToString()); int movieReleaseYear = m.ReleaseYear; String movieTitle = m.Title; String characterName = lbCharacters.SelectedItem.ToString().Replace("/", ""); // Remove slash if it exists. String actor = ""; HashSet <int> peopleIDs = new HashSet <int>(); // m.GetActorsWhoPlayedCharacter(characterName); if (peopleIDs.Count() > 0) { int person1 = peopleIDs.First(); actor = u.People.First(o => o.Id == person1).Name; } else { //Problem with lookup } string query = actor + " as " + characterName + " in " + movieTitle; // Need Movie and Actor example: Jared Leto as The Joker in Suicide Squad // 2016 CharacterImageSearchResults cisr = new CharacterImageSearchResults(); var customSearchService = new CustomsearchService(new BaseClientService.Initializer { ApiKey = apiKey }); var features = customSearchService.Features; var listRequest = customSearchService.Cse.List(query); listRequest.Cx = searchEngineId; listRequest.SearchType = CseResource.ListRequest.SearchTypeEnum.Image; listRequest.ImgType = CseResource.ListRequest.ImgTypeEnum.Face; listRequest.ExcludeTerms = "toys, collectables, figure"; listRequest.Filter = CseResource.ListRequest.FilterEnum.Value1; // Turn on duplicate content filter. Console.WriteLine("Image Search for: " + query); IList <Result> paging = new List <Result>(); var count = 0; while (paging != null) { // Console.WriteLine($"Page {count}"); listRequest.Start = count * 10 + 1; if (listRequest.Start >= 50) { break; // DOn't want all results.. just first 5 pages (50 or so. } paging = listRequest.Execute().Items; if (paging != null) { foreach (var item in paging) { //Can and should filter by known Titles that would not be relevant (first through search engine and second here.) //+ "Image :" + item.Image.ContextLink+ string tFilter = item.Title.ToLower(); if (tFilter.Contains("toys") || tFilter.Contains("tv") || tFilter.Contains("collectibles") || tFilter.Contains("figure") || tFilter.Contains("halloween")) { continue; //skip this one } Console.WriteLine("Title : " + item.Title + Environment.NewLine + "ContextLink: " + item.Image.ContextLink + Environment.NewLine + "MIME: " + item.Mime + Environment.NewLine + "Image Link: " + item.Link + Environment.NewLine + "Image Width: " + item.Image.Width + Environment.NewLine + "Image Height: " + item.Image.Height + Environment.NewLine + "Thumbnail Link: " + item.Image.ThumbnailLink + Environment.NewLine + "Thumbnail Width: " + item.Image.ThumbnailWidth + Environment.NewLine + "Thumbnail Height: " + item.Image.ThumbnailHeight + Environment.NewLine + Environment.NewLine); CharacterImageSearchResult cis = new CharacterImageSearchResult(); cis.Title = item.Title; cis.ContextLink = item.Image.ContextLink; cis.Mime = item.Mime; cis.ImageLink = item.Link; cis.ImageWidth = (int)item.Image.Width; cis.ImageHeight = (int)item.Image.Height; cis.ThumbnailLink = item.Image.ThumbnailLink; cis.ThumbnailWidth = (int)item.Image.ThumbnailWidth; cis.ThumbnailHeight = (int)item.Image.ThumbnailHeight; cisr.CharacterImageSearchResultsList.Add(cis); createImage(item.Image.ThumbnailLink, item.Link, (int)item.Image.ThumbnailWidth, (int)item.Image.ThumbnailHeight); } } count++; } //Console.WriteLine("Done."); //Console.ReadLine(); //No Slashes //No Colon //Can't have quotes (Escaped or otherwise) PersistenceBase.Save(PrivateData.GetAppPath() + @"\Private\" + query.Replace("/", "_").Replace(":", "") + ".json", cisr); }