add search methods to remote metadata providers

This commit is contained in:
Luke Pulverenti
2014-02-19 23:53:15 -05:00
parent 120c8bcbb9
commit 13e4b2a6a7
45 changed files with 524 additions and 166 deletions

View File

@@ -912,32 +912,6 @@ namespace MediaBrowser.Controller.Entities
}
}
/// <summary>
/// Determine if we have changed vs the passed in copy
/// </summary>
/// <param name="copy">The copy.</param>
/// <returns><c>true</c> if the specified copy has changed; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
public virtual bool HasChanged(BaseItem copy)
{
if (copy == null)
{
throw new ArgumentNullException();
}
if (IsInMixedFolder != copy.IsInMixedFolder)
{
Logger.Debug(Name + " changed due to different value for IsInMixedFolder.");
return true;
}
var changed = copy.DateModified != DateModified;
if (changed)
{
Logger.Debug(Name + " changed - original creation: " + DateCreated + " new creation: " + copy.DateCreated + " original modified: " + DateModified + " new modified: " + copy.DateModified);
}
return changed;
}
public virtual string GetClientTypeName()
{
return GetType().Name;

View File

@@ -181,8 +181,6 @@ namespace MediaBrowser.Controller.Entities
item.Parent = null;
LibraryManager.ReportItemRemoved(item);
return ItemRepository.SaveChildren(Id, ActualChildren.Select(i => i.Id).ToList(), cancellationToken);
}
@@ -220,7 +218,6 @@ namespace MediaBrowser.Controller.Entities
{LocalizedStrings.Instance.GetString("GenreDispPref")},
{LocalizedStrings.Instance.GetString("DirectorDispPref")},
{LocalizedStrings.Instance.GetString("YearDispPref")},
//{LocalizedStrings.Instance.GetString("OfficialRatingDispPref"), null},
{LocalizedStrings.Instance.GetString("StudioDispPref")}
};

View File

@@ -0,0 +1,8 @@

namespace MediaBrowser.Controller.Library
{
public class DeleteOptions
{
public bool DeleteFileLocation { get; set; }
}
}

View File

@@ -41,7 +41,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="parent">The parent.</param>
/// <returns>BaseItem.</returns>
BaseItem ResolvePath(FileSystemInfo fileInfo, Folder parent = null);
/// <summary>
/// Resolves a set of files into a list of BaseItem
/// </summary>
@@ -335,7 +335,19 @@ namespace MediaBrowser.Controller.Library
/// Deletes the item.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="options">The options.</param>
/// <returns>Task.</returns>
Task DeleteItem(BaseItem item);
Task DeleteItem(BaseItem item, DeleteOptions options);
}
public static class LibraryManagerExtensions
{
public static Task DeleteItem(this ILibraryManager manager, BaseItem item)
{
return manager.DeleteItem(item, new DeleteOptions
{
DeleteFileLocation = true
});
}
}
}

View File

@@ -111,6 +111,7 @@
<Compile Include="Entities\IHasAwards.cs" />
<Compile Include="Entities\Photo.cs" />
<Compile Include="FileOrganization\IFileOrganizationService.cs" />
<Compile Include="Library\DeleteOptions.cs" />
<Compile Include="Library\ILibraryPostScanTask.cs" />
<Compile Include="Library\IMetadataSaver.cs" />
<Compile Include="Library\ItemUpdateType.cs" />

View File

@@ -95,6 +95,13 @@ namespace MediaBrowser.Controller.Persistence
/// <returns>IEnumerable{ChildDefinition}.</returns>
IEnumerable<Guid> GetChildren(Guid parentId);
/// <summary>
/// Gets the type of the items of.
/// </summary>
/// <param name="type">The type.</param>
/// <returns>IEnumerable{Guid}.</returns>
IEnumerable<BaseItem> GetItemsOfType(Type type);
/// <summary>
/// Saves the children.
/// </summary>

View File

@@ -96,5 +96,19 @@ namespace MediaBrowser.Controller.Providers
/// <param name="item">The item.</param>
/// <returns>MetadataOptions.</returns>
MetadataOptions GetMetadataOptions(IHasImages 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;
}
}

View File

@@ -1,4 +1,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Providers;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
@@ -9,29 +11,27 @@ namespace MediaBrowser.Controller.Providers
{
}
public interface IRemoteMetadataProvider<TItemType, TLookupInfoType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider
public interface IRemoteMetadataProvider<TItemType, in TLookupInfoType> : IMetadataProvider<TItemType>, IRemoteMetadataProvider, IRemoteSearchProvider<TLookupInfoType>
where TItemType : IHasMetadata, IHasLookupInfo<TLookupInfoType>
where TLookupInfoType : ItemLookupInfo, new()
{
Task<MetadataResult<TItemType>> GetMetadata(TLookupInfoType info, CancellationToken cancellationToken);
}
public interface IRemoteSearchProvider<TLookupInfoType>
public interface IRemoteSearchProvider<in TLookupInfoType> : IMetadataProvider
where TLookupInfoType : ItemLookupInfo
{
string Name { get; }
Task<IEnumerable<RemoteSearchResult>> GetSearchResults(TLookupInfoType searchInfo, CancellationToken cancellationToken);
Task<IEnumerable<SearchResult<TLookupInfoType>>> GetSearchResults(TLookupInfoType searchInfo, 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);
}
public class SearchResult<T>
where T : ItemLookupInfo
{
public T Item { get; set; }
public string ImageUrl { get; set; }
}
public class RemoteSearchQuery<T>
where T : ItemLookupInfo
{