Skip to content

Commit

Permalink
Keep 'co' query string parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyMartynov committed May 15, 2024
1 parent a53b4c5 commit f4cc102
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Tagging/ShazamApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace Project;

static class ShazamApi {
const string COUNTRY = "US";

static readonly HttpClient HTTP = new HttpClient();
static readonly string INSTALLATION_ID = Guid.NewGuid().ToString();

Expand All @@ -31,7 +33,7 @@ static class ShazamApi {
payloadWriter.WriteEndObject();
payloadWriter.Flush();

var url = "https://amp.shazam.com/match/v1/en/US/android/" + INSTALLATION_ID + "/" + tagId;
var url = "https://amp.shazam.com/match/v1/en/" + COUNTRY + "/android/" + INSTALLATION_ID + "/" + tagId;
var postData = new ByteArrayContent(payloadStream.GetBuffer(), 0, (int)payloadStream.Length);
postData.Headers.ContentType = new MediaTypeHeaderValue("application/json");

Expand Down Expand Up @@ -110,6 +112,10 @@ static class ShazamApi {
// As of March 2024
// shazam.com/track/[ID] redirects to shazam.com/song/[AppleSongID]
result.Url = result.Url.Replace("/track/", "/snippets/email-share/");
} else {
// Some URLs redirect to / unless the 'co' parameter is kept
// Examples: 11180294, 51774667, 538859473
result.Url = result.Url + "?co=" + COUNTRY;
}
}

Expand Down
2 changes: 1 addition & 1 deletion UI/TagLive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static class TagLive {

static void Navigate(string url) {
if(OperatingSystem.IsWindows()) {
using var proc = Process.Start("explorer", url);
using var proc = Process.Start("explorer", '"' + url + '"');
proc.WaitForExit();
}
}
Expand Down

0 comments on commit f4cc102

Please sign in to comment.