// Kyoo - A portable and vast media library solution. // Copyright (c) Kyoo. // // See AUTHORS.md and LICENSE file in the project root for full license information. // // Kyoo is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // Kyoo is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Kyoo. If not, see . using System.Collections.Generic; using System.Threading.Tasks; using JetBrains.Annotations; using Kyoo.Abstractions.Models; namespace Kyoo.Abstractions.Controllers { /// /// An interface to automatically retrieve metadata from external providers. /// public interface IMetadataProvider { /// /// The corresponding to this provider. /// This allow to map metadata to a provider, keep metadata links and /// know witch is used for a specific . /// Provider Provider { get; } /// /// Return a new item with metadata from your provider. /// /// /// The item to retrieve metadata from. Most of the time, only the name will be available but other /// properties may be filed by other providers before a call to this method. This can allow you to identify /// the collection on your provider. /// /// /// You must not use metadata from the given . /// Merging metadata is the job of Kyoo, a complex is given /// to make a precise search and give you every available properties, not to discard properties. /// /// The type of resource to retrieve metadata for. /// A new containing metadata from your provider or null [ItemCanBeNull] Task Get([NotNull] T item) where T : class, IResource; /// /// Search for a specific type of items with a given query. /// /// The search query to use. /// The type of resource to search metadata for. /// The list of items that could be found on this specific provider. [ItemNotNull] Task> Search(string query) where T : class, IResource; } /// /// A special that merge results. /// This interface exists to specify witch provider to use but it can be used like any other metadata provider. /// public abstract class AProviderComposite : IMetadataProvider { /// [ItemNotNull] public abstract Task Get(T item) where T : class, IResource; /// public abstract Task> Search(string query) where T : class, IResource; /// /// Since this is a composite and not a real provider, no metadata is available. /// It is not meant to be stored or selected. This class will handle merge based on what is required. /// public Provider Provider => null; /// /// Select witch providers to use. /// The associated with the given will be used. /// /// The list of providers to use public abstract void UseProviders(IEnumerable providers); } }