From f4cc102a6511094eca78e331f899bf06b60eb521 Mon Sep 17 00:00:00 2001 From: AlekseyMartynov Date: Wed, 15 May 2024 16:18:32 +0300 Subject: [PATCH] Keep 'co' query string parameter --- Tagging/ShazamApi.cs | 8 +++++++- UI/TagLive.cs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Tagging/ShazamApi.cs b/Tagging/ShazamApi.cs index 1f5ffb1..8ea3945 100644 --- a/Tagging/ShazamApi.cs +++ b/Tagging/ShazamApi.cs @@ -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(); @@ -31,7 +33,7 @@ public static async Task SendRequestAsync(string tagId, int sample 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"); @@ -110,6 +112,10 @@ static void PopulateAttributes(JsonElement rootElement, ShazamResult result) { // 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; } } diff --git a/UI/TagLive.cs b/UI/TagLive.cs index 04ed3a3..97e3323 100644 --- a/UI/TagLive.cs +++ b/UI/TagLive.cs @@ -58,7 +58,7 @@ public static async Task RunAsync(bool auto) { static void Navigate(string url) { if(OperatingSystem.IsWindows()) { - using var proc = Process.Start("explorer", url); + using var proc = Process.Start("explorer", '"' + url + '"'); proc.WaitForExit(); } }