mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
fix: use correct 'subsonic-response' key format in JSON responses
ASP.NET Core serializes anonymous objects with camelCase, producing 'subsonicResponse' instead of 'subsonic-response'. Fixed by using Dictionary with explicit key names for all JSON responses.
This commit is contained in:
@@ -426,22 +426,17 @@ public class SubsonicController : ControllerBase
|
|||||||
.Concat(externalResult.Artists.Select(a => ConvertArtistToSubsonicJson(a)))
|
.Concat(externalResult.Artists.Select(a => ConvertArtistToSubsonicJson(a)))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var response = new
|
return CreateSubsonicJsonResponse(new
|
||||||
{
|
{
|
||||||
subsonicResponse = new
|
status = "ok",
|
||||||
|
version = "1.16.1",
|
||||||
|
searchResult3 = new
|
||||||
{
|
{
|
||||||
status = "ok",
|
song = mergedSongs,
|
||||||
version = "1.16.1",
|
album = mergedAlbums,
|
||||||
searchResult3 = new
|
artist = mergedArtists
|
||||||
{
|
|
||||||
song = mergedSongs,
|
|
||||||
album = mergedAlbums,
|
|
||||||
artist = mergedArtists
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
return Ok(response);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -604,11 +599,23 @@ public class SubsonicController : ControllerBase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Crée une réponse JSON Subsonic avec la clé "subsonic-response" (avec tiret)
|
||||||
|
/// </summary>
|
||||||
|
private IActionResult CreateSubsonicJsonResponse(object responseContent)
|
||||||
|
{
|
||||||
|
var response = new Dictionary<string, object>
|
||||||
|
{
|
||||||
|
["subsonic-response"] = responseContent
|
||||||
|
};
|
||||||
|
return new JsonResult(response);
|
||||||
|
}
|
||||||
|
|
||||||
private IActionResult CreateSubsonicResponse(string format, string elementName, object data)
|
private IActionResult CreateSubsonicResponse(string format, string elementName, object data)
|
||||||
{
|
{
|
||||||
if (format == "json")
|
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");
|
var ns = XNamespace.Get("http://subsonic.org/restapi");
|
||||||
@@ -626,14 +633,11 @@ public class SubsonicController : ControllerBase
|
|||||||
{
|
{
|
||||||
if (format == "json")
|
if (format == "json")
|
||||||
{
|
{
|
||||||
return Ok(new
|
return CreateSubsonicJsonResponse(new
|
||||||
{
|
{
|
||||||
subsonicResponse = new
|
status = "failed",
|
||||||
{
|
version = "1.16.1",
|
||||||
status = "failed",
|
error = new { code, message }
|
||||||
version = "1.16.1",
|
|
||||||
error = new { code, message }
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -655,14 +659,11 @@ public class SubsonicController : ControllerBase
|
|||||||
{
|
{
|
||||||
if (format == "json")
|
if (format == "json")
|
||||||
{
|
{
|
||||||
return Ok(new
|
return CreateSubsonicJsonResponse(new
|
||||||
{
|
{
|
||||||
subsonicResponse = new
|
status = "ok",
|
||||||
{
|
version = "1.16.1",
|
||||||
status = "ok",
|
song = ConvertSongToSubsonicJson(song)
|
||||||
version = "1.16.1",
|
|
||||||
song = ConvertSongToSubsonicJson(song)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -681,24 +682,21 @@ public class SubsonicController : ControllerBase
|
|||||||
{
|
{
|
||||||
if (format == "json")
|
if (format == "json")
|
||||||
{
|
{
|
||||||
return Ok(new
|
return CreateSubsonicJsonResponse(new
|
||||||
{
|
{
|
||||||
subsonicResponse = new
|
status = "ok",
|
||||||
{
|
version = "1.16.1",
|
||||||
status = "ok",
|
album = new
|
||||||
version = "1.16.1",
|
{
|
||||||
album = new
|
id = album.Id,
|
||||||
{
|
name = album.Title,
|
||||||
id = album.Id,
|
artist = album.Artist,
|
||||||
name = album.Title,
|
artistId = album.ArtistId,
|
||||||
artist = album.Artist,
|
songCount = album.SongCount ?? 0,
|
||||||
artistId = album.ArtistId,
|
year = album.Year ?? 0,
|
||||||
songCount = album.SongCount ?? 0,
|
coverArt = album.Id,
|
||||||
year = album.Year ?? 0,
|
song = album.Songs.Select(s => ConvertSongToSubsonicJson(s)).ToList()
|
||||||
coverArt = album.Id,
|
}
|
||||||
song = album.Songs.Select(s => ConvertSongToSubsonicJson(s)).ToList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "octo-fiesta",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user