コード例 #1
0
 public ScraperResult(string siteId, string title, string system, string year, Scraper dataProvider, string searchString = null)
 {
     SiteId         = siteId == null ? "" : siteId;
     Title          = title == null ? "" : title;
     System         = system == null ? "" : system;
     Year           = year == null ? "" : year;
     DataProvider   = dataProvider;
     SearchDistance = 0;
 }
コード例 #2
0
 public void Add(Scraper scraper, ScraperResult result)
 {
     cachedResults[scraper] = result;
 }
コード例 #3
0
        public static List <Scraper> GetScrapers(bool allowIgnored = false)
        {
            List <Scraper> scrapers = new List <Scraper>();

            List <string> scriptPriorities = new List <string>();

            string[] optStr = Options.Instance.GetStringOption("scraperpriorities").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            scriptPriorities.AddRange(optStr);

            List <string> ignoredScripts = new List <string>();

            if (!allowIgnored)
            {
                optStr = Options.Instance.GetStringOption("ignoredscrapers").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                ignoredScripts.AddRange(optStr);
            }

            foreach (string resource in System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames())
            {
                if (!resource.StartsWith("MyEmulators2.Importer.Scripts.") || !resource.EndsWith(".xml"))
                {
                    continue;
                }

                Scraper script = new Scraper(resource);
                if (script.IsReady)
                {
                    if (allowIgnored || !ignoredScripts.Contains(script.IdString))
                    {
                        scrapers.Add(script);
                        Logger.LogDebug("Successfully added script {0}", script.Name);
                    }
                    else
                    {
                        Logger.LogDebug("Ignoring script {0}", script.Name);
                    }
                }
            }

            if (scrapers.Count < 1)
            {
                return(scrapers);
            }

            foreach (Scraper scraper in scrapers)
            {
                int prio = scriptPriorities.IndexOf(scraper.IdString);
                if (prio < 0)
                {
                    scriptPriorities.Add(scraper.IdString);
                    prio = scriptPriorities.Count - 1;
                }
                scraper.Priority = prio;
            }

            scrapers.Sort((Scraper s, Scraper t) =>
            {
                return(s.Priority.CompareTo(t.Priority));
            });

            return(scrapers);
        }