aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-06 11:49:22 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-10-06 11:49:22 -0400
commit43eec485e9341e32816206fba30dda48aee3a89a (patch)
tree281e0a7df16176d0932366fd85655796b80ce672
parentdb01b79901e503350f8359cab8b1eeae5ea30735 (diff)
fix book providers
-rw-r--r--MediaBrowser.Controller/Entities/Audio/AudioPodcast.cs14
-rw-r--r--MediaBrowser.Controller/Entities/AudioBook.cs3
-rw-r--r--MediaBrowser.Controller/Providers/IMetadataService.cs4
-rw-r--r--MediaBrowser.Providers/Books/GoogleBooksProvider.cs45
-rw-r--r--MediaBrowser.Providers/Manager/MetadataService.cs5
-rw-r--r--MediaBrowser.Providers/Manager/ProviderManager.cs26
-rw-r--r--MediaBrowser.Providers/MediaBrowser.Providers.csproj1
7 files changed, 93 insertions, 5 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/AudioPodcast.cs b/MediaBrowser.Controller/Entities/Audio/AudioPodcast.cs
index d2b4569ba..1b717b900 100644
--- a/MediaBrowser.Controller/Entities/Audio/AudioPodcast.cs
+++ b/MediaBrowser.Controller/Entities/Audio/AudioPodcast.cs
@@ -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;
diff --git a/MediaBrowser.Controller/Entities/AudioBook.cs b/MediaBrowser.Controller/Entities/AudioBook.cs
index 1bdcfb881..78fb10253 100644
--- a/MediaBrowser.Controller/Entities/AudioBook.cs
+++ b/MediaBrowser.Controller/Entities/AudioBook.cs
@@ -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
diff --git a/MediaBrowser.Controller/Providers/IMetadataService.cs b/MediaBrowser.Controller/Providers/IMetadataService.cs
index 2d4873f7e..7b7bf166b 100644
--- a/MediaBrowser.Controller/Providers/IMetadataService.cs
+++ b/MediaBrowser.Controller/Providers/IMetadataService.cs
@@ -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.
diff --git a/MediaBrowser.Providers/Books/GoogleBooksProvider.cs b/MediaBrowser.Providers/Books/GoogleBooksProvider.cs
new file mode 100644
index 000000000..7330b8c43
--- /dev/null
+++ b/MediaBrowser.Providers/Books/GoogleBooksProvider.cs
@@ -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>();
+ }
+ }
+}
diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs
index 23c6b3efd..c37e05d95 100644
--- a/MediaBrowser.Providers/Manager/MetadataService.cs
+++ b/MediaBrowser.Providers/Manager/MetadataService.cs
@@ -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,
diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs
index 9f46d41df..28367662b 100644
--- a/MediaBrowser.Providers/Manager/ProviderManager.cs
+++ b/MediaBrowser.Providers/Manager/ProviderManager.cs
@@ -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>(),
diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
index 65791ed10..a7d4a1b06 100644
--- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj
+++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
@@ -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" />