Skip to content

Commit

Permalink
Added short delay, so we don't get blocked for too many requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrKnarz committed Mar 24, 2023
1 parent d7c2c39 commit 56a227b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions Generic/LinkUtilities/Linker/LinkSources/LinkMapGenie.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using KNARZhelper;
using Playnite.SDK.Models;
using System.Threading;

namespace LinkUtilities.Linker
{
Expand All @@ -13,12 +14,18 @@ internal class LinkMapGenie : Link

// Map Genie Links need the game name in lowercase without special characters and hyphens instead of white spaces.
public override string GetGamePath(Game game, string gameName = null)
=> (gameName ?? game.Name).RemoveDiacritics()
.RemoveSpecialChars()
.Replace("_", " ")
.CollapseWhitespaces()
.Replace(" ", "-")
.ToLower();
{
// sleep a while, so the site doesn't block us for too many requests.
// Todo: put the interval into the interface, so all links could use it, and put it in the loop to only use the delay, when adding several
// links to the site in bulk.
Thread.Sleep(200);
return (gameName ?? game.Name).RemoveDiacritics()
.RemoveSpecialChars()
.Replace("_", " ")
.CollapseWhitespaces()
.Replace(" ", "-")
.ToLower();
}

public LinkMapGenie(LinkUtilities plugin) : base(plugin)
{
Expand Down

0 comments on commit 56a227b

Please sign in to comment.