Yandex Music metadata plugin for Jellyfin 12.4
This commit is contained in:
commit
c3dc901337
25 files changed
+3233
No files matched your search
@@ -0,0 +1,26 @@
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using Jellyfin.Plugin.YandexMusic.Yandex;
|
||||
|
||||
namespace Jellyfin.Plugin.YandexMusic.Providers;
|
||||
|
||||
/// <summary>Creates image responses for search results.</summary>
|
||||
internal static class ImageResponseFactory
|
||||
{
|
||||
/// <summary>Downloads an image and wraps it into an HTTP response.</summary>
|
||||
public static async Task<HttpResponseMessage> FromUrlAsync(
|
||||
YandexMusicClient client,
|
||||
string url,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
var bytes = await client.GetImageBytesAsync(url, cancellationToken).ConfigureAwait(false);
|
||||
if (bytes is null)
|
||||
{
|
||||
return new HttpResponseMessage(HttpStatusCode.NotFound);
|
||||
}
|
||||
|
||||
var content = new ByteArrayContent(bytes);
|
||||
content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
|
||||
return new HttpResponseMessage(HttpStatusCode.OK) { Content = content };
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user