private string GetArtworkUrl(Artwork artwork, ArtworkKind artworkKind) { string artworkPath = artwork.Path; int height = artworkKind switch { ArtworkKind.Thumbnail => 220, _ => 440 }; if (artworkPath.StartsWith("jellyfin://")) { artworkPath = JellyfinUrl.ProxyForArtwork(_scheme, _host, artworkPath, artworkKind) .SetQueryParam("fillHeight", height); } else if (artworkPath.StartsWith("emby://")) { artworkPath = EmbyUrl.ProxyForArtwork(_scheme, _host, artworkPath, artworkKind) .SetQueryParam("maxHeight", height); } else { string artworkFolder = artworkKind switch { ArtworkKind.Thumbnail => "thumbnails", _ => "posters" }; artworkPath = $"{_scheme}://{_host}/iptv/artwork/{artworkFolder}/{artwork.Path}.jpg"; } return(artworkPath); }
private static string Artwork( Metadata metadata, ArtworkKind artworkKind, Option <JellyfinMediaSource> maybeJellyfin, Option <EmbyMediaSource> maybeEmby) { string artwork = Optional(metadata.Artwork.FirstOrDefault(a => a.ArtworkKind == artworkKind)) .Match(a => a.Path, string.Empty); if (maybeJellyfin.IsSome && artwork.StartsWith("jellyfin://")) { Url url = JellyfinUrl.RelativeProxyForArtwork(artwork); if (artworkKind is ArtworkKind.Poster or ArtworkKind.Thumbnail) { url.SetQueryParam("fillHeight", 440); } artwork = url; } else if (maybeEmby.IsSome && artwork.StartsWith("emby://")) { Url url = EmbyUrl.RelativeProxyForArtwork(artwork); if (artworkKind is ArtworkKind.Poster or ArtworkKind.Thumbnail) { url.SetQueryParam("maxHeight", 440); } artwork = url; } return(artwork); }
private async Task <IActionResult> GetEmbyArtwork(string path, CancellationToken cancellationToken) { Either <BaseError, EmbyConnectionParametersViewModel> connectionParameters = await _mediator.Send(new GetEmbyConnectionParameters(), cancellationToken); return(await connectionParameters.Match <Task <IActionResult> >( Left : _ => new NotFoundResult().AsTask <IActionResult>(), Right : async vm => { HttpClient client = _httpClientFactory.CreateClient(); Url fullPath = EmbyUrl.ForArtwork(vm.Address, path); HttpResponseMessage response = await client.GetAsync( fullPath, HttpCompletionOption.ResponseHeadersRead, cancellationToken); Stream stream = await response.Content.ReadAsStreamAsync(cancellationToken); return new FileStreamResult( stream, response.Content.Headers.ContentType?.MediaType ?? "image/jpeg"); })); }