Skip to content

Commit

Permalink
fix: use TrackerGG API instead of web scrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
pwall2222 committed Mar 30, 2024
1 parent 06135ef commit 0779be8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions NOWT/Helpers/LiveMatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,19 +1134,22 @@ private static async Task<Uri> TrackerAsync(string username)
try
{
var encodedUsername = Uri.EscapeDataString(username);
var url = new Uri("https://tracker.gg/valorant/profile/riot/" + encodedUsername);
var url = new Uri(
"https://api.tracker.network/api/v2/valorant/standard/profile/riot/"
+ encodedUsername
);
var response = await DoCachedRequestAsync(
Method.Get,
url.ToString(),
false,
false,
false,
true
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 OverwolfClient/0.190.0.13"
)
.ConfigureAwait(false);
var numericStatusCode = (short)response.StatusCode;
if (numericStatusCode == 200)
return url;
return new Uri("https://tracker.gg/valorant/profile/riot/" + encodedUsername);
}
catch (Exception e)
{
Expand Down
6 changes: 3 additions & 3 deletions NOWT/Helpers/Login.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static async Task<RestResponse> DoCachedRequestAsync(
bool addRiotAuth,
bool bypassCache = false,
bool displayError = true,
bool userAgentTrickery = false
string? userAgent = null
)
{
var attemptCache = method == Method.Get && !bypassCache;
Expand All @@ -182,9 +182,9 @@ public static async Task<RestResponse> DoCachedRequestAsync(
return res;
var client = new RestClient(url);

if (userAgentTrickery)
if (userAgent is not null)
{
client.AddDefaultHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:121.0) Gecko/20100101 Firefox/121.0");
client.AddDefaultHeader("User-Agent", userAgent);
}

var request = new RestRequest();
Expand Down

0 comments on commit 0779be8

Please sign in to comment.