2021-05-06 22:39:20 +00:00
|
|
|
#nullable disable
|
|
|
|
|
2020-08-22 19:56:24 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-13 20:01:16 +00:00
|
|
|
using System;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
2020-08-17 19:10:02 +00:00
|
|
|
using System.Net.Http;
|
2018-12-27 23:27:57 +00:00
|
|
|
using System.Threading;
|
|
|
|
using System.Threading.Tasks;
|
2020-08-14 00:48:28 +00:00
|
|
|
using Jellyfin.Data.Events;
|
2019-01-13 19:25:32 +00:00
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using MediaBrowser.Model.Configuration;
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
using MediaBrowser.Model.Providers;
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
namespace MediaBrowser.Controller.Providers
|
|
|
|
{
|
|
|
|
/// <summary>
|
2020-03-09 14:05:03 +00:00
|
|
|
/// Interface IProviderManager.
|
2018-12-27 23:27:57 +00:00
|
|
|
/// </summary>
|
|
|
|
public interface IProviderManager
|
|
|
|
{
|
2021-01-09 14:00:59 +00:00
|
|
|
event EventHandler<GenericEventArgs<BaseItem>> RefreshStarted;
|
|
|
|
|
|
|
|
event EventHandler<GenericEventArgs<BaseItem>> RefreshCompleted;
|
|
|
|
|
|
|
|
event EventHandler<GenericEventArgs<Tuple<BaseItem, double>>> RefreshProgress;
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Queues the refresh.
|
|
|
|
/// </summary>
|
2021-07-23 16:16:48 +00:00
|
|
|
/// <param name="itemId">Item ID.</param>
|
|
|
|
/// <param name="options">MetadataRefreshOptions for operation.</param>
|
|
|
|
/// <param name="priority">RefreshPriority for operation.</param>
|
2018-12-27 23:27:57 +00:00
|
|
|
void QueueRefresh(Guid itemId, MetadataRefreshOptions options, RefreshPriority priority);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Refreshes the full item.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <param name="options">The options.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task RefreshFullItem(BaseItem item, MetadataRefreshOptions options, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <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<ItemUpdateType> RefreshSingleItem(BaseItem item, MetadataRefreshOptions options, CancellationToken cancellationToken);
|
|
|
|
|
2020-12-03 02:51:53 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Runs multiple metadata refreshes concurrently.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="action">The action to run.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
|
|
|
|
Task RunMetadataRefresh(Func<Task> action, CancellationToken cancellationToken);
|
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Saves the image.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
/// <param name="imageIndex">Index of the image.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SaveImage(BaseItem item, string url, ImageType type, int? imageIndex, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the image.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <param name="source">The source.</param>
|
|
|
|
/// <param name="mimeType">Type of the MIME.</param>
|
|
|
|
/// <param name="type">The type.</param>
|
|
|
|
/// <param name="imageIndex">Index of the image.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SaveImage(BaseItem item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the image.
|
|
|
|
/// </summary>
|
2021-07-23 16:16:48 +00:00
|
|
|
/// <param name="item">Image to save.</param>
|
|
|
|
/// <param name="source">Source of image.</param>
|
|
|
|
/// <param name="mimeType">Mime type image.</param>
|
|
|
|
/// <param name="type">Type of image.</param>
|
|
|
|
/// <param name="imageIndex">Index of image.</param>
|
|
|
|
/// <param name="saveLocallyWithMedia">Option to save locally.</param>
|
|
|
|
/// <param name="cancellationToken">CancellationToken to use with operation.</param>
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <returns>Task.</returns>
|
|
|
|
Task SaveImage(BaseItem item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken);
|
|
|
|
|
2020-08-07 17:26:28 +00:00
|
|
|
Task SaveImage(Stream source, string mimeType, string path);
|
2020-05-13 02:10:35 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Adds the metadata providers.
|
|
|
|
/// </summary>
|
2021-07-23 16:16:48 +00:00
|
|
|
/// <param name="imageProviders">Image providers to use.</param>
|
|
|
|
/// <param name="metadataServices">Metadata services to use.</param>
|
|
|
|
/// <param name="metadataProviders">Metadata providers to use.</param>
|
|
|
|
/// <param name="metadataSavers">Metadata savers to use.</param>
|
|
|
|
/// <param name="externalIds">External IDs to use.</param>
|
Fix possible nullref
when `ProviderManager.SaveMetadata` gets called before
`ProviderManager.AddParts`
```
Error Message:
System.ArgumentNullException : Value cannot be null. (Parameter 'source')
Stack Trace:
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
at System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)
at MediaBrowser.Providers.Manager.ProviderManager.SaveMetadata(BaseItem item, ItemUpdateType updateType, IEnumerable`1 savers) in D:\a\1\s\MediaBrowser.Providers\Manager\ProviderManager.cs:line 674
at MediaBrowser.Providers.Manager.ProviderManager.SaveMetadata(BaseItem item, ItemUpdateType updateType) in D:\a\1\s\MediaBrowser.Providers\Manager\ProviderManager.cs:line 655
at Emby.Server.Implementations.Library.LibraryManager.RunMetadataSavers(BaseItem item, ItemUpdateType updateReason) in D:\a\1\s\Emby.Server.Implementations\Library\LibraryManager.cs:line 2012
at Emby.Server.Implementations.Library.LibraryManager.UpdateItemsAsync(IReadOnlyList`1 items, BaseItem parent, ItemUpdateType updateReason, CancellationToken cancellationToken) in D:\a\1\s\Emby.Server.Implementations\Library\LibraryManager.cs:line 1970
at Emby.Server.Implementations.Library.LibraryManager.CreateRootFolder() in D:\a\1\s\Emby.Server.Implementations\Library\LibraryManager.cs:line 775
at Emby.Server.Implementations.Library.LibraryManager.get_RootFolder() in D:\a\1\s\Emby.Server.Implementations\Library\LibraryManager.cs:line 180
at Emby.Server.Implementations.IO.LibraryMonitor.Start() in D:\a\1\s\Emby.Server.Implementations\IO\LibraryMonitor.cs:line 135
at Emby.Server.Implementations.IO.LibraryMonitorStartup.RunAsync() in D:\a\1\s\Emby.Server.Implementations\IO\LibraryMonitorStartup.cs:line 26
at Emby.Server.Implementations.ApplicationHost.StartEntryPoints(IEnumerable`1 entryPoints, Boolean isBeforeStartup)+MoveNext() in D:\a\1\s\Emby.Server.Implementations\ApplicationHost.cs:line 541
at System.Threading.Tasks.Task.WhenAll(IEnumerable`1 tasks)
at Emby.Server.Implementations.ApplicationHost.RunStartupTasksAsync(CancellationToken cancellationToken) in D:\a\1\s\Emby.Server.Implementations\ApplicationHost.cs:line 525
at Jellyfin.Server.Integration.Tests.JellyfinApplicationFactory.CreateServer(IWebHostBuilder builder) in D:\a\1\s\tests\Jellyfin.Server.Integration.Tests\JellyfinApplicationFactory.cs:line 101
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.EnsureServer()
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(DelegatingHandler[] handlers)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateDefaultClient(Uri baseAddress, DelegatingHandler[] handlers)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient(WebApplicationFactoryClientOptions options)
at Microsoft.AspNetCore.Mvc.Testing.WebApplicationFactory`1.CreateClient()
at Jellyfin.Server.Integration.Tests.OpenApiSpecTests.GetSpec_ReturnsCorrectResponse() in D:\a\1\s\tests\Jellyfin.Server.Integration.Tests\OpenApiSpecTests.cs:line 26
--- End of stack trace from previous location ---
```
2021-04-03 23:45:15 +00:00
|
|
|
void AddParts(
|
|
|
|
IEnumerable<IImageProvider> imageProviders,
|
|
|
|
IEnumerable<IMetadataService> metadataServices,
|
|
|
|
IEnumerable<IMetadataProvider> metadataProviders,
|
|
|
|
IEnumerable<IMetadataSaver> metadataSavers,
|
2018-12-27 23:27:57 +00:00
|
|
|
IEnumerable<IExternalId> externalIds);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the available remote images.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <param name="query">The query.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns>
|
|
|
|
Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(BaseItem item, RemoteImageQuery query, CancellationToken cancellationToken);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the image providers.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <returns>IEnumerable{ImageProviderInfo}.</returns>
|
|
|
|
IEnumerable<ImageProviderInfo> GetRemoteImageProviderInfo(BaseItem item);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets all metadata plugins.
|
|
|
|
/// </summary>
|
|
|
|
/// <returns>IEnumerable{MetadataPlugin}.</returns>
|
|
|
|
MetadataPluginSummary[] GetAllMetadataPlugins();
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the external urls.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <returns>IEnumerable{ExternalUrl}.</returns>
|
|
|
|
IEnumerable<ExternalUrl> GetExternalUrls(BaseItem item);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the external identifier infos.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <returns>IEnumerable{ExternalIdInfo}.</returns>
|
|
|
|
IEnumerable<ExternalIdInfo> GetExternalIdInfos(IHasProviderIds item);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the metadata.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <param name="updateType">Type of the update.</param>
|
2022-01-22 22:36:42 +00:00
|
|
|
/// <returns>The task object representing the asynchronous operation.</returns>
|
|
|
|
Task SaveMetadataAsync(BaseItem item, ItemUpdateType updateType);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Saves the metadata.
|
|
|
|
/// </summary>
|
2021-01-09 14:00:59 +00:00
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <param name="updateType">Type of the update.</param>
|
2021-01-09 14:14:26 +00:00
|
|
|
/// <param name="savers">The metadata savers.</param>
|
2022-01-22 22:36:42 +00:00
|
|
|
/// <returns>The task object representing the asynchronous operation.</returns>
|
|
|
|
Task SaveMetadataAsync(BaseItem item, ItemUpdateType updateType, IEnumerable<string> savers);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the metadata options.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="item">The item.</param>
|
|
|
|
/// <returns>MetadataOptions.</returns>
|
|
|
|
MetadataOptions GetMetadataOptions(BaseItem item);
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the remote search results.
|
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TItemType">The type of the t item type.</typeparam>
|
|
|
|
/// <typeparam name="TLookupType">The type of the t lookup type.</typeparam>
|
|
|
|
/// <param name="searchInfo">The search information.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task{IEnumerable{SearchResult{``1}}}.</returns>
|
|
|
|
Task<IEnumerable<RemoteSearchResult>> GetRemoteSearchResults<TItemType, TLookupType>(
|
|
|
|
RemoteSearchQuery<TLookupType> searchInfo,
|
|
|
|
CancellationToken cancellationToken)
|
|
|
|
where TItemType : BaseItem, new()
|
|
|
|
where TLookupType : ItemLookupInfo;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the search image.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="providerName">Name of the provider.</param>
|
|
|
|
/// <param name="url">The URL.</param>
|
|
|
|
/// <param name="cancellationToken">The cancellation token.</param>
|
|
|
|
/// <returns>Task{HttpResponseInfo}.</returns>
|
2020-08-17 19:10:02 +00:00
|
|
|
Task<HttpResponseMessage> GetSearchImage(string providerName, string url, CancellationToken cancellationToken);
|
2018-12-27 23:27:57 +00:00
|
|
|
|
|
|
|
Dictionary<Guid, Guid> GetRefreshQueue();
|
|
|
|
|
|
|
|
void OnRefreshStart(BaseItem item);
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
void OnRefreshProgress(BaseItem item, double progress);
|
2020-03-09 14:05:03 +00:00
|
|
|
|
2018-12-27 23:27:57 +00:00
|
|
|
void OnRefreshComplete(BaseItem item);
|
|
|
|
|
|
|
|
double? GetRefreshProgress(Guid id);
|
|
|
|
}
|
2019-01-13 19:30:58 +00:00
|
|
|
}
|