/// <summary>
        /// Called when a download link search is done.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void SingleDownloadSearchDone(object sender, EventArgs e)
        {
            _done.Add(sender as DownloadSearchEngine);

            (sender as DownloadSearchEngine).DownloadSearchNewLink -= SingleDownloadSearchNewLink;
            (sender as DownloadSearchEngine).DownloadSearchDone    -= SingleDownloadSearchDone;
            (sender as DownloadSearchEngine).DownloadSearchError   -= SingleDownloadSearchError;

            DownloadSearchEngineDone.Fire(this, SearchEngines.Except(_done).ToList());

            if (_done.Count == SearchEngines.Count)
            {
                Log.Debug("Search finished in " + (DateTime.Now - _start).TotalSeconds + "s.");
                DownloadSearchDone.Fire(this);
            }
        }
        /// <summary>
        /// Called when a download link search has encountered an error.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void SingleDownloadSearchError(object sender, EventArgs <string, Exception> e)
        {
            _done.Add(sender as DownloadSearchEngine);

            (sender as DownloadSearchEngine).DownloadSearchNewLink -= SingleDownloadSearchNewLink;
            (sender as DownloadSearchEngine).DownloadSearchDone    -= SingleDownloadSearchDone;
            (sender as DownloadSearchEngine).DownloadSearchError   -= SingleDownloadSearchError;

            Log.Warn("Error while searching on " + ((DownloadSearchEngine)sender).Name + ".", e.Second);

            DownloadSearchEngineError.Fire(this, e.First, e.Second);
            DownloadSearchEngineDone.Fire(this, SearchEngines.Except(_done).ToList());

            if (_done.Count == SearchEngines.Count)
            {
                Log.Debug("Search finished in " + (DateTime.Now - _start).TotalSeconds + "s.");
                DownloadSearchDone.Fire(this);
            }
        }
        /// <summary>
        /// Synchronous search helper.
        /// </summary>
        /// <param name="query">The name of the release to search for.</param>
        private void SearchInternal(object query)
        {
            try
            {
                _cts.Token.ThrowIfCancellationRequested();
                var list = Search((string)query);
                _cts.Token.ThrowIfCancellationRequested();

                foreach (var link in list)
                {
                    _cts.Token.ThrowIfCancellationRequested();
                    DownloadSearchNewLink.Fire(this, link);
                    _cts.Token.ThrowIfCancellationRequested();
                }

                _cts.Token.ThrowIfCancellationRequested();
                DownloadSearchDone.Fire(this);
            }
            catch (InvalidCredentialException)
            {
                Log.Warn(Name + " requires authentication.");

                var info = Settings.Get(Name + " Login");

                if (!CanLogin || string.IsNullOrWhiteSpace(info) || _cts.IsCancellationRequested)
                {
                    DownloadSearchDone.Fire(this);
                    return;
                }

                Log.Debug("Trying to authenticate with " + Name + "...");

                try
                {
                    _cts.Token.ThrowIfCancellationRequested();

                    var usrpwd  = Utils.Decrypt(this, info);
                    var cookies = Login(usrpwd[0], usrpwd[1]);

                    Cookies = cookies;
                    Settings.Set(Name + " Cookies", Utils.Encrypt(this, cookies));

                    _cts.Token.ThrowIfCancellationRequested();
                    var list = Search((string)query);
                    _cts.Token.ThrowIfCancellationRequested();

                    foreach (var link in list)
                    {
                        _cts.Token.ThrowIfCancellationRequested();
                        DownloadSearchNewLink.Fire(this, link);
                        _cts.Token.ThrowIfCancellationRequested();
                    }

                    _cts.Token.ThrowIfCancellationRequested();
                    DownloadSearchDone.Fire(this);
                }
                catch (InvalidCredentialException)
                {
                    Log.Warn("Failed to authenticate with " + Name + ": invalid credentials or broken plugin.");
                    DownloadSearchDone.Fire(this);
                }
                catch (Exception ex)
                {
                    DownloadSearchError.Fire(this, "There was an error while searching for download links.", ex);
                }
            }
            catch (Exception ex)
            {
                DownloadSearchError.Fire(this, "There was an error while searching for download links.", ex);
            }
        }