diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
index 4fdcc8472..f8a674f05 100644
--- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs
@@ -38,12 +38,6 @@ namespace MediaBrowser.Api.Playback.Hls
[Api(Description = "Gets an Http live streaming segment file. Internal use only.")]
public class GetHlsVideoSegment : VideoStreamRequest
{
- ///
- /// Gets or sets the id.
- ///
- /// The id.
- public string Id { get; set; }
-
public string PlaylistId { get; set; }
///
diff --git a/MediaBrowser.Providers/LiveTv/AudioRecordingService.cs b/MediaBrowser.Providers/LiveTv/AudioRecordingService.cs
new file mode 100644
index 000000000..d11fb77ee
--- /dev/null
+++ b/MediaBrowser.Providers/LiveTv/AudioRecordingService.cs
@@ -0,0 +1,42 @@
+using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Providers.Manager;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Providers.LiveTv
+{
+ public class AudioRecordingService : MetadataService
+ {
+ private readonly ILibraryManager _libraryManager;
+
+ public AudioRecordingService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, ILibraryManager libraryManager)
+ : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem)
+ {
+ _libraryManager = libraryManager;
+ }
+
+ ///
+ /// Merges the specified source.
+ ///
+ /// The source.
+ /// The target.
+ /// The locked fields.
+ /// if set to true [replace data].
+ protected override void MergeData(LiveTvAudioRecording source, LiveTvAudioRecording target, List lockedFields, bool replaceData, bool mergeMetadataSettings)
+ {
+ ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
+ }
+
+ protected override Task SaveItem(LiveTvAudioRecording item, ItemUpdateType reason, CancellationToken cancellationToken)
+ {
+ return _libraryManager.UpdateItem(item, reason, cancellationToken);
+ }
+ }
+}
diff --git a/MediaBrowser.Providers/LiveTv/VideoRecordingService.cs b/MediaBrowser.Providers/LiveTv/VideoRecordingService.cs
new file mode 100644
index 000000000..fb4156e8d
--- /dev/null
+++ b/MediaBrowser.Providers/LiveTv/VideoRecordingService.cs
@@ -0,0 +1,42 @@
+using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Providers;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.Logging;
+using MediaBrowser.Providers.Manager;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Providers.LiveTv
+{
+ public class VideoRecordingService : MetadataService
+ {
+ private readonly ILibraryManager _libraryManager;
+
+ public VideoRecordingService(IServerConfigurationManager serverConfigurationManager, ILogger logger, IProviderManager providerManager, IProviderRepository providerRepo, IFileSystem fileSystem, ILibraryManager libraryManager)
+ : base(serverConfigurationManager, logger, providerManager, providerRepo, fileSystem)
+ {
+ _libraryManager = libraryManager;
+ }
+
+ ///
+ /// Merges the specified source.
+ ///
+ /// The source.
+ /// The target.
+ /// The locked fields.
+ /// if set to true [replace data].
+ protected override void MergeData(LiveTvVideoRecording source, LiveTvVideoRecording target, List lockedFields, bool replaceData, bool mergeMetadataSettings)
+ {
+ ProviderUtils.MergeBaseItemData(source, target, lockedFields, replaceData, mergeMetadataSettings);
+ }
+
+ protected override Task SaveItem(LiveTvVideoRecording item, ItemUpdateType reason, CancellationToken cancellationToken)
+ {
+ return _libraryManager.UpdateItem(item, reason, cancellationToken);
+ }
+ }
+}
diff --git a/MediaBrowser.Providers/MediaBrowser.Providers.csproj b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
index 8e459bdc6..54da3471c 100644
--- a/MediaBrowser.Providers/MediaBrowser.Providers.csproj
+++ b/MediaBrowser.Providers/MediaBrowser.Providers.csproj
@@ -77,9 +77,11 @@
+
+
@@ -121,7 +123,7 @@
-
+
diff --git a/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs b/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs
index d59ff0609..233d2ebf4 100644
--- a/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs
+++ b/MediaBrowser.Providers/Music/MusicBrainzArtistProvider.cs
@@ -17,7 +17,7 @@ namespace MediaBrowser.Providers.Music
public async Task> GetMetadata(ArtistInfo id, CancellationToken cancellationToken)
{
var result = new MetadataResult();
-
+
var musicBrainzId = id.GetProviderId(MetadataProviders.Musicbrainz) ?? await FindId(id, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrWhiteSpace(musicBrainzId))
diff --git a/MediaBrowser.Providers/Omdb/OmdbSeriesProvider.cs b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs
similarity index 90%
rename from MediaBrowser.Providers/Omdb/OmdbSeriesProvider.cs
rename to MediaBrowser.Providers/Omdb/OmdbItemProvider.cs
index 4ce2ad5e1..ad985943f 100644
--- a/MediaBrowser.Providers/Omdb/OmdbSeriesProvider.cs
+++ b/MediaBrowser.Providers/Omdb/OmdbItemProvider.cs
@@ -10,13 +10,13 @@ using System.Threading.Tasks;
namespace MediaBrowser.Providers.Omdb
{
- public class OmdbSeriesProvider : ICustomMetadataProvider,
+ public class OmdbItemProvider : ICustomMetadataProvider,
ICustomMetadataProvider, ICustomMetadataProvider
{
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
- public OmdbSeriesProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient)
+ public OmdbItemProvider(IJsonSerializer jsonSerializer, IHttpClient httpClient)
{
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
diff --git a/MediaBrowser.Server.Implementations/LiveTv/RecordingImageProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/RecordingImageProvider.cs
index 1f5610f67..0ba760768 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/RecordingImageProvider.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/RecordingImageProvider.cs
@@ -1,156 +1,111 @@
-using System;
-using System.IO;
-using System.Linq;
-using System.Net;
-using System.Threading;
-using System.Threading.Tasks;
-using MediaBrowser.Common.IO;
-using MediaBrowser.Common.Net;
-using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
-using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
-using MediaBrowser.Model.Net;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
namespace MediaBrowser.Server.Implementations.LiveTv
{
- public class RecordingImageProvider : BaseMetadataProvider
+ public class RecordingImageProvider : IDynamicImageProvider, IHasChangeMonitor
{
private readonly ILiveTvManager _liveTvManager;
- private readonly IProviderManager _providerManager;
- private readonly IFileSystem _fileSystem;
private readonly IHttpClient _httpClient;
+ private readonly ILogger _logger;
- public RecordingImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager, ILiveTvManager liveTvManager, IProviderManager providerManager, IFileSystem fileSystem, IHttpClient httpClient)
- : base(logManager, configurationManager)
+ public RecordingImageProvider(ILiveTvManager liveTvManager, IHttpClient httpClient, ILogger logger)
{
_liveTvManager = liveTvManager;
- _providerManager = providerManager;
- _fileSystem = fileSystem;
_httpClient = httpClient;
+ _logger = logger;
}
- public override bool Supports(BaseItem item)
+ public IEnumerable GetSupportedImages(IHasImages item)
{
- return item is ILiveTvRecording;
+ return new[] { ImageType.Primary };
}
- protected override bool NeedsRefreshInternal(BaseItem item, BaseProviderInfo providerInfo)
+ public async Task GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken)
{
- return !item.HasImage(ImageType.Primary);
- }
+ var liveTvItem = (ILiveTvRecording)item;
- public override async Task FetchAsync(BaseItem item, bool force, BaseProviderInfo providerInfo, CancellationToken cancellationToken)
- {
- if (item.HasImage(ImageType.Primary))
+ var imageResponse = new DynamicImageResponse();
+
+ if (!string.IsNullOrEmpty(liveTvItem.RecordingInfo.ImagePath))
{
- SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
- return true;
+ imageResponse.Path = liveTvItem.RecordingInfo.ImagePath;
+ imageResponse.HasImage = true;
}
-
- var changed = true;
-
- try
- {
- changed = await DownloadImage((ILiveTvRecording)item, cancellationToken).ConfigureAwait(false);
- }
- catch (HttpException ex)
- {
- // Don't fail the provider on a 404
- if (!ex.StatusCode.HasValue || ex.StatusCode.Value != HttpStatusCode.NotFound)
- {
- throw;
- }
- }
-
- if (changed)
- {
- SetLastRefreshed(item, DateTime.UtcNow, providerInfo);
- }
-
- return changed;
- }
-
- private async Task DownloadImage(ILiveTvRecording item, CancellationToken cancellationToken)
- {
- var recordingInfo = item.RecordingInfo;
-
- Stream imageStream = null;
- string contentType = null;
-
- if (!string.IsNullOrEmpty(recordingInfo.ImagePath))
- {
- contentType = "image/" + Path.GetExtension(recordingInfo.ImagePath).ToLower();
- imageStream = _fileSystem.GetFileStream(recordingInfo.ImagePath, FileMode.Open, FileAccess.Read, FileShare.Read, true);
- }
- else if (!string.IsNullOrEmpty(recordingInfo.ImageUrl))
+ else if (!string.IsNullOrEmpty(liveTvItem.RecordingInfo.ImageUrl))
{
var options = new HttpRequestOptions
{
CancellationToken = cancellationToken,
- Url = recordingInfo.ImageUrl
+ Url = liveTvItem.RecordingInfo.ImageUrl
};
var response = await _httpClient.GetResponse(options).ConfigureAwait(false);
- if (!response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
+ if (response.ContentType.StartsWith("image/", StringComparison.OrdinalIgnoreCase))
{
- Logger.Error("Provider did not return an image content type.");
- return false;
+ imageResponse.HasImage = true;
+ imageResponse.Stream = response.Content;
+ imageResponse.SetFormatFromMimeType(response.ContentType);
+ }
+ else
+ {
+ _logger.Error("Provider did not return an image content type.");
}
-
- imageStream = response.Content;
- contentType = response.ContentType;
}
- else if (recordingInfo.HasImage ?? true)
+ else if (liveTvItem.RecordingInfo.HasImage ?? true)
{
- var service = _liveTvManager.Services.FirstOrDefault(i => string.Equals(i.Name, item.ServiceName, StringComparison.OrdinalIgnoreCase));
+ var service = _liveTvManager.Services.FirstOrDefault(i => string.Equals(i.Name, liveTvItem.ServiceName, StringComparison.OrdinalIgnoreCase));
if (service != null)
{
try
{
- var response = await service.GetRecordingImageAsync(recordingInfo.Id, cancellationToken).ConfigureAwait(false);
+ var response = await service.GetRecordingImageAsync(liveTvItem.RecordingInfo.Id, cancellationToken).ConfigureAwait(false);
if (response != null)
{
- imageStream = response.Stream;
- contentType = "image/" + response.Format.ToString().ToLower();
+ imageResponse.HasImage = true;
+ imageResponse.Stream = response.Stream;
+ imageResponse.Format = response.Format;
}
}
catch (NotImplementedException)
{
- return false;
}
}
}
- if (imageStream != null)
- {
- // Dummy up the original url
- var url = item.ServiceName + recordingInfo.Id;
-
- await _providerManager.SaveImage((BaseItem)item, imageStream, contentType, ImageType.Primary, null, cancellationToken).ConfigureAwait(false);
- return true;
- }
-
- return false;
+ return imageResponse;
}
- public override MetadataProviderPriority Priority
+ public string Name
{
- get { return MetadataProviderPriority.Second; }
+ get { return "Live TV Service Provider"; }
}
- public override ItemUpdateType ItemUpdateType
+ public bool Supports(IHasImages item)
{
- get
- {
- return ItemUpdateType.ImageUpdate;
- }
+ return item is ILiveTvRecording;
+ }
+
+ public int Order
+ {
+ get { return 0; }
+ }
+
+ public bool HasChanged(IHasMetadata item, DateTime date)
+ {
+ return !item.HasImage(ImageType.Primary) && (DateTime.UtcNow - date).TotalHours >= 3;
}
}
}