summaryrefslogtreecommitdiff
path: root/SeriesImageProvider.cs
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-12-10 00:56:16 +0100
committerLinnea Gräf <nea@nea.moe>2024-12-10 00:56:16 +0100
commit9a06e4e555fe10edc9df4693e63b07aa6b568ddf (patch)
tree9b4d935ae3f9f52f44723534017e6605cb3d3cc0 /SeriesImageProvider.cs
parent8df43548d451a37a76441986b5620cf84609c59d (diff)
downloadJCoverXtremePro-9a06e4e555fe10edc9df4693e63b07aa6b568ddf.tar.gz
JCoverXtremePro-9a06e4e555fe10edc9df4693e63b07aa6b568ddf.tar.bz2
JCoverXtremePro-9a06e4e555fe10edc9df4693e63b07aa6b568ddf.zip
feat: Add downloader
Diffstat (limited to 'SeriesImageProvider.cs')
-rw-r--r--SeriesImageProvider.cs25
1 files changed, 21 insertions, 4 deletions
diff --git a/SeriesImageProvider.cs b/SeriesImageProvider.cs
index 7f48223..dd0f3b3 100644
--- a/SeriesImageProvider.cs
+++ b/SeriesImageProvider.cs
@@ -1,14 +1,18 @@
-using Microsoft.Extensions.Logging;
+using System.Linq;
namespace Jellyfin.Plugin.JCoverXtremePro;
using System.Collections.Generic;
using System.Net.Http;
+using System.Text.Json;
+using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
+using Jellyfin.Plugin.JCoverXtremePro.Api;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
@@ -26,13 +30,14 @@ public class SeriesImageProvider
{
return
[
+ // Note: update JCoverSharedController if more image types are supported
ImageType.Primary
];
}
public async Task<IEnumerable<RemoteImageInfo>> GetImages(BaseItem item, CancellationToken cancellationToken)
{
- // TODO: hadnle episodes
+ // TODO: handle specific episodes directly
if (item is Series series)
{
return await HandleSeries(series, cancellationToken);
@@ -51,8 +56,20 @@ public class SeriesImageProvider
var metadata = await MediuxDownloader.instance.GetMediuxMetadata("https://mediux.pro/shows/" + tmdbId)
.ConfigureAwait(false);
- Plugin.Logger.LogInformation("JSON: " + metadata);
- return [];
+ var show = JsonSerializer.Deserialize<POJO.ShowData>(metadata as JsonObject)!;
+
+ return from set in show.sets
+ let representativeImage = set.files.Find(it => it.fileType is "poster" or "title_card")!
+ let enrichedUrl = JCoverSharedController.PackSetInfo(representativeImage.downloadUrl, series, set)
+ select new RemoteImageInfo
+ {
+ Url = enrichedUrl,
+ ProviderName = set.user_created.username + " (via Mediux)",
+ ThumbnailUrl = enrichedUrl, // TODO: use generated thumbnails from /_next/image?url=
+ Language = "en",
+ RatingType = RatingType.Likes,
+ Type = representativeImage.JellyFinFileType().Value
+ };
}
public Task<HttpResponseMessage> GetImageResponse(string url, CancellationToken cancellationToken)