diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs
index 1dd267c93..9fc60beb9 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs
@@ -42,5 +42,8 @@ namespace MediaBrowser.Controller.LiveTv
RecordingStatus Status { get; set; }
DateTime? EndDate { get; set; }
ChannelType ChannelType { get; set; }
+ DateTime DateLastSaved { get; set; }
+ DateTime DateCreated { get; set; }
+ DateTime DateModified { get; set; }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
index 42064cf50..3006b9bbe 100644
--- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
@@ -191,6 +191,12 @@ namespace MediaBrowser.Controller.LiveTv
/// The show identifier.
public string ShowId { get; set; }
+ ///
+ /// Gets or sets the date last updated.
+ ///
+ /// The date last updated.
+ public DateTime DateLastUpdated { get; set; }
+
public RecordingInfo()
{
Genres = new List();
diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index a28e3faec..51476e296 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -576,6 +576,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
recording.Path = recordPath;
recording.Status = RecordingStatus.InProgress;
+ recording.DateLastUpdated = DateTime.UtcNow;
_recordingProvider.Update(recording);
try
@@ -598,7 +599,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
catch (OperationCanceledException)
{
- _logger.Info("Recording cancelled");
+ _logger.Info("Recording stopped");
recording.Status = RecordingStatus.Completed;
}
catch (Exception ex)
@@ -607,6 +608,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
recording.Status = RecordingStatus.Error;
}
+ recording.DateLastUpdated = DateTime.UtcNow;
_recordingProvider.Update(recording);
_timerProvider.Delete(timer);
_logger.Info("Recording was a success");
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 1280c52b1..4c44f5c3b 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -1,6 +1,8 @@
-using MediaBrowser.Common;
+using System.IO;
+using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.IO;
using MediaBrowser.Common.Progress;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller.Configuration;
@@ -61,8 +63,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private readonly List _tunerHosts = new List();
private readonly List _listingProviders = new List();
+ private readonly IFileSystem _fileSystem;
- public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager)
+ public LiveTvManager(IApplicationHost appHost, IServerConfigurationManager config, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserDataManager userDataManager, IDtoService dtoService, IUserManager userManager, ILibraryManager libraryManager, ITaskManager taskManager, ILocalizationManager localization, IJsonSerializer jsonSerializer, IProviderManager providerManager, IFileSystem fileSystem)
{
_config = config;
_logger = logger;
@@ -73,6 +76,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
_localization = localization;
_jsonSerializer = jsonSerializer;
_providerManager = providerManager;
+ _fileSystem = fileSystem;
_dtoService = dtoService;
_userDataManager = userDataManager;
@@ -729,6 +733,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (!string.IsNullOrEmpty(info.Path))
{
item.Path = info.Path;
+ var fileInfo = new FileInfo(info.Path);
+
+ recording.DateCreated = _fileSystem.GetCreationTimeUtc(fileInfo);
+ recording.DateModified = _fileSystem.GetLastWriteTimeUtc(fileInfo);
}
else if (!string.IsNullOrEmpty(info.Url))
{
@@ -741,7 +749,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
await _libraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false);
}
- else if (pathChanged)
+ else if (pathChanged || info.DateLastUpdated > recording.DateLastSaved)
{
await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
}
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index 60ff36c6d..9ecd0764a 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -496,7 +496,7 @@ namespace MediaBrowser.Server.Startup.Common
PlaylistManager = new PlaylistManager(LibraryManager, FileSystemManager, LibraryMonitor, LogManager.GetLogger("PlaylistManager"), UserManager, ProviderManager);
RegisterSingleInstance(PlaylistManager);
- LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager);
+ LiveTvManager = new LiveTvManager(this, ServerConfigurationManager, Logger, ItemRepository, ImageProcessor, UserDataManager, DtoService, UserManager, LibraryManager, TaskManager, LocalizationManager, JsonSerializer, ProviderManager, FileSystemManager);
RegisterSingleInstance(LiveTvManager);
UserViewManager = new UserViewManager(LibraryManager, LocalizationManager, UserManager, ChannelManager, LiveTvManager, PlaylistManager, CollectionManager, ServerConfigurationManager);