From 0af5e600946231df73f1783330ad8cd0bbbed2ee Mon Sep 17 00:00:00 2001
From: Joe Rogers <1337joe@gmail.com>
Date: Mon, 22 Nov 2021 21:08:07 +0100
Subject: [PATCH] Address review comments
Store null instead of calculating scaled image sizes.
Add endpoint to provide TMDb image size options.
---
.../Plugins/Tmdb/Api/TmdbController.cs | 41 +++++++++++
.../Tmdb/Configuration/PluginConfiguration.cs | 21 ------
.../Plugins/Tmdb/Configuration/config.html | 59 ++++++++++-----
.../Plugins/Tmdb/TmdbClientManager.cs | 71 ++++++-------------
4 files changed, 104 insertions(+), 88 deletions(-)
create mode 100644 MediaBrowser.Providers/Plugins/Tmdb/Api/TmdbController.cs
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Api/TmdbController.cs b/MediaBrowser.Providers/Plugins/Tmdb/Api/TmdbController.cs
new file mode 100644
index 0000000000..0bab7c3cad
--- /dev/null
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Api/TmdbController.cs
@@ -0,0 +1,41 @@
+using System.Net.Mime;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using TMDbLib.Objects.General;
+
+namespace MediaBrowser.Providers.Plugins.Tmdb.Api
+{
+ ///
+ /// The TMDb api controller.
+ ///
+ [ApiController]
+ [Authorize(Policy = "DefaultAuthorization")]
+ [Route("[controller]")]
+ [Produces(MediaTypeNames.Application.Json)]
+ public class TmdbController : ControllerBase
+ {
+ private readonly TmdbClientManager _tmdbClientManager;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The TMDb client manager.
+ public TmdbController(TmdbClientManager tmdbClientManager)
+ {
+ _tmdbClientManager = tmdbClientManager;
+ }
+
+ ///
+ /// Gets the TMDb image configuration options.
+ ///
+ /// The image portion of the TMDb client configuration.
+ [HttpGet("ClientConfiguration")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ public async Task TmdbClientConfiguration()
+ {
+ return (await _tmdbClientManager.GetClientConfiguration().ConfigureAwait(false)).Images;
+ }
+ }
+}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs
index b043da76ca..dec7961484 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/PluginConfiguration.cs
@@ -1,4 +1,3 @@
-using System.Collections.Generic;
using MediaBrowser.Model.Plugins;
namespace MediaBrowser.Providers.Plugins.Tmdb
@@ -33,39 +32,19 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
///
public string? PosterSize { get; set; }
- ///
- /// Gets or sets the available options for poster size.
- ///
- public List PosterSizeOptions { get; set; } = new List();
-
///
/// Gets or sets a value indicating the backdrop image size to fetch.
///
public string? BackdropSize { get; set; }
- ///
- /// Gets or sets the available options for backdrop size.
- ///
- public List BackdropSizeOptions { get; set; } = new List();
-
///
/// Gets or sets a value indicating the profile image size to fetch.
///
public string? ProfileSize { get; set; }
- ///
- /// Gets or sets the available options for profile size.
- ///
- public List ProfileSizeOptions { get; set; } = new List();
-
///
/// Gets or sets a value indicating the still image size to fetch.
///
public string? StillSize { get; set; }
-
- ///
- /// Gets or sets the available options for still size.
- ///
- public List StillSizeOptions { get; set; } = new List();
}
}
diff --git a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html
index d376df96cc..52693795b5 100644
--- a/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html
+++ b/MediaBrowser.Providers/Plugins/Tmdb/Configuration/config.html
@@ -26,7 +26,6 @@