Skip to content

Commit

Permalink
imp - IsRadio() is now less strict
Browse files Browse the repository at this point in the history
---

Since it's a function that determines whether it's a radio station or not, we need to make it less strict, while preserving the strictness in the GetRadioInfo() function.

---

Type: imp
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Sep 19, 2024
1 parent 0b034df commit 086d730
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions BassBoom.Basolia/Radio/RadioTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static bool IsRadio(string radioUrl, out string streamType)
{
// Check to see if we provided a path
if (string.IsNullOrEmpty(radioUrl))
throw new BasoliaMiscException("Provide a path to a radio station");
return ("", false);
var uri = new Uri(radioUrl);

// Check to see if the radio station exists
Expand All @@ -124,11 +124,11 @@ public static bool IsRadio(string radioUrl, out string streamType)
var reply = await client.GetAsync(radioUrl, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
client.DefaultRequestHeaders.Remove("Icy-MetaData");
if (!reply.IsSuccessStatusCode)
throw new BasoliaMiscException($"This radio station doesn't exist. Error code: {(int)reply.StatusCode} ({reply.StatusCode}).");
return ("", false);

// Check for radio statio and get the MIME type
if (!reply.Headers.Any((kvp) => kvp.Key.StartsWith("icy-")))
throw new BasoliaMiscException("This doesn't look like a radio station. Are you sure?");
return ("", false);
var contentType = reply.Content.Headers.ContentType;
string streamType = contentType.MediaType;

Expand Down

0 comments on commit 086d730

Please sign in to comment.