diff --git a/octo-fiesta/Controllers/SubSonicController.cs b/octo-fiesta/Controllers/SubSonicController.cs
index 30a8270..04a89f6 100644
--- a/octo-fiesta/Controllers/SubSonicController.cs
+++ b/octo-fiesta/Controllers/SubSonicController.cs
@@ -426,22 +426,17 @@ public class SubsonicController : ControllerBase
.Concat(externalResult.Artists.Select(a => ConvertArtistToSubsonicJson(a)))
.ToList();
- var response = new
+ return CreateSubsonicJsonResponse(new
{
- subsonicResponse = new
+ status = "ok",
+ version = "1.16.1",
+ searchResult3 = new
{
- status = "ok",
- version = "1.16.1",
- searchResult3 = new
- {
- song = mergedSongs,
- album = mergedAlbums,
- artist = mergedArtists
- }
+ song = mergedSongs,
+ album = mergedAlbums,
+ artist = mergedArtists
}
- };
-
- return Ok(response);
+ });
}
else
{
@@ -604,11 +599,23 @@ public class SubsonicController : ControllerBase
);
}
+ ///
+ /// Crée une réponse JSON Subsonic avec la clé "subsonic-response" (avec tiret)
+ ///
+ private IActionResult CreateSubsonicJsonResponse(object responseContent)
+ {
+ var response = new Dictionary
+ {
+ ["subsonic-response"] = responseContent
+ };
+ return new JsonResult(response);
+ }
+
private IActionResult CreateSubsonicResponse(string format, string elementName, object data)
{
if (format == "json")
{
- return Ok(new { subsonicResponse = new { status = "ok", version = "1.16.1" } });
+ return CreateSubsonicJsonResponse(new { status = "ok", version = "1.16.1" });
}
var ns = XNamespace.Get("http://subsonic.org/restapi");
@@ -626,14 +633,11 @@ public class SubsonicController : ControllerBase
{
if (format == "json")
{
- return Ok(new
+ return CreateSubsonicJsonResponse(new
{
- subsonicResponse = new
- {
- status = "failed",
- version = "1.16.1",
- error = new { code, message }
- }
+ status = "failed",
+ version = "1.16.1",
+ error = new { code, message }
});
}
@@ -655,14 +659,11 @@ public class SubsonicController : ControllerBase
{
if (format == "json")
{
- return Ok(new
+ return CreateSubsonicJsonResponse(new
{
- subsonicResponse = new
- {
- status = "ok",
- version = "1.16.1",
- song = ConvertSongToSubsonicJson(song)
- }
+ status = "ok",
+ version = "1.16.1",
+ song = ConvertSongToSubsonicJson(song)
});
}
@@ -681,24 +682,21 @@ public class SubsonicController : ControllerBase
{
if (format == "json")
{
- return Ok(new
+ return CreateSubsonicJsonResponse(new
{
- subsonicResponse = new
- {
- status = "ok",
- version = "1.16.1",
- album = new
- {
- id = album.Id,
- name = album.Title,
- artist = album.Artist,
- artistId = album.ArtistId,
- songCount = album.SongCount ?? 0,
- year = album.Year ?? 0,
- coverArt = album.Id,
- song = album.Songs.Select(s => ConvertSongToSubsonicJson(s)).ToList()
- }
- }
+ status = "ok",
+ version = "1.16.1",
+ album = new
+ {
+ id = album.Id,
+ name = album.Title,
+ artist = album.Artist,
+ artistId = album.ArtistId,
+ songCount = album.SongCount ?? 0,
+ year = album.Year ?? 0,
+ coverArt = album.Id,
+ song = album.Songs.Select(s => ConvertSongToSubsonicJson(s)).ToList()
+ }
});
}
diff --git a/package-lock.json b/package-lock.json
new file mode 100644
index 0000000..03f0c22
--- /dev/null
+++ b/package-lock.json
@@ -0,0 +1,6 @@
+{
+ "name": "octo-fiesta",
+ "lockfileVersion": 3,
+ "requires": true,
+ "packages": {}
+}