AllGames() public method

public AllGames ( ) : List
return List
Example #1
0
        public void IntervallSearchFromDB(int Intervall)
        {
            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;

            while (!_stopped)
            {
                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);

                        if (RSSResults == null)
                            break;

                        #region Checking
                        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;
                            }
                        }
                        #endregion
                    }
                }
                System.Threading.Thread.Sleep(Intervall * 60000);
            }
        }