private void cmdOK_Click(object sender, EventArgs e) { var selected = (TmdbResult)comboBox1.SelectedItem; SelectedEntry = new MovieEntry(); SelectedEntry.SetData(_oldEntry); SelectedEntry.SetData(selected); DialogResult = DialogResult.OK; }
private async Task <MovieEntry> HelperFetch(string path) { var tmdb = _kernel.Get <ITmdb>(); var guessit = _kernel.Get <IGuessit>(); var filename = Path.GetFileName(path); // results GuessitResult name = null; TmdbResult newData = null; // process try { // guess name = await guessit.RealGuessName(filename); if (name?.ImdbId != null) { // IMDB id detected newData = await tmdb.GetByImdbId(name.ImdbId); } else if (name?.Title != null) { // title detected var movies = await tmdb.SearchMovies(name.Title, name.Year); newData = await tmdb.GetByTmdbId(movies.First()); } } catch (Exception e) { Debug.Print("Unable to fetch: {0}. {1}", filename, e.Message); } // entry create var entry = new MovieEntry(); entry.SetFullPath(path); entry.SetData(newData ?? await tmdb.GetByFilename(filename)); if (name != null) { entry.SetData(name); } return(entry); }
public SettingsView() { InitializeComponent(); _tryitData = new MovieEntry(); _tryitData.SetData(new TmdbResult { Genre = "Science Fiction", TmdbId = 1134, ImdbId = "tt172845369", Plot = "There is...", Title = "Star Trek Beyond", Year = 2017 }); }
private async void InternalOpenDirectory(string path) { // save states UpdateUi(UiState.Working); _settings.LastOpenDirectory = path; _settings.Save(); // clear data Model.Invoke(() => Model.DataView.Clear()); // enumerate var tmdb = _kernel.Get <ITmdb>(); var persistFileManager = _kernel.Get <IPersistFileManager>(); var dirEnumbEnumerable = Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly).ToList(); var calc = new PercentageCalculator(dirEnumbEnumerable.Count); // walk foreach (var basePath in dirEnumbEnumerable) { try { string currentMoviePath; var currentFolder = new PowerPath(basePath); // check for ignore pattern var lastName = currentFolder.GetLastDirectoryName(); if (lastName.StartsWith("[") && lastName.EndsWith("]")) { continue; } // find first movie if ((currentMoviePath = HelperFindFirstFile(basePath)) == null) { continue; } // find metadata MovieEntry entry; if (persistFileManager.HasPersistentData(Path.GetDirectoryName(currentMoviePath))) { entry = persistFileManager.Load(currentMoviePath); } else { var currentResult = await tmdb.GetByFilename(currentMoviePath); entry = new MovieEntry(); entry.SetFullPath(currentMoviePath); entry.SetData(currentResult); } // push to collection Model.Invoke(() => Model.DataView.Add(entry)); } catch (Exception e) { Debug.Print("Analyze error: {0}. {1}", basePath, e.Message); } // sync _lastSelectedIndex = -1; UpdateUi(UiState.StatusUpdate, calc.Increment()); if (IsCancellationRequested) { break; } } // finish UpdateUi(UiState.Ready); }