Skip to content

Commit

Permalink
Fixed crash / incorrect behavior when searching TheGamesDB.net for a …
Browse files Browse the repository at this point in the history
…number
  • Loading branch information
DanTheMan827 committed Aug 10, 2021
1 parent 54b7201 commit f18aa1b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ScraperForm.cs
Expand Up @@ -867,10 +867,15 @@ private void buttonSearch_Click(object sender, EventArgs e)
Threads.Add(Thread.CurrentThread);
IScraperResult results = null;
Task<IScraperResult> resultsTask = null;
var matches = Regex.Matches(item.SearchTerm, "^ID:(?:,?\\s*(\\d+))+$");
var ids = Regex.Matches(item.SearchTerm, "(\\d+)").Cast<Match>().Select(m => int.Parse(m.Groups[1].Value)).ToArray();
var ids = Regex.Matches(item.SearchTerm, "(\\d+$)").Cast<Match>().Select(m =>
{
int value = 0;
int.TryParse(m.Groups[0].Value, out value);
return value;
}).Where(i => i > 0).Distinct().ToArray();
if (matches.Count > 0 && ids.Length > 0 && scraper is TeamShinkansen.Scrapers.TheGamesDB.Scraper)
if (item.SearchTerm.StartsWith("ID:") && ids.Length > 0 && scraper is TeamShinkansen.Scrapers.TheGamesDB.Scraper)
{
resultsTask = ((TeamShinkansen.Scrapers.TheGamesDB.Scraper)scraper).GetInfoByID(ids);
}
Expand Down

0 comments on commit f18aa1b

Please sign in to comment.