mirror of
https://github.com/SoPat712/allstarr.git
synced 2026-02-09 23:55:10 -05:00
Fix: Wrap playback request bodies in required field names for Jellyfin
Jellyfin expects playback endpoints to have bodies wrapped:
- /Sessions/Playing -> {"playbackStartInfo": {...}}
- /Sessions/Playing/Progress -> {"playbackProgressInfo": {...}}
- /Sessions/Playing/Stopped -> {"playbackStopInfo": {...}}
This fixes the 'field is required' validation errors.
This commit is contained in:
@@ -256,16 +256,40 @@ public class JellyfinProxyService
|
||||
|
||||
using var request = new HttpRequestMessage(HttpMethod.Post, url);
|
||||
|
||||
// Create content from body string - ALWAYS set content even if empty
|
||||
// Jellyfin expects a body for POST requests, even if it's "{}"
|
||||
var bodyToSend = string.IsNullOrWhiteSpace(body) ? "{}" : body;
|
||||
request.Content = new StringContent(bodyToSend, System.Text.Encoding.UTF8, "application/json");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(body))
|
||||
// Handle special case for playback endpoints - Jellyfin expects wrapped body
|
||||
var bodyToSend = body;
|
||||
if (!string.IsNullOrWhiteSpace(body))
|
||||
{
|
||||
// Check if this is a playback progress endpoint
|
||||
if (endpoint.Contains("Sessions/Playing/Progress", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Wrap the body in playbackProgressInfo field
|
||||
bodyToSend = $"{{\"playbackProgressInfo\":{body}}}";
|
||||
_logger.LogDebug("Wrapped body for playback progress endpoint");
|
||||
}
|
||||
else if (endpoint.Contains("Sessions/Playing/Stopped", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Wrap the body in playbackStopInfo field
|
||||
bodyToSend = $"{{\"playbackStopInfo\":{body}}}";
|
||||
_logger.LogDebug("Wrapped body for playback stopped endpoint");
|
||||
}
|
||||
else if (endpoint.Contains("Sessions/Playing", StringComparison.OrdinalIgnoreCase) &&
|
||||
!endpoint.Contains("Progress", StringComparison.OrdinalIgnoreCase) &&
|
||||
!endpoint.Contains("Stopped", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Wrap the body in playbackStartInfo field for /Sessions/Playing
|
||||
bodyToSend = $"{{\"playbackStartInfo\":{body}}}";
|
||||
_logger.LogDebug("Wrapped body for playback start endpoint");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bodyToSend = "{}";
|
||||
_logger.LogWarning("POST body was empty for {Url}, sending empty JSON object", url);
|
||||
}
|
||||
|
||||
request.Content = new StringContent(bodyToSend, System.Text.Encoding.UTF8, "application/json");
|
||||
|
||||
bool authHeaderAdded = false;
|
||||
|
||||
// Forward authentication headers from client (case-insensitive)
|
||||
|
||||
Reference in New Issue
Block a user