|
|
|
|
@ -73,6 +73,32 @@ namespace ErsatzTV.Controllers
@@ -73,6 +73,32 @@ namespace ErsatzTV.Controllers
|
|
|
|
|
response.Content.Headers.ContentType?.MediaType ?? "image/jpeg"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[HttpGet("/artwork/fanart/plex/{plexMediaSourceId}/{*path}")] |
|
|
|
|
public async Task<IActionResult> GetPlexFanArt(int plexMediaSourceId, string path) |
|
|
|
|
{ |
|
|
|
|
Either<BaseError, PlexConnectionParametersViewModel> connectionParameters = |
|
|
|
|
await _mediator.Send(new GetPlexConnectionParameters(plexMediaSourceId)); |
|
|
|
|
|
|
|
|
|
return await connectionParameters.Match<Task<IActionResult>>( |
|
|
|
|
Left: _ => new NotFoundResult().AsTask<IActionResult>(), |
|
|
|
|
Right: async r => |
|
|
|
|
{ |
|
|
|
|
HttpClient client = _httpClientFactory.CreateClient(); |
|
|
|
|
client.DefaultRequestHeaders.Add("X-Plex-Token", r.AuthToken); |
|
|
|
|
|
|
|
|
|
var transcodePath = $"/{path}"; |
|
|
|
|
var fullPath = new Uri(r.Uri, transcodePath); |
|
|
|
|
HttpResponseMessage response = await client.GetAsync( |
|
|
|
|
fullPath, |
|
|
|
|
HttpCompletionOption.ResponseHeadersRead); |
|
|
|
|
Stream stream = await response.Content.ReadAsStreamAsync(); |
|
|
|
|
|
|
|
|
|
return new FileStreamResult( |
|
|
|
|
stream, |
|
|
|
|
response.Content.Headers.ContentType?.MediaType ?? "image/jpeg"); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[HttpGet("/artwork/thumbnails/{fileName}")] |
|
|
|
|
public async Task<IActionResult> GetThumbnail(string fileName) |
|
|
|
|
|