mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-15 18:08:53 -07:00
fix book providers
This commit is contained in:
parent
db01b79901
commit
43eec485e9
@ -1,8 +1,9 @@
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities.Audio
|
||||
{
|
||||
public class AudioPodcast : Audio
|
||||
public class AudioPodcast : Audio, IHasLookupInfo<SongInfo>
|
||||
{
|
||||
[IgnoreDataMember]
|
||||
public override bool SupportsPositionTicksResume
|
||||
@ -13,6 +14,15 @@ namespace MediaBrowser.Controller.Entities.Audio
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public override bool SupportsPlayedStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override double? GetDefaultPrimaryImageAspectRatio()
|
||||
{
|
||||
return 1;
|
||||
|
@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
||||
namespace MediaBrowser.Controller.Entities
|
||||
{
|
||||
public class AudioBook : Audio.Audio, IHasSeries
|
||||
public class AudioBook : Audio.Audio, IHasSeries, IHasLookupInfo<SongInfo>
|
||||
{
|
||||
[IgnoreDataMember]
|
||||
public override bool SupportsPositionTicksResume
|
||||
|
@ -1,4 +1,5 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using System;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -13,6 +14,7 @@ namespace MediaBrowser.Controller.Providers
|
||||
/// <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);
|
||||
bool CanRefreshPrimary(Type type);
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the metadata.
|
||||
|
45
MediaBrowser.Providers/Books/GoogleBooksProvider.cs
Normal file
45
MediaBrowser.Providers/Books/GoogleBooksProvider.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Entities.TV;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Providers;
|
||||
|
||||
namespace MediaBrowser.Providers.Books
|
||||
{
|
||||
public class GoogleBooksProvider : IRemoteMetadataProvider<AudioBook, SongInfo>
|
||||
{
|
||||
public string Name => "Google Books";
|
||||
private readonly IHttpClient _httpClient;
|
||||
|
||||
public GoogleBooksProvider(IHttpClient httpClient)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
}
|
||||
|
||||
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
return _httpClient.GetResponse(new HttpRequestOptions
|
||||
{
|
||||
CancellationToken = cancellationToken,
|
||||
Url = url,
|
||||
BufferContent = false
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<MetadataResult<AudioBook>> GetMetadata(SongInfo info, CancellationToken cancellationToken)
|
||||
{
|
||||
return new MetadataResult<AudioBook>();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(SongInfo searchInfo, CancellationToken cancellationToken)
|
||||
{
|
||||
return new List<RemoteSearchResult>();
|
||||
}
|
||||
}
|
||||
}
|
@ -453,6 +453,11 @@ namespace MediaBrowser.Providers.Manager
|
||||
return item is TItemType;
|
||||
}
|
||||
|
||||
public bool CanRefreshPrimary(Type type)
|
||||
{
|
||||
return type == typeof(TItemType);
|
||||
}
|
||||
|
||||
protected virtual async Task<RefreshResult> RefreshWithProviders(MetadataResult<TItemType> metadata,
|
||||
TIdType id,
|
||||
MetadataRefreshOptions options,
|
||||
|
@ -118,7 +118,29 @@ namespace MediaBrowser.Providers.Manager
|
||||
|
||||
public Task<ItemUpdateType> RefreshSingleItem(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken)
|
||||
{
|
||||
var service = _metadataServices.FirstOrDefault(i => i.CanRefresh(item));
|
||||
IMetadataService service = null;
|
||||
var type = item.GetType();
|
||||
|
||||
foreach (var current in _metadataServices)
|
||||
{
|
||||
if (current.CanRefreshPrimary(type))
|
||||
{
|
||||
service = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (service == null)
|
||||
{
|
||||
foreach (var current in _metadataServices)
|
||||
{
|
||||
if (current.CanRefresh(item))
|
||||
{
|
||||
service = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
@ -452,6 +474,8 @@ namespace MediaBrowser.Providers.Manager
|
||||
GetPluginSummary<MusicAlbum>(),
|
||||
GetPluginSummary<MusicArtist>(),
|
||||
GetPluginSummary<Audio>(),
|
||||
GetPluginSummary<AudioBook>(),
|
||||
GetPluginSummary<AudioPodcast>(),
|
||||
GetPluginSummary<Genre>(),
|
||||
GetPluginSummary<Studio>(),
|
||||
GetPluginSummary<GameGenre>(),
|
||||
|
@ -41,6 +41,7 @@
|
||||
<Compile Include="Books\AudioBookMetadataService.cs" />
|
||||
<Compile Include="Books\AudioPodcastMetadataService.cs" />
|
||||
<Compile Include="Books\BookMetadataService.cs" />
|
||||
<Compile Include="Books\GoogleBooksProvider.cs" />
|
||||
<Compile Include="BoxSets\BoxSetMetadataService.cs" />
|
||||
<Compile Include="BoxSets\MovieDbBoxSetImageProvider.cs" />
|
||||
<Compile Include="BoxSets\MovieDbBoxSetProvider.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user