private void manualAssignButton_Click(object sender, EventArgs e) { unapprovedGrid.EndEdit(); foreach (DataGridViewRow currRow in unapprovedGrid.SelectedRows) { MovieMatch selectedMatch = (MovieMatch)currRow.DataBoundItem; ManualAssignPopup popup = new ManualAssignPopup(selectedMatch); popup.ShowDialog(this); if (popup.DialogResult == DialogResult.OK) { // create a movie with the user supplied information DBMovieInfo movie = new DBMovieInfo(); movie.Title = popup.Title; movie.Year = popup.Year.GetValueOrDefault(0); // update the match PossibleMatch selectedMovie = new PossibleMatch(); selectedMovie.Movie = movie; MatchResult result = new MatchResult(); result.TitleScore = 0; result.YearScore = 0; result.ImdbMatch = true; selectedMovie.Result = result; selectedMatch.PossibleMatches.Add(selectedMovie); selectedMatch.Selected = selectedMovie; ThreadStart actions = delegate { // Manually Assign Movie MovingPicturesCore.Importer.ManualAssign(selectedMatch); }; Thread thread = new Thread(actions); thread.Name = "ManualUpdateThread"; thread.Start(); } } }
public MatchResult GetMatchResult(DBMovieInfo movie) { // Create a new score card MatchResult result = new MatchResult(); // Get the default scores for this movie result.TitleScore = matchTitle(movie.Title); result.YearScore = matchYear(movie.Year); result.ImdbMatch = matchImdb(movie.ImdbID); // check if this match came from our #1 details provider ReadOnlyCollection<DBSourceInfo> detailSources = MovingPicturesCore.DataProviderManager.MovieDetailSources; if (detailSources.Count > 0 && detailSources[0] == movie.PrimarySource) result.FromTopSource = true; else result.FromTopSource = false; // If we don't have a perfect score on the original title // iterate through the available alternate titles and check // them to lower the score if possible if (result.TitleScore > 0) { foreach (string alternateTitle in movie.AlternateTitles.ToArray()) { int score = matchTitle(alternateTitle); // if this match is better than the previous one save the score if (score < result.TitleScore) { result.TitleScore = score; result.AlternateTitle = alternateTitle; } // if the best score is 0 (the best possible score) then stop score checking if (result.TitleScore == 0) break; } } // return the result logger.Debug("MATCHING: '{0}' WITH: '{1}' RESULT: {2}", this.baseTitle, movie.Title, result.ToString()); return result; }