Ejemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the searchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void SearchButtonClick(object sender = null, RoutedEventArgs e = null)
        {
            if (string.IsNullOrWhiteSpace(textBox.Text))
            {
                return;
            }

            if (_searching)
            {
                ActiveSearch.CancelAsync();
                DownloadSearchDone();
                return;
            }

            _results = new ConcurrentBag <LinkItem>();
            DownloadLinksListViewItemCollection.Clear();

            textBox.IsEnabled    = false;
            searchButton.Content = "Cancel";

            ActiveSearch = new DownloadSearch(AutoDownloader.ActiveSearchEngines, filterResults.IsChecked);

            ActiveSearch.DownloadSearchDone          += DownloadSearchDone;
            ActiveSearch.DownloadSearchEngineNewLink += DownloadSearchEngineNewLink;
            ActiveSearch.DownloadSearchEngineDone    += DownloadSearchEngineDone;
            ActiveSearch.DownloadSearchEngineError   += DownloadSearchEngineError;

            SetStatus("Searching for download links on " + (string.Join(", ", ActiveSearch.SearchEngines.Select(engine => engine.Name).ToArray())) + "...", true);

            _searching = true;

            ActiveSearch.SearchAsync(textBox.Text);

            Utils.Win7Taskbar(0, TaskbarProgressBarState.Normal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Searches for the specified episode and returns the download links.
        /// </summary>
        /// <param name="ep">The episode.</param>
        /// <returns>
        /// List of download links.
        /// </returns>
        public static async Task <List <Link> > SearchForLinks(Episode ep)
        {
            var links = new List <Link>();
            var dlsrc = new DownloadSearch(AutoSearchEngines, true);

            dlsrc.DownloadSearchEngineNewLink += (s, e) => links.Add(e.Data);

            var tasks = dlsrc.SearchAsync(ep.Show.Title + " " + (ep.Show.Data.Get("notation") == "airdate" ? ep.Airdate.ToOriginalTimeZone(ep.Show.TimeZone).ToString("yyyy.MM.dd") : string.Format("S{0:00}E{1:00}", ep.Season, ep.Number)));

            await Task.WhenAll(tasks);

            return(links);
        }
        /// <summary>
        /// Handles the Click event of the searchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void SearchButtonClick(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(textBox.Text)) return;

            if (_searching)
            {
                ActiveSearch.CancelAsync();
                DownloadSearchDone();
                return;
            }

            _results = new List<LinkItem>();
            DownloadLinksListViewItemCollection.Clear();

            textBox.IsEnabled    = false;
            searchButton.Content = "Cancel";

            ActiveSearch = new DownloadSearch(AutoDownloader.ActiveSearchEngines, filterResults.IsChecked);

            ActiveSearch.DownloadSearchDone          += DownloadSearchDone;
            ActiveSearch.DownloadSearchEngineNewLink += DownloadSearchEngineNewLink;
            ActiveSearch.DownloadSearchEngineDone    += DownloadSearchEngineDone;
            ActiveSearch.DownloadSearchEngineError   += DownloadSearchEngineError;

            SetStatus("Searching for download links on " + (string.Join(", ", ActiveSearch.SearchEngines.Select(engine => engine.Name).ToArray())) + "...", true);

            _searching = true;

            ActiveSearch.SearchAsync(textBox.Text);

            Utils.Win7Taskbar(0, TaskbarProgressBarState.Normal);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Searches for the specified episode and returns the download links.
        /// </summary>
        /// <param name="ep">The episode.</param>
        /// <returns>
        /// List of download links.
        /// </returns>
        public static List<Link> SearchForLinks(Episode ep)
        {
            var links = new List<Link>();
            var dlsrc = new DownloadSearch(ActiveSearchEngines, true);
            var start = DateTime.Now;
            var busy  = true;

            dlsrc.DownloadSearchEngineNewLink += (s, e) => links.Add(e.Data);
            dlsrc.DownloadSearchDone          += (s, e) => { busy = false; };

            dlsrc.SearchAsync(ep.Show.Name + " " + (ep.Show.Data.Get("notation") == "airdate" ? ep.Airdate.ToOriginalTimeZone(ep.Show.TimeZone).ToString("yyyy.MM.dd") : string.Format("S{0:00}E{1:00}", ep.Season, ep.Number)));

            while (busy && (DateTime.Now - start).TotalMinutes < 2)
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            return links;
        }