always proxy jellyfin and emby artwork (#323)

This commit is contained in:
Jason Dove
2021-08-01 12:19:50 -05:00
committed by GitHub
parent d5bfd1a254
commit 0f5fee99c6
8 changed files with 45 additions and 12 deletions
+6 -6
View File
@@ -123,12 +123,12 @@ namespace ErsatzTV.Application.MediaCards
if (maybeJellyfin.IsSome && artwork.StartsWith("jellyfin://"))
{
artwork = JellyfinUrl.ForArtwork(maybeJellyfin, artwork)
artwork = JellyfinUrl.RelativeProxyForArtwork(artwork)
.SetQueryParam("fillHeight", 440);
}
else if (maybeEmby.IsSome && artwork.StartsWith("emby://"))
{
artwork = EmbyUrl.ForArtwork(maybeEmby, artwork)
artwork = EmbyUrl.RelativeProxyForArtwork(artwork)
.SetQueryParam("maxHeight", 440);
}
@@ -171,12 +171,12 @@ namespace ErsatzTV.Application.MediaCards
if (maybeJellyfin.IsSome && poster.StartsWith("jellyfin://"))
{
poster = JellyfinUrl.ForArtwork(maybeJellyfin, poster)
poster = JellyfinUrl.RelativeProxyForArtwork(poster)
.SetQueryParam("fillHeight", 440);
}
else if (maybeEmby.IsSome && poster.StartsWith("emby://"))
{
poster = EmbyUrl.ForArtwork(maybeEmby, poster)
poster = EmbyUrl.RelativeProxyForArtwork(poster)
.SetQueryParam("maxHeight", 440);
}
@@ -193,12 +193,12 @@ namespace ErsatzTV.Application.MediaCards
if (maybeJellyfin.IsSome && thumb.StartsWith("jellyfin://"))
{
thumb = JellyfinUrl.ForArtwork(maybeJellyfin, thumb)
thumb = JellyfinUrl.RelativeProxyForArtwork(thumb)
.SetQueryParam("fillHeight", 220);
}
else if (maybeEmby.IsSome && thumb.StartsWith("emby://"))
{
thumb = EmbyUrl.ForArtwork(maybeEmby, thumb)
thumb = EmbyUrl.RelativeProxyForArtwork(thumb)
.SetQueryParam("maxHeight", 220);
}
+2 -2
View File
@@ -66,7 +66,7 @@ namespace ErsatzTV.Application.Movies
if (maybeJellyfin.IsSome && artwork.StartsWith("jellyfin://"))
{
Url url = JellyfinUrl.ForArtwork(maybeJellyfin, artwork);
Url url = JellyfinUrl.RelativeProxyForArtwork(artwork);
if (artworkKind is ArtworkKind.Poster or ArtworkKind.Thumbnail)
{
url.SetQueryParam("fillHeight", 440);
@@ -76,7 +76,7 @@ namespace ErsatzTV.Application.Movies
}
else if (maybeEmby.IsSome && artwork.StartsWith("emby://"))
{
Url url = EmbyUrl.ForArtwork(maybeEmby, artwork);
Url url = EmbyUrl.RelativeProxyForArtwork(artwork);
if (artworkKind is ArtworkKind.Poster or ArtworkKind.Thumbnail)
{
url.SetQueryParam("maxHeight", 440);
+2 -2
View File
@@ -80,7 +80,7 @@ namespace ErsatzTV.Application.Television
if (maybeJellyfin.IsSome && artwork.StartsWith("jellyfin://"))
{
Url url = JellyfinUrl.ForArtwork(maybeJellyfin, artwork);
Url url = JellyfinUrl.RelativeProxyForArtwork(artwork);
if (artworkKind == ArtworkKind.Poster)
{
url.SetQueryParam("fillHeight", 440);
@@ -90,7 +90,7 @@ namespace ErsatzTV.Application.Television
}
else if (maybeEmby.IsSome && artwork.StartsWith("emby://"))
{
Url url = EmbyUrl.ForArtwork(maybeEmby, artwork);
Url url = EmbyUrl.RelativeProxyForArtwork(artwork);
if (artworkKind == ArtworkKind.Poster)
{
url.SetQueryParam("maxHeight", 440);
+16
View File
@@ -63,5 +63,21 @@ namespace ErsatzTV.Core.Emby
.AppendPathSegment(pathSegment)
.SetQueryParams(query);
}
public static Url RelativeProxyForArtwork(string artwork)
{
string[] split = artwork.Replace("emby://", string.Empty).Split('?');
if (split.Length != 2)
{
return artwork;
}
string pathSegment = split[0];
QueryParamCollection query = Url.ParseQueryParams(split[1]);
return Url.Parse("emby")
.AppendPathSegment(pathSegment)
.SetQueryParams(query);
}
}
}
+17
View File
@@ -63,5 +63,22 @@ namespace ErsatzTV.Core.Jellyfin
.AppendPathSegment(pathSegment)
.SetQueryParams(query);
}
public static Url RelativeProxyForArtwork(string artwork)
{
string[] split = artwork.Replace("jellyfin://", string.Empty).Split('?');
if (split.Length != 2)
{
return artwork;
}
string pathSegment = split[0];
QueryParamCollection query = Url.ParseQueryParams(split[1]);
return Url.Parse("jellyfin")
.AppendPathSegment(pathSegment)
.SetQueryParams(query);
}
}
}
@@ -71,6 +71,7 @@ namespace ErsatzTV.Controllers
[HttpGet("/artwork/posters/jellyfin/{*path}")]
[HttpGet("/iptv/artwork/thumbnails/jellyfin/{*path}")]
[HttpGet("/artwork/thumbnails/jellyfin/{*path}")]
[HttpGet("/artwork/fanart/jellyfin/{*path}")]
public Task<IActionResult> GetJellyfin(string path)
{
if (Request.QueryString.HasValue)
@@ -85,6 +86,7 @@ namespace ErsatzTV.Controllers
[HttpGet("/artwork/posters/emby/{*path}")]
[HttpGet("/iptv/artwork/thumbnails/emby/{*path}")]
[HttpGet("/artwork/thumbnails/emby/{*path}")]
[HttpGet("/artwork/fanart/emby/{*path}")]
public Task<IActionResult> GetEmby(string path)
{
if (Request.QueryString.HasValue)
-1
View File
@@ -161,7 +161,6 @@
{
<MediaCard Data="@actor"
Link="@(@$"actor:""{actor.Name.ToLowerInvariant()}""".GetRelativeSearchQuery())"
IsRemoteArtwork="true"
ArtworkKind="ArtworkKind.Thumbnail"/>
}
</MudContainer>
@@ -162,7 +162,6 @@
{
<MediaCard Data="@actor"
Link="@(@$"actor:""{actor.Name.ToLowerInvariant()}""".GetRelativeSearchQuery())"
IsRemoteArtwork="true"
ArtworkKind="ArtworkKind.Thumbnail"/>
}
</MudContainer>