fix(lautfm): send track searches to the Radioadmin search host
Radioadmin reads its track search host from client/_/config.json, which names search.api.radioadmin.laut.fm. The provider asked api.radioadmin.laut.fm instead, so the laut.fm library stayed empty. Refs #15 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
816b902aca
commit
7a9ba99a27
3 files changed
+7
-4
No files matched your search
@@ -141,7 +141,7 @@ Password and token are stored in `settings.json` encrypted with Windows DPAPI fo
|
|||||||
|
|
||||||
Risks:
|
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.
|
- 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.
|
- 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.
|
- 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.
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ public class LautFmProvider(HttpClient http, Func<AppSettings> settings) : IMusi
|
|||||||
{
|
{
|
||||||
public const string ApiBase = "https://api.radioadmin.laut.fm/";
|
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 string Name => "laut.fm";
|
||||||
|
|
||||||
public bool IsAvailable => settings().LautFmEnabled;
|
public bool IsAvailable => settings().LautFmEnabled;
|
||||||
@@ -28,7 +31,7 @@ public class LautFmProvider(HttpClient http, Func<AppSettings> settings) : IMusi
|
|||||||
return [];
|
return [];
|
||||||
|
|
||||||
// The API filters one field at a time, so title and artist are two searches.
|
// 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(
|
var results = await Task.WhenAll(
|
||||||
SearchFieldAsync($"{url}title={Uri.EscapeDataString(words)}", current.LautFmToken, cancellationToken),
|
SearchFieldAsync($"{url}title={Uri.EscapeDataString(words)}", current.LautFmToken, cancellationToken),
|
||||||
SearchFieldAsync($"{url}artist={Uri.EscapeDataString(words)}", current.LautFmToken, cancellationToken));
|
SearchFieldAsync($"{url}artist={Uri.EscapeDataString(words)}", current.LautFmToken, cancellationToken));
|
||||||
|
|||||||
@@ -198,8 +198,8 @@ public sealed class LautFmTests : IDisposable
|
|||||||
Assert.Equal("https://api.radioadmin.laut.fm/tracks/7/prelisten", track.Url);
|
Assert.Equal("https://api.radioadmin.laut.fm/tracks/7/prelisten", track.Url);
|
||||||
Assert.Equal(2, requests.Count);
|
Assert.Equal(2, requests.Count);
|
||||||
Assert.All(requests, r => Assert.Equal("Bearer geheimer-token", r.Headers.Authorization!.ToString()));
|
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://search.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?artist=Sommer");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|||||||
Reference in new issue
Block a user