mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-08 08:48:48 +01:00
New provider system. Only for people right now
This commit is contained in:
31
MediaBrowser.Controller/Providers/IHasMetadata.cs
Normal file
31
MediaBrowser.Controller/Providers/IHasMetadata.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IHasMetadata
|
||||
/// </summary>
|
||||
public interface IHasMetadata : IHasImages, IHasProviderIds
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the preferred metadata country code.
|
||||
/// </summary>
|
||||
/// <returns>System.String.</returns>
|
||||
string GetPreferredMetadataCountryCode();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the locked fields.
|
||||
/// </summary>
|
||||
/// <value>The locked fields.</value>
|
||||
List<MetadataFields> LockedFields { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date last saved.
|
||||
/// </summary>
|
||||
/// <value>The date last saved.</value>
|
||||
DateTime DateLastSaved { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,4 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
@@ -26,26 +21,9 @@ namespace MediaBrowser.Controller.Providers
|
||||
bool Supports(IHasImages item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the images.
|
||||
/// Gets the order.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||
Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, ImageType imageType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||
Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the priority.
|
||||
/// </summary>
|
||||
/// <value>The priority.</value>
|
||||
int Priority { get; }
|
||||
/// <value>The order.</value>
|
||||
int Order { get; }
|
||||
}
|
||||
}
|
||||
|
||||
58
MediaBrowser.Controller/Providers/ILocalImageProvider.cs
Normal file
58
MediaBrowser.Controller/Providers/ILocalImageProvider.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using MediaBrowser.Controller.Drawing;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// This is just a marker interface
|
||||
/// </summary>
|
||||
public interface ILocalImageProvider : IImageProvider
|
||||
{
|
||||
}
|
||||
|
||||
public interface IImageFileProvider : ILocalImageProvider
|
||||
{
|
||||
List<LocalImageInfo> GetImages(IHasImages item);
|
||||
}
|
||||
|
||||
public class LocalImageInfo
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public ImageType Type { get; set; }
|
||||
}
|
||||
|
||||
public interface IDynamicImageProvider : ILocalImageProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>List{DynamicImageInfo}.</returns>
|
||||
List<DynamicImageInfo> GetImageInfos(IHasImages item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="info">The information.</param>
|
||||
/// <returns>Task{DynamicImageResponse}.</returns>
|
||||
Task<DynamicImageResponse> GetImage(IHasImages item, DynamicImageInfo info);
|
||||
}
|
||||
|
||||
public class DynamicImageInfo
|
||||
{
|
||||
public string ImageId { get; set; }
|
||||
public ImageType Type { get; set; }
|
||||
}
|
||||
|
||||
public class DynamicImageResponse
|
||||
{
|
||||
public string Path { get; set; }
|
||||
public Stream Stream { get; set; }
|
||||
public ImageFormat Format { get; set; }
|
||||
}
|
||||
}
|
||||
90
MediaBrowser.Controller/Providers/IMetadataProvider.cs
Normal file
90
MediaBrowser.Controller/Providers/IMetadataProvider.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Marker interface
|
||||
/// </summary>
|
||||
public interface IMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
string Name { get; }
|
||||
}
|
||||
|
||||
public interface IMetadataProvider<TItemType> : IMetadataProvider
|
||||
where TItemType : IHasMetadata
|
||||
{
|
||||
}
|
||||
|
||||
public interface ILocalMetadataProvider : IMetadataProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether [has local metadata] [the specified item].
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns><c>true</c> if [has local metadata] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||
bool HasLocalMetadata(IHasMetadata item);
|
||||
}
|
||||
|
||||
public interface IRemoteMetadataProvider : IMetadataProvider
|
||||
{
|
||||
}
|
||||
|
||||
public interface IRemoteMetadataProvider<TItemType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider
|
||||
where TItemType : IHasMetadata
|
||||
{
|
||||
Task<MetadataResult<TItemType>> GetMetadata(ItemId id, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public interface ILocalMetadataProvider<TItemType> : IMetadataProvider<TItemType>, ILocalMetadataProvider
|
||||
where TItemType : IHasMetadata
|
||||
{
|
||||
Task<MetadataResult<TItemType>> GetMetadata(string path, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
public interface IHasChangeMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the specified date has changed.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="date">The date.</param>
|
||||
/// <returns><c>true</c> if the specified date has changed; otherwise, <c>false</c>.</returns>
|
||||
bool HasChanged(IHasMetadata item, DateTime date);
|
||||
}
|
||||
|
||||
public enum MetadataProviderType
|
||||
{
|
||||
Embedded = 0,
|
||||
Local = 1,
|
||||
Remote = 2
|
||||
}
|
||||
|
||||
public class MetadataResult<T>
|
||||
where T : IHasMetadata
|
||||
{
|
||||
public bool HasMetadata { get; set; }
|
||||
public T Item { get; set; }
|
||||
}
|
||||
|
||||
public class ItemId : IHasProviderIds
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string MetadataLanguage { get; set; }
|
||||
public string MetadataCountryCode { get; set; }
|
||||
|
||||
public Dictionary<string, string> ProviderIds { get; set; }
|
||||
|
||||
public ItemId()
|
||||
{
|
||||
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
38
MediaBrowser.Controller/Providers/IMetadataService.cs
Normal file
38
MediaBrowser.Controller/Providers/IMetadataService.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public interface IMetadataService
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds the parts.
|
||||
/// </summary>
|
||||
/// <param name="providers">The providers.</param>
|
||||
/// <param name="imageProviders">The image providers.</param>
|
||||
void AddParts(IEnumerable<IMetadataProvider> providers, IEnumerable<IImageProvider> imageProviders);
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether this instance can refresh the specified item.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns><c>true</c> if this instance can refresh the specified item; otherwise, <c>false</c>.</returns>
|
||||
bool CanRefresh(IHasMetadata item);
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the metadata.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task RefreshMetadata(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the order.
|
||||
/// </summary>
|
||||
/// <value>The order.</value>
|
||||
int Order { get; }
|
||||
}
|
||||
}
|
||||
@@ -14,15 +14,23 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
public interface IProviderManager
|
||||
{
|
||||
/// <summary>
|
||||
/// Refreshes the metadata.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task RefreshMetadata(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Executes the metadata providers.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <param name="force">if set to <c>true</c> [force].</param>
|
||||
/// <param name="allowSlowProviders">if set to <c>true</c> [allow slow providers].</param>
|
||||
/// <returns>Task{System.Boolean}.</returns>
|
||||
Task<ItemUpdateType?> ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false, bool allowSlowProviders = true);
|
||||
Task<ItemUpdateType?> ExecuteMetadataProviders(BaseItem item, CancellationToken cancellationToken, bool force = false);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the image.
|
||||
@@ -54,7 +62,9 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// </summary>
|
||||
/// <param name="providers">The providers.</param>
|
||||
/// <param name="imageProviders">The image providers.</param>
|
||||
void AddParts(IEnumerable<BaseMetadataProvider> providers, IEnumerable<IImageProvider> imageProviders);
|
||||
/// <param name="metadataServices">The metadata services.</param>
|
||||
/// <param name="metadataProviders">The metadata providers.</param>
|
||||
void AddParts(IEnumerable<BaseMetadataProvider> providers, IEnumerable<IImageProvider> imageProviders, IEnumerable<IMetadataService> metadataServices, IEnumerable<IMetadataProvider> metadataProviders);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available remote images.
|
||||
@@ -70,7 +80,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// Gets the image providers.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>IEnumerable{IImageProvider}.</returns>
|
||||
IEnumerable<IImageProvider> GetImageProviders(BaseItem item);
|
||||
/// <returns>IEnumerable{ImageProviderInfo}.</returns>
|
||||
IEnumerable<ImageProviderInfo> GetImageProviderInfo(BaseItem item);
|
||||
}
|
||||
}
|
||||
48
MediaBrowser.Controller/Providers/IRemoteImageProvider.cs
Normal file
48
MediaBrowser.Controller/Providers/IRemoteImageProvider.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Providers;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IImageProvider
|
||||
/// </summary>
|
||||
public interface IRemoteImageProvider : IImageProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the supported images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>IEnumerable{ImageType}.</returns>
|
||||
IEnumerable<ImageType> GetSupportedImages(IHasImages item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="imageType">Type of the image.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||
Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, ImageType imageType, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the images.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
||||
Task<IEnumerable<RemoteImageInfo>> GetAllImages(IHasImages item, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image response.
|
||||
/// </summary>
|
||||
/// <param name="url">The URL.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task{HttpResponseInfo}.</returns>
|
||||
Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
49
MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs
Normal file
49
MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public class MetadataRefreshOptions : ImageRefreshOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// When paired with MetadataRefreshMode=FullRefresh, all existing data will be overwritten with new data from the providers.
|
||||
/// </summary>
|
||||
public bool ReplaceAllMetadata { get; set; }
|
||||
|
||||
public MetadataRefreshMode MetadataRefreshMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO: deprecate. Keeping this for now, for api compatibility
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public bool ForceSave { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO: deprecate. Keeping this for now, for api compatibility
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public bool ResetResolveArgs { get; set; }
|
||||
}
|
||||
|
||||
public class ImageRefreshOptions
|
||||
{
|
||||
public MetadataRefreshMode ImageRefreshMode { get; set; }
|
||||
}
|
||||
|
||||
public enum MetadataRefreshMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Providers will be executed based on default rules
|
||||
/// </summary>
|
||||
EnsureMetadata,
|
||||
|
||||
/// <summary>
|
||||
/// No providers will be executed
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// All providers will be executed to search for new metadata
|
||||
/// </summary>
|
||||
FullRefresh
|
||||
}
|
||||
}
|
||||
60
MediaBrowser.Controller/Providers/ProviderResult.cs
Normal file
60
MediaBrowser.Controller/Providers/ProviderResult.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public class ProviderResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the item identifier.
|
||||
/// </summary>
|
||||
/// <value>The item identifier.</value>
|
||||
public Guid ItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance has refreshed metadata.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance has refreshed metadata; otherwise, <c>false</c>.</value>
|
||||
public bool HasRefreshedMetadata { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance has refreshed images.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance has refreshed images; otherwise, <c>false</c>.</value>
|
||||
public bool HasRefreshedImages { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date last refreshed.
|
||||
/// </summary>
|
||||
/// <value>The date last refreshed.</value>
|
||||
public DateTime DateLastRefreshed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last result.
|
||||
/// </summary>
|
||||
/// <value>The last result.</value>
|
||||
public ProviderRefreshStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last result error message.
|
||||
/// </summary>
|
||||
/// <value>The last result error message.</value>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public void AddStatus(ProviderRefreshStatus status, string errorMessage)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ErrorMessage))
|
||||
{
|
||||
ErrorMessage = errorMessage;
|
||||
}
|
||||
if (Status == ProviderRefreshStatus.Success)
|
||||
{
|
||||
Status = status;
|
||||
}
|
||||
}
|
||||
|
||||
public ProviderResult()
|
||||
{
|
||||
Status = ProviderRefreshStatus.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user