public static ChooseMovieDialogResult GetCorrectMovie(Window owner, BindingList <MovieInfo> candidates, string keywords, bool imdbSelection)
        {
            ChooseMovieDialogResult _result = new ChooseMovieDialogResult();

            if (FileManager.Mode == ProcessingMode.FeelingLucky)
            {
                if (candidates != null && candidates.Count > 0)
                {
                    return(new ChooseMovieDialogResult()
                    {
                        MovieInfo = candidates[0]
                    });
                }
                else
                {
                    return(new ChooseMovieDialogResult());
                }
            }
            else
            {
                if (candidates != null && candidates.Count == 1)
                {
                    _result = new ChooseMovieDialogResult()
                    {
                        MovieInfo = candidates[0]
                    };
                }
                else
                {
                    if (candidates != null && candidates.Count > 0)
                    {
                        ChooseMovieFromIMDb _box = new ChooseMovieFromIMDb();
                        _box.Owner    = owner;
                        _box.IMDBMode = imdbSelection;
                        _box.panelCollectorInfo.Visibility = imdbSelection ? Visibility.Collapsed : Visibility.Visible;
                        _box.tbKeywords.Text       = keywords;
                        _box.WindowStartupLocation = owner != null ? WindowStartupLocation.CenterOwner : WindowStartupLocation.CenterScreen;
                        _box.MoviesBox.DataContext = candidates;
                        var res = _box.ShowDialog();
                        if (res.HasValue && res.Value && _box.MoviesBox.SelectedItem != null)
                        {
                            _result = _box.ChooseMovieDialogResult;
                        }
                    }
                }
                // if the selected item is a series item, remembed the seriesid
                if (_result != null && _result.MovieInfo != null && !string.IsNullOrEmpty(_result.MovieInfo.TVDBID))
                {
                    CurrentSeriesHelper.SeriesID     = _result.MovieInfo.TVDBID;
                    CurrentSeriesHelper.SeriesIMDBID = _result.MovieInfo.IMDBID;
                    CurrentSeriesHelper.SeriesName   = _result.MovieInfo.Name;
                }

                return(_result);
            }
        }
        public ChooseMovieFromIMDb()
        {
            InitializeComponent();

            ChooseMovieDialogResult          = new ChooseMovieDialogResult();
            this.DataContext                 = this;
            this.MouseLeftButtonDown        += delegate { DragMove(); };
            this.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(ChooseMovieFromIMDb_PreviewMouseLeftButtonDown);
            this.Loaded  += new RoutedEventHandler(ChooseMovieFromIMDb_Loaded);
            this.Closing += new CancelEventHandler(ChooseMovieFromIMDb_Closing);
        }
示例#3
0
        public MovieInfo QueryPreferredCollector(string imdbid, string keywords)
        {
            MovieInfo _result = null;

            // find the type of the preferred collector
            BaseCollector _tmp = BaseCollector.GetMovieCollector(FileManager.Configuration.Options.PreferedInfoCollector);

            if (_tmp != null)
            {
                // create a new collector (to not affect the old one)
                BaseCollector _prefCollector = GetNewCollectorObject(FileManager.Configuration.Options.PreferedInfoCollector); //BaseCollector.GetMovieCollector(FileManager.Configuration.Options.PreferedInfoCollector);
                Loggy.Logger.Debug("Detected prefinfocollector: " + _prefCollector.CollectorName);
                //BaseCollector _prefCollector = BaseCollector.GetMovieCollectorObject(FileManager.Configuration.Options.PreferedInfoCollector);
                if (_prefCollector != null)
                {
                    _prefCollector.IMDBID       = imdbid;
                    _prefCollector.CurrentMovie = new MovieItem(MoviePath);
                    _result = _prefCollector.QueryMovieInfo(_prefCollector.IMDBID);
                    if ((_result == null) || (string.IsNullOrEmpty(_result.Name)))
                    {
                        // ask user
                        _prefCollector.GetResults(keywords, _prefCollector.IMDBID, true);
                        BindingList <MovieInfo> _candidates = new BindingList <MovieInfo>();
                        foreach (ResultItemBase _rib in _prefCollector.ResultsList)
                        {
                            if (!string.IsNullOrEmpty(imdbid) && !string.IsNullOrEmpty(_rib.MovieInfo.IMDBID) && imdbid != _rib.MovieInfo.IMDBID)
                            {
                                continue; // IMDBID does not match with ours
                            }
                            if (!_candidates.Contains(_rib.MovieInfo, new MovieInfoComparer()))
                            {
                                _candidates.Add(_rib.MovieInfo);
                            }
                        }
                        ChooseMovieDialogResult _dresult = ChooseMovieFromIMDb.GetCorrectMovie(null, _candidates, "", false);
                        _result = _dresult != null ? _dresult.MovieInfo : null;
                    }
                }
            }
            return(_result);
        }