diff --git a/README.md b/README.md index ce32bd8..65ee5ef 100644 --- a/README.md +++ b/README.md @@ -141,7 +141,7 @@ Password and token are stored in `settings.json` encrypted with Windows DPAPI fo Risks: -- The library uses the API behind Radioadmin (`api.radioadmin.laut.fm`). laut.fm does not publish it for other programs, so it can change or stop working without notice, and the token expires when Radioadmin logs out. +- The library uses the API behind Radioadmin (`search.api.radioadmin.laut.fm`). laut.fm does not publish it for other programs, so it can change or stop working without notice, and the token expires when Radioadmin logs out. - The import downloads the prelisten link that Radioadmin uses. Whether that is the full track or a shorter preview has not been checked against a real station. - laut.fm licenses the station's music for broadcasting on laut.fm. Imported laut.fm tracks are marked with that license and must not be played anywhere else. - Nothing here has been tested against a real laut.fm account. The tests run against a local fake server. If laut.fm expects a different format or login method, the settings show the error but do not adapt. diff --git a/src/Radiosender/Services/LautFmProvider.cs b/src/Radiosender/Services/LautFmProvider.cs index c42af9a..9b7294d 100644 --- a/src/Radiosender/Services/LautFmProvider.cs +++ b/src/Radiosender/Services/LautFmProvider.cs @@ -13,6 +13,9 @@ public class LautFmProvider(HttpClient http, Func settings) : IMusi { public const string ApiBase = "https://api.radioadmin.laut.fm/"; + // Radioadmin sends track searches to its own host ("searchHost" in radioadmin.laut.fm/client/_/config.json). + public const string SearchBase = "https://search.api.radioadmin.laut.fm/"; + public string Name => "laut.fm"; public bool IsAvailable => settings().LautFmEnabled; @@ -28,7 +31,7 @@ public class LautFmProvider(HttpClient http, Func settings) : IMusi return []; // The API filters one field at a time, so title and artist are two searches. - var url = $"{ApiBase}stations/{Uri.EscapeDataString(station)}/tracks?"; + var url = $"{SearchBase}stations/{Uri.EscapeDataString(station)}/tracks?"; var results = await Task.WhenAll( SearchFieldAsync($"{url}title={Uri.EscapeDataString(words)}", current.LautFmToken, cancellationToken), SearchFieldAsync($"{url}artist={Uri.EscapeDataString(words)}", current.LautFmToken, cancellationToken)); diff --git a/tests/Radiosender.Tests/LautFmTests.cs b/tests/Radiosender.Tests/LautFmTests.cs index a667dd5..2165b32 100644 --- a/tests/Radiosender.Tests/LautFmTests.cs +++ b/tests/Radiosender.Tests/LautFmTests.cs @@ -198,8 +198,8 @@ public sealed class LautFmTests : IDisposable Assert.Equal("https://api.radioadmin.laut.fm/tracks/7/prelisten", track.Url); Assert.Equal(2, requests.Count); Assert.All(requests, r => Assert.Equal("Bearer geheimer-token", r.Headers.Authorization!.ToString())); - Assert.Contains(requests, r => r.RequestUri!.AbsoluteUri == "https://api.radioadmin.laut.fm/stations/123/tracks?title=Sommer"); - Assert.Contains(requests, r => r.RequestUri!.AbsoluteUri == "https://api.radioadmin.laut.fm/stations/123/tracks?artist=Sommer"); + Assert.Contains(requests, r => r.RequestUri!.AbsoluteUri == "https://search.api.radioadmin.laut.fm/stations/123/tracks?title=Sommer"); + Assert.Contains(requests, r => r.RequestUri!.AbsoluteUri == "https://search.api.radioadmin.laut.fm/stations/123/tracks?artist=Sommer"); } [Fact]