Fix API JSON serialization to return raw strings for client JS
This commit is contained in:
@@ -21,41 +21,43 @@ namespace JellyfinPlugin.Api
|
||||
}
|
||||
|
||||
[HttpGet("CropByPath")]
|
||||
public ActionResult<string> GetCropByPath([FromQuery] string path)
|
||||
[Produces("text/plain")]
|
||||
public ContentResult GetCropByPath([FromQuery] string path)
|
||||
{
|
||||
if (string.IsNullOrEmpty(path)) return Ok(string.Empty);
|
||||
if (string.IsNullOrEmpty(path)) return Content(string.Empty, "text/plain");
|
||||
|
||||
var mode = Plugin.Instance!.Configuration.PlaybackMode;
|
||||
if (mode == "Client") return Ok(string.Empty);
|
||||
if (mode == "Client") return Content(string.Empty, "text/plain");
|
||||
|
||||
var item = _libraryManager.RootFolder.GetRecursiveChildren().FirstOrDefault(x => x.Path == path);
|
||||
|
||||
if (item != null && item.ProviderIds != null && item.ProviderIds.TryGetValue("BlackBarCrop", out string? cropData))
|
||||
{
|
||||
return Ok(cropData ?? string.Empty);
|
||||
return Content(cropData ?? string.Empty, "text/plain");
|
||||
}
|
||||
|
||||
return Ok(string.Empty);
|
||||
return Content(string.Empty, "text/plain");
|
||||
}
|
||||
|
||||
[HttpGet("CropById")]
|
||||
public ActionResult<string> GetCropById([FromQuery] string itemId)
|
||||
[Produces("text/plain")]
|
||||
public ContentResult GetCropById([FromQuery] string itemId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(itemId)) return Ok(string.Empty);
|
||||
if (string.IsNullOrEmpty(itemId)) return Content(string.Empty, "text/plain");
|
||||
|
||||
var mode = Plugin.Instance!.Configuration.PlaybackMode;
|
||||
if (mode == "Server") return Ok(string.Empty);
|
||||
if (mode == "Server") return Content(string.Empty, "text/plain");
|
||||
|
||||
if (Guid.TryParse(itemId, out Guid id))
|
||||
{
|
||||
var item = _libraryManager.GetItemById(id);
|
||||
if (item != null && item.ProviderIds != null && item.ProviderIds.TryGetValue("BlackBarCrop", out string? cropData))
|
||||
{
|
||||
return Ok(cropData ?? string.Empty);
|
||||
return Content(cropData ?? string.Empty, "text/plain");
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(string.Empty);
|
||||
return Content(string.Empty, "text/plain");
|
||||
}
|
||||
|
||||
[HttpGet("ClientScript.js")]
|
||||
|
||||
Reference in New Issue
Block a user