FreakOut.classes.Searcher.SearchFromDB C# (CSharp) Method

SearchFromDB() public method

public SearchFromDB ( ) : void
return void
        public void SearchFromDB()
        {
            DatabaseConnector SearchConnector = new DatabaseConnector(SearchLog);
            List<string> providerlist = SearchConnector.GetProviderList;
            ProviderInterface RSSSearch = new ProviderInterface(providerlist, SearchLog);
            bool sabenabled;

            if (SearchConnector.GetSettingByName("sabnzbdenabled") == "True")
                sabenabled = true;
            else
                sabenabled = false;

            nzbhandler sabnzbd = new nzbhandler(SearchLog);
            bool exc = false;

            List<Game> Result = SearchConnector.AllGames();

            if (Result != null && providerlist != null)
            {
                foreach (Game GameToSearch in Result)
                {
                    if (GameToSearch == null)
                        break;

                    List<string> RSSResults = RSSSearch.Search(GameToSearch, 1000);

                    for (int i = 0; i < RSSResults.Count; i++)
                    {
                        string ResultName = RSSResults[i].Split(new Char[] { ';' })[0];
                        string ResultLink = RSSResults[i].Split(new Char[] { ';' })[1];

                        if (ResultName.Contains(GameToSearch.Name.Replace(" ", ".")) && !ResultName.Contains("Update") && !ResultName.Contains("Patch") && !SearchConnector.GameIsDownloaded(GameToSearch.ID))
                        {
                            if (SearchConnector.GetExceptions != null)
                            {
                                foreach (string exception in SearchConnector.GetExceptions)
                                {
                                    if (ResultName.Contains(exception))
                                    {
                                        exc = true;
                                        SearchLog.WriteToFile(1, "Found exception for " + GameToSearch.Name + "! Exception match: " + exception, LogSource);
                                    }

                                    if (!exc)
                                    {
                                        SearchConnector.MarkGameSnatched(GameToSearch.ID);
                                        SearchConnector.MarkGameUnwanted(GameToSearch.ID);
                                        if (sabenabled)
                                        {
                                            SearchLog.WriteToFile(1, "Downloading game " + GameToSearch.Name + " via sabnzbd.", LogSource);
                                            sabnzbd.SendNZB(ResultLink, SearchConnector.GetSettingByName("sabnzbdurl"), SearchConnector.GetSettingByName("sabnzbdapi"));
                                            break;
                                        }
                                        else
                                        {
                                            SearchLog.WriteToFile(1, "Not sending DL for " + GameToSearch.Name + " to sabnzbd. Check your config!", LogSource);
                                            break;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (sabenabled)
                                {
                                    SearchLog.WriteToFile(1, "Downloading game " + GameToSearch.Name + " via sabnzbd.", LogSource);
                                    sabnzbd.SendNZB(ResultLink, SearchConnector.GetSettingByName("sabnzbdurl"), SearchConnector.GetSettingByName("sabnzbdapi"));
                                    break;
                                }
                                else
                                {
                                    SearchLog.WriteToFile(1, "Not sending DL for " + GameToSearch.Name + " to sabnzbd. Check your config!", LogSource);
                                    break;
                                }
                            }
                                exc = false;
                            }
                        }
                    }
                }
        }

Usage Example

Esempio n. 1
0
 private void tSManualSearch_Click(object sender, EventArgs e)
 {
     Searcher ManualSearch = new Searcher(LogInstance);
     ManualSearch.SearchFromDB();
 }