mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-30 20:38:27 +01:00
Merge branch 'support-external-audio-files' of github.com:jonas-resch/jellyfin into support-external-audio-files
This commit is contained in:
@@ -39,20 +39,12 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
IHasItemChangeMonitor
|
||||
{
|
||||
private readonly ILogger<FFProbeProvider> _logger;
|
||||
private readonly IMediaEncoder _mediaEncoder;
|
||||
private readonly IItemRepository _itemRepo;
|
||||
private readonly IBlurayExaminer _blurayExaminer;
|
||||
private readonly ILocalizationManager _localization;
|
||||
private readonly IEncodingManager _encodingManager;
|
||||
private readonly IServerConfigurationManager _config;
|
||||
private readonly ISubtitleManager _subtitleManager;
|
||||
private readonly IChapterManager _chapterManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
private readonly SubtitleResolver _subtitleResolver;
|
||||
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
|
||||
private readonly NamingOptions _namingOptions;
|
||||
private readonly AudioResolver _audioResolver;
|
||||
private readonly FFProbeVideoInfo _videoProber;
|
||||
private readonly FFProbeAudioInfo _audioProber;
|
||||
|
||||
private readonly Task<ItemUpdateType> _cachedTask = Task.FromResult(ItemUpdateType.None);
|
||||
|
||||
public FFProbeProvider(
|
||||
ILogger<FFProbeProvider> logger,
|
||||
@@ -69,20 +61,21 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
NamingOptions namingOptions)
|
||||
{
|
||||
_logger = logger;
|
||||
_mediaEncoder = mediaEncoder;
|
||||
_itemRepo = itemRepo;
|
||||
_blurayExaminer = blurayExaminer;
|
||||
_localization = localization;
|
||||
_encodingManager = encodingManager;
|
||||
_config = config;
|
||||
_subtitleManager = subtitleManager;
|
||||
_chapterManager = chapterManager;
|
||||
_libraryManager = libraryManager;
|
||||
_mediaSourceManager = mediaSourceManager;
|
||||
_namingOptions = namingOptions;
|
||||
|
||||
_audioResolver = new AudioResolver(localization, mediaEncoder, namingOptions);
|
||||
_subtitleResolver = new SubtitleResolver(BaseItem.LocalizationManager);
|
||||
_audioResolver = new AudioResolver(_localization, _mediaEncoder, namingOptions);
|
||||
_videoProber = new FFProbeVideoInfo(
|
||||
_logger,
|
||||
mediaSourceManager,
|
||||
mediaEncoder,
|
||||
itemRepo,
|
||||
blurayExaminer,
|
||||
localization,
|
||||
encodingManager,
|
||||
config,
|
||||
subtitleManager,
|
||||
chapterManager,
|
||||
libraryManager);
|
||||
_audioProber = new FFProbeAudioInfo(mediaSourceManager, mediaEncoder, itemRepo, libraryManager);
|
||||
}
|
||||
|
||||
public string Name => "ffprobe";
|
||||
@@ -190,21 +183,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
FetchShortcutInfo(item);
|
||||
}
|
||||
|
||||
var prober = new FFProbeVideoInfo(
|
||||
_logger,
|
||||
_mediaSourceManager,
|
||||
_mediaEncoder,
|
||||
_itemRepo,
|
||||
_blurayExaminer,
|
||||
_localization,
|
||||
_encodingManager,
|
||||
_config,
|
||||
_subtitleManager,
|
||||
_chapterManager,
|
||||
_libraryManager,
|
||||
_audioResolver);
|
||||
|
||||
return prober.ProbeVideo(item, options, cancellationToken);
|
||||
return _videoProber.ProbeVideo(item, options, cancellationToken);
|
||||
}
|
||||
|
||||
private string NormalizeStrmLine(string line)
|
||||
@@ -240,9 +219,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||
FetchShortcutInfo(item);
|
||||
}
|
||||
|
||||
var prober = new FFProbeAudioInfo(_mediaSourceManager, _mediaEncoder, _itemRepo, _libraryManager);
|
||||
|
||||
return prober.Probe(item, options, cancellationToken);
|
||||
return _audioProber.Probe(item, options, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
MediaBrowser.Providers/Plugins/Tmdb/Api/TmdbController.cs
Normal file
41
MediaBrowser.Providers/Plugins/Tmdb/Api/TmdbController.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// The TMDb api controller.
|
||||
/// </summary>
|
||||
[ApiController]
|
||||
[Authorize(Policy = "DefaultAuthorization")]
|
||||
[Route("[controller]")]
|
||||
[Produces(MediaTypeNames.Application.Json)]
|
||||
public class TmdbController : ControllerBase
|
||||
{
|
||||
private readonly TmdbClientManager _tmdbClientManager;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TmdbController"/> class.
|
||||
/// </summary>
|
||||
/// <param name="tmdbClientManager">The TMDb client manager.</param>
|
||||
public TmdbController(TmdbClientManager tmdbClientManager)
|
||||
{
|
||||
_tmdbClientManager = tmdbClientManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the TMDb image configuration options.
|
||||
/// </summary>
|
||||
/// <returns>The image portion of the TMDb client configuration.</returns>
|
||||
[HttpGet("ClientConfiguration")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
public async Task<ConfigImageTypes> TmdbClientConfiguration()
|
||||
{
|
||||
return (await _tmdbClientManager.GetClientConfiguration().ConfigureAwait(false)).Images;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,5 +26,25 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// Gets or sets a value indicating the maximum number of cast members to fetch for an item.
|
||||
/// </summary>
|
||||
public int MaxCastMembers { get; set; } = 15;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the poster image size to fetch.
|
||||
/// </summary>
|
||||
public string? PosterSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the backdrop image size to fetch.
|
||||
/// </summary>
|
||||
public string? BackdropSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the profile image size to fetch.
|
||||
/// </summary>
|
||||
public string? ProfileSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the still image size to fetch.
|
||||
/// </summary>
|
||||
public string? StillSize { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,21 @@
|
||||
<input is="emby-input" type="number" id="maxCastMembers" pattern="[0-9]*" required min="0" max="1000" label="Max Cast Members" />
|
||||
<div class="fieldDescription">The maximum number of cast members to fetch for an item.</div>
|
||||
</div>
|
||||
<br />
|
||||
<div class="verticalSection verticalSection-extrabottompadding">
|
||||
<h2>Image Scaling</h2>
|
||||
<div class="selectContainer">
|
||||
<select is="emby-select" id="selectPosterSize" label="Poster"></select>
|
||||
</div>
|
||||
<div class="selectContainer">
|
||||
<select is="emby-select" id="selectBackdropSize" label="Backdrop"></select>
|
||||
</div>
|
||||
<div class="selectContainer">
|
||||
<select is="emby-select" id="selectProfileSize" label="Profile"></select>
|
||||
</div>
|
||||
<div class="selectContainer">
|
||||
<select is="emby-select" id="selectStillSize" label="Still"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<button is="emby-button" type="submit" class="raised button-submit block"><span>Save</span></button>
|
||||
</div>
|
||||
@@ -39,6 +53,47 @@
|
||||
document.querySelector('.configPage')
|
||||
.addEventListener('pageshow', function () {
|
||||
Dashboard.showLoadingMsg();
|
||||
|
||||
var clientConfig, pluginConfig;
|
||||
var configureImageScaling = function() {
|
||||
if (clientConfig === null || pluginConfig === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var sizeOptionsGenerator = function (size) {
|
||||
return '<option value="' + size + '">' + size + '</option>';
|
||||
}
|
||||
|
||||
var selPosterSize = document.querySelector('#selectPosterSize');
|
||||
selPosterSize.innerHTML = clientConfig.PosterSizes.map(sizeOptionsGenerator);
|
||||
selPosterSize.value = pluginConfig.PosterSize;
|
||||
|
||||
var selBackdropSize = document.querySelector('#selectBackdropSize');
|
||||
selBackdropSize.innerHTML = clientConfig.BackdropSizes.map(sizeOptionsGenerator);
|
||||
selBackdropSize.value = pluginConfig.BackdropSize;
|
||||
|
||||
var selProfileSize = document.querySelector('#selectProfileSize');
|
||||
selProfileSize.innerHTML = clientConfig.ProfileSizes.map(sizeOptionsGenerator);
|
||||
selProfileSize.value = pluginConfig.ProfileSize;
|
||||
|
||||
var selStillSize = document.querySelector('#selectStillSize');
|
||||
selStillSize.innerHTML = clientConfig.StillSizes.map(sizeOptionsGenerator);
|
||||
selStillSize.value = pluginConfig.StillSize;
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
}
|
||||
|
||||
const request = {
|
||||
url: ApiClient.getUrl('tmdb/ClientConfiguration'),
|
||||
dataType: 'json',
|
||||
type: 'GET',
|
||||
headers: { accept: 'application/json' }
|
||||
}
|
||||
ApiClient.fetch(request).then(function (config) {
|
||||
clientConfig = config;
|
||||
configureImageScaling();
|
||||
});
|
||||
|
||||
ApiClient.getPluginConfiguration(PluginConfig.pluginId).then(function (config) {
|
||||
document.querySelector('#includeAdult').checked = config.IncludeAdult;
|
||||
document.querySelector('#excludeTagsSeries').checked = config.ExcludeTagsSeries;
|
||||
@@ -51,7 +106,8 @@
|
||||
cancelable: false
|
||||
}));
|
||||
|
||||
Dashboard.hideLoadingMsg();
|
||||
pluginConfig = config;
|
||||
configureImageScaling();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,6 +121,10 @@
|
||||
config.ExcludeTagsSeries = document.querySelector('#excludeTagsSeries').checked;
|
||||
config.ExcludeTagsMovies = document.querySelector('#excludeTagsMovies').checked;
|
||||
config.MaxCastMembers = document.querySelector('#maxCastMembers').value;
|
||||
config.PosterSize = document.querySelector('#selectPosterSize').value;
|
||||
config.BackdropSize = document.querySelector('#selectBackdropSize').value;
|
||||
config.ProfileSize = document.querySelector('#selectProfileSize').value;
|
||||
config.StillSize = document.querySelector('#selectStillSize').value;
|
||||
ApiClient.updatePluginConfiguration(PluginConfig.pluginId, config).then(Dashboard.processPluginConfigurationUpdateResult);
|
||||
});
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
return null;
|
||||
}
|
||||
|
||||
return _tmDbClient.GetImageUrl(size, path).ToString();
|
||||
return _tmDbClient.GetImageUrl(size, path, true).ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -508,7 +508,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <returns>The absolute URL.</returns>
|
||||
public string GetPosterUrl(string posterPath)
|
||||
{
|
||||
return GetUrl(_tmDbClient.Config.Images.PosterSizes[^1], posterPath);
|
||||
return GetUrl(Plugin.Instance.Configuration.PosterSize, posterPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -518,7 +518,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <returns>The absolute URL.</returns>
|
||||
public string GetProfileUrl(string actorProfilePath)
|
||||
{
|
||||
return GetUrl(_tmDbClient.Config.Images.ProfileSizes[^1], actorProfilePath);
|
||||
return GetUrl(Plugin.Instance.Configuration.ProfileSize, actorProfilePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -529,7 +529,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertPostersToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.PosterSizes[^1], ImageType.Primary, requestLanguage, results);
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.PosterSize, ImageType.Primary, requestLanguage, results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -540,7 +540,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertBackdropsToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.BackdropSizes[^1], ImageType.Backdrop, requestLanguage, results);
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.BackdropSize, ImageType.Backdrop, requestLanguage, results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -551,7 +551,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertProfilesToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.ProfileSizes[^1], ImageType.Primary, requestLanguage, results);
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.ProfileSize, ImageType.Primary, requestLanguage, results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -562,7 +562,7 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
public void ConvertStillsToRemoteImageInfo(List<ImageData> images, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
ConvertToRemoteImageInfo(images, _tmDbClient.Config.Images.StillSizes[^1], ImageType.Primary, requestLanguage, results);
|
||||
ConvertToRemoteImageInfo(images, Plugin.Instance.Configuration.StillSize, ImageType.Primary, requestLanguage, results);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -575,16 +575,20 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
/// <param name="results">The collection to add the remote images into.</param>
|
||||
private void ConvertToRemoteImageInfo(List<ImageData> images, string size, ImageType type, string requestLanguage, List<RemoteImageInfo> results)
|
||||
{
|
||||
// sizes provided are for original resolution, don't store them when downloading scaled images
|
||||
var scaleImage = !string.Equals(size, "original", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
for (var i = 0; i < images.Count; i++)
|
||||
{
|
||||
var image = images[i];
|
||||
|
||||
results.Add(new RemoteImageInfo
|
||||
{
|
||||
Url = GetUrl(size, image.FilePath),
|
||||
CommunityRating = image.VoteAverage,
|
||||
VoteCount = image.VoteCount,
|
||||
Width = image.Width,
|
||||
Height = image.Height,
|
||||
Width = scaleImage ? null : image.Width,
|
||||
Height = scaleImage ? null : image.Height,
|
||||
Language = TmdbUtils.AdjustImageLanguage(image.Iso_639_1, requestLanguage),
|
||||
ProviderName = TmdbUtils.ProviderName,
|
||||
Type = type,
|
||||
@@ -593,9 +597,51 @@ namespace MediaBrowser.Providers.Plugins.Tmdb
|
||||
}
|
||||
}
|
||||
|
||||
private Task EnsureClientConfigAsync()
|
||||
private async Task EnsureClientConfigAsync()
|
||||
{
|
||||
return !_tmDbClient.HasConfig ? _tmDbClient.GetConfigAsync() : Task.CompletedTask;
|
||||
if (!_tmDbClient.HasConfig)
|
||||
{
|
||||
var config = await _tmDbClient.GetConfigAsync().ConfigureAwait(false);
|
||||
ValidatePreferences(config);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidatePreferences(TMDbConfig config)
|
||||
{
|
||||
var imageConfig = config.Images;
|
||||
|
||||
var pluginConfig = Plugin.Instance.Configuration;
|
||||
|
||||
if (!imageConfig.PosterSizes.Contains(pluginConfig.PosterSize))
|
||||
{
|
||||
pluginConfig.PosterSize = imageConfig.PosterSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.BackdropSizes.Contains(pluginConfig.BackdropSize))
|
||||
{
|
||||
pluginConfig.BackdropSize = imageConfig.BackdropSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.ProfileSizes.Contains(pluginConfig.ProfileSize))
|
||||
{
|
||||
pluginConfig.ProfileSize = imageConfig.ProfileSizes[^1];
|
||||
}
|
||||
|
||||
if (!imageConfig.StillSizes.Contains(pluginConfig.StillSize))
|
||||
{
|
||||
pluginConfig.StillSize = imageConfig.StillSizes[^1];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="TMDbClient"/> configuration.
|
||||
/// </summary>
|
||||
/// <returns>The configuration.</returns>
|
||||
public async Task<TMDbConfig> GetClientConfiguration()
|
||||
{
|
||||
await EnsureClientConfigAsync().ConfigureAwait(false);
|
||||
|
||||
return _tmDbClient.Config;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Reference in New Issue
Block a user