Пример #1
0
        public override bool GetResults(string keywords, string imdbID, bool skipImages)
        {
            bool _result = false;

            m_IMDbId = imdbID;

            try
            {
                m_EpisodeData = EpisodeData.GetEpisodeData(this.CurrentMovie.Filename);
            }
            catch { }

            try
            {
                // don't start querying if there's no episode number detected
                if (!string.IsNullOrEmpty(m_EpisodeData.Episode) && GetMirrors())
                {
                    if (GetSeries(keywords))
                    {
                        foreach (KeyValuePair <int, TheTVDBSerieItem> _item in m_Series)
                        {
                            if (FileManager.CancellationPending)
                            {
                                return(ResultsList.Count != 0);
                            }

                            if (skipImages)
                            {
                                string          _id        = _item.Value.ID.ToString();
                                ResultMovieItem _movieItem = new ResultMovieItem(_id, _item.Value.Title, null, CollectorName);
                                _movieItem.MovieInfo = _item.Value.MovieInfo;
                                SetCurrentEpisodeRelatedInfo(Convert.ToInt32(_id), _movieItem.MovieInfo);

                                _movieItem.CollectorMovieUrl = !string.IsNullOrEmpty(_id) ? string.Format("http://thetvdb.com/index.php?tab=series&id={0}", _id) : null;
                                ResultsList.Add(_movieItem);
                            }
                            else
                            {
                                GetEpisodes(_item.Value);
                                GetPosters(_item.Value);
                            }

                            _result = true;
                        }
                    }
                }
            }
            catch { }

            return(_result);
        }
Пример #2
0
        public static bool Show(Window owner, string folder, string imageUrl)
        {
            BatchApplyFolderBox _box = new BatchApplyFolderBox();

            _box.Owner = owner;
            _box.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            _box.TheFolder.Text        = string.Format(@"{0}\", folder);

            _box.PromptWatermarkText.Visibility = (owner is ResultsListBox) ? (owner as ResultsListBox).Watermark.Visibility : Visibility.Collapsed;

            AsyncImageDownloader.GetImageAsync(_box, imageUrl, SetImageData);

            bool?_res = _box.ShowDialog();

            if (_res.HasValue && _res.Value)
            {
                bool _promptUser = FileManager.Configuration.Options.AddWatermark && (bool)_box.rbManual.IsChecked;
                _box.Dispatcher.BeginInvoke((Action) delegate
                {
                    IEnumerable <FileInfo> _movies = new FilesCollector().CollectFiles(folder, false);
                    string _season = string.Empty;

                    foreach (FileInfo _movie in _movies)
                    {
                        string _destFile = Helpers.GetCorrectThumbnailPath(_movie.FullName, true);
                        if (File.Exists(_destFile) && !_box.OverwriteAllFlag)
                        {
                            continue;
                        }

                        string _text = FileManager.Configuration.Options.WatermarkOptions.Text;

                        if (!_promptUser)
                        {
                            //detect season
                            EpisodeData _epData = EpisodeData.GetEpisodeData(_movie.Name);
                            string _s           = _epData.Season;
                            _season             = string.IsNullOrEmpty(_s) ? _season : _s;
                            // detect episode
                            string _episode = _epData.Episode;
                            if (string.IsNullOrEmpty(_episode))
                            {
                                // detect Cd number
                                _episode = KeywordGenerator.ExtractCDNumber(_movie.Name);
                                if (string.IsNullOrEmpty(_episode))
                                {
                                    // default text
                                    _episode = FileManager.Configuration.Options.WatermarkOptions.Text;
                                }
                            }

                            // apply mask
                            string _mask = FileManager.Configuration.Options.BatchAutoMask;
                            if (string.IsNullOrEmpty(_mask))
                            {
                                _mask = "S$SE$E";
                            }

                            _text = _mask.Replace("$S", _season).Replace("$E", _episode).Trim();
                        }
                        else
                        {
                            InputBoxDialogResult _ibres = InputBox.Show(null, _text,
                                                                        "type text here",
                                                                        "Add custom text for " + System.IO.Path.GetFileName(_movie.FullName),
                                                                        false, false, null, false);
                            if (_ibres.SkipFolder)
                            {
                                return;
                            }
                            if (string.IsNullOrEmpty(_ibres.Keywords))
                            {
                                continue;
                            }
                            _text = _ibres.Keywords;
                        }

                        FileManager.Configuration.Options.WatermarkOptions.Text = string.IsNullOrEmpty(_text) ? FileManager.Configuration.Options.WatermarkOptions.Text : _text;

                        Helpers.CreateThumbnailImage(imageUrl, _destFile, FileManager.Configuration.Options.KeepAspectRatio);
                    }
                }, _promptUser ? DispatcherPriority.Send : DispatcherPriority.Background);
            }
            return((bool)_res);
        }