public async Task LoadAsync(Game game)
        {
            // Record.
            this.GameToMatch = game;
            textQuery.Text   = await ScraperEngine.GetGameNameAsync(game.Platform, game.GameFilename);

            comboPlatform.SelectedItem = game.Platform;

            // Load the scrapers.
            var scrapers = ScraperEngine.GatherScrapers(this.CatalogEditor.Config.FolderPath);

            if (scrapers.Count > 0)
            {
                foreach (var scraper in scrapers)
                {
                    comboScraper.Items.Add(scraper);
                }
                comboScraper.SelectedIndex = 0;
            }
        }
Exemplo n.º 2
0
        private async Task MatchNowAsync(DoWorkEventArgs e)
        {
            int index  = 0;
            var engine = new ScraperEngine();

            // Match.
            foreach (var game in this.GamesToMatch)
            {
                // Exit if cancellation pending.
                if (this.BackgroundWorker.CancellationPending)
                {
                    break;
                }

                index++;
                ReportProgress(index, "Matching " + index + "/" + this.GamesToMatch.Count + ": " + game.GameFilename + "...");
                try
                {
                    var query = await ScraperEngine.GetGameNameAsync(game.Platform, game.GameFilename);

                    var matchedGame = await engine.SearchExactAsync(this.Scraper, game.Platform, query, game.GameFilename);

                    if (matchedGame != null)
                    {
                        await this.CatalogEditor.MatchGameAsync(game, matchedGame,
                                                                await HttpHelper.DownloadFileContentsAsync(matchedGame.ImageFilePath));

                        ReportProgress(index, "MATCHED\n");
                    }
                    else
                    {
                        ReportProgress(index, "Not Matched\n");
                    }
                }
                catch (Exception ex)
                {
                    ReportProgress(index, "ERROR: " + ex.Message + "\n");
                }
            }
        }