mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-03 22:38:30 +01:00
persist provider results
This commit is contained in:
@@ -364,11 +364,16 @@ namespace MediaBrowser.Controller.Entities
|
||||
}
|
||||
}
|
||||
|
||||
private string _forcedSortName;
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the forced sort.
|
||||
/// </summary>
|
||||
/// <value>The name of the forced sort.</value>
|
||||
public string ForcedSortName { get; set; }
|
||||
public string ForcedSortName
|
||||
{
|
||||
get { return _forcedSortName; }
|
||||
set { _forcedSortName = value; _sortName = null; }
|
||||
}
|
||||
|
||||
private string _sortName;
|
||||
/// <summary>
|
||||
|
||||
@@ -146,13 +146,15 @@
|
||||
<Compile Include="Providers\IDynamicInfoProvider.cs" />
|
||||
<Compile Include="Providers\IHasMetadata.cs" />
|
||||
<Compile Include="Providers\IImageProvider.cs" />
|
||||
<Compile Include="Providers\IProviderRepository.cs" />
|
||||
<Compile Include="Providers\IRemoteImageProvider.cs" />
|
||||
<Compile Include="Providers\ILocalImageProvider.cs" />
|
||||
<Compile Include="Providers\IMetadataProvider.cs" />
|
||||
<Compile Include="Providers\IMetadataService.cs" />
|
||||
<Compile Include="Providers\ItemId.cs" />
|
||||
<Compile Include="Providers\MetadataRefreshOptions.cs" />
|
||||
<Compile Include="Providers\NameParser.cs" />
|
||||
<Compile Include="Providers\ProviderResult.cs" />
|
||||
<Compile Include="Providers\MetadataStatus.cs" />
|
||||
<Compile Include="Session\ISessionManager.cs" />
|
||||
<Compile Include="Drawing\ImageExtensions.cs" />
|
||||
<Compile Include="Entities\AggregateFolder.cs" />
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -112,22 +111,6 @@ namespace MediaBrowser.Controller.Persistence
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveMediaStreams(Guid id, IEnumerable<MediaStream> streams, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the provider history.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <returns>IEnumerable{BaseProviderInfo}.</returns>
|
||||
IEnumerable<BaseProviderInfo> GetProviderHistory(Guid itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the provider history.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="history">The history.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveProviderHistory(Guid id, IEnumerable<BaseProviderInfo> history, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -52,21 +50,14 @@ namespace MediaBrowser.Controller.Providers
|
||||
public interface IHasChangeMonitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the specified date has changed.
|
||||
/// Determines whether the specified item 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>
|
||||
/// <returns><c>true</c> if the specified item 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
|
||||
{
|
||||
@@ -74,17 +65,4 @@ namespace MediaBrowser.Controller.Providers
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
48
MediaBrowser.Controller/Providers/IProviderRepository.cs
Normal file
48
MediaBrowser.Controller/Providers/IProviderRepository.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public interface IProviderRepository : IRepository
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the provider history.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <returns>IEnumerable{BaseProviderInfo}.</returns>
|
||||
IEnumerable<BaseProviderInfo> GetProviderHistory(Guid itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the provider history.
|
||||
/// </summary>
|
||||
/// <param name="id">The identifier.</param>
|
||||
/// <param name="history">The history.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveProviderHistory(Guid id, IEnumerable<BaseProviderInfo> history, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata status.
|
||||
/// </summary>
|
||||
/// <param name="itemId">The item identifier.</param>
|
||||
/// <returns>MetadataStatus.</returns>
|
||||
MetadataStatus GetMetadataStatus(Guid itemId);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the metadata status.
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <param name="cancellationToken">The cancellation token.</param>
|
||||
/// <returns>Task.</returns>
|
||||
Task SaveMetadataStatus(MetadataStatus status, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes this instance.
|
||||
/// </summary>
|
||||
/// <returns>Task.</returns>
|
||||
Task Initialize();
|
||||
}
|
||||
}
|
||||
35
MediaBrowser.Controller/Providers/ItemId.cs
Normal file
35
MediaBrowser.Controller/Providers/ItemId.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public class ItemId : IHasProviderIds
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the metadata language.
|
||||
/// </summary>
|
||||
/// <value>The metadata language.</value>
|
||||
public string MetadataLanguage { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the metadata country code.
|
||||
/// </summary>
|
||||
/// <value>The metadata country code.</value>
|
||||
public string MetadataCountryCode { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the provider ids.
|
||||
/// </summary>
|
||||
/// <value>The provider ids.</value>
|
||||
public Dictionary<string, string> ProviderIds { get; set; }
|
||||
|
||||
public ItemId()
|
||||
{
|
||||
ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
}
|
||||
122
MediaBrowser.Controller/Providers/MetadataStatus.cs
Normal file
122
MediaBrowser.Controller/Providers/MetadataStatus.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
|
||||
namespace MediaBrowser.Controller.Providers
|
||||
{
|
||||
public class MetadataStatus
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the item identifier.
|
||||
/// </summary>
|
||||
/// <value>The item identifier.</value>
|
||||
public Guid ItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date last metadata refresh.
|
||||
/// </summary>
|
||||
/// <value>The date last metadata refresh.</value>
|
||||
public DateTime? DateLastMetadataRefresh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the date last images refresh.
|
||||
/// </summary>
|
||||
/// <value>The date last images refresh.</value>
|
||||
public DateTime? DateLastImagesRefresh { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last result.
|
||||
/// </summary>
|
||||
/// <value>The last result.</value>
|
||||
public ProviderRefreshStatus LastStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the last result error message.
|
||||
/// </summary>
|
||||
/// <value>The last result error message.</value>
|
||||
public string LastErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the providers refreshed.
|
||||
/// </summary>
|
||||
/// <value>The providers refreshed.</value>
|
||||
public List<Guid> MetadataProvidersRefreshed { get; set; }
|
||||
public List<Guid> ImageProvidersRefreshed { get; set; }
|
||||
|
||||
public void AddStatus(ProviderRefreshStatus status, string errorMessage)
|
||||
{
|
||||
if (LastStatus != status)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(LastErrorMessage))
|
||||
{
|
||||
LastErrorMessage = errorMessage;
|
||||
}
|
||||
if (LastStatus == ProviderRefreshStatus.Success)
|
||||
{
|
||||
LastStatus = status;
|
||||
}
|
||||
}
|
||||
|
||||
public MetadataStatus()
|
||||
{
|
||||
LastStatus = ProviderRefreshStatus.Success;
|
||||
|
||||
MetadataProvidersRefreshed = new List<Guid>();
|
||||
ImageProvidersRefreshed = new List<Guid>();
|
||||
}
|
||||
|
||||
public bool IsDirty { get; private set; }
|
||||
|
||||
public void SetDateLastMetadataRefresh(DateTime date)
|
||||
{
|
||||
if (date != (DateLastMetadataRefresh ?? DateTime.MinValue))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
DateLastMetadataRefresh = date;
|
||||
}
|
||||
|
||||
public void SetDateLastImagesRefresh(DateTime date)
|
||||
{
|
||||
if (date != (DateLastImagesRefresh ?? DateTime.MinValue))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
DateLastImagesRefresh = date;
|
||||
}
|
||||
|
||||
public void AddImageProvidersRefreshed(List<Guid> providerIds)
|
||||
{
|
||||
var count = ImageProvidersRefreshed.Count;
|
||||
|
||||
providerIds.AddRange(ImageProvidersRefreshed);
|
||||
|
||||
ImageProvidersRefreshed = providerIds.Distinct().ToList();
|
||||
|
||||
if (ImageProvidersRefreshed.Count != count)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddMetadataProvidersRefreshed(List<Guid> providerIds)
|
||||
{
|
||||
var count = MetadataProvidersRefreshed.Count;
|
||||
|
||||
providerIds.AddRange(MetadataProvidersRefreshed);
|
||||
|
||||
MetadataProvidersRefreshed = providerIds.Distinct().ToList();
|
||||
|
||||
if (MetadataProvidersRefreshed.Count != count)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
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