automatically adjust timer schedules to program changes

This commit is contained in:
Luke Pulverenti 2016-12-13 13:23:03 -05:00
parent afabbfa22b
commit ffad9c27e4
6 changed files with 32 additions and 1 deletions

View File

@ -489,6 +489,7 @@ namespace Emby.Server.Core
{ {
var migrations = new List<IVersionMigration> var migrations = new List<IVersionMigration>
{ {
new LibraryScanMigration(ServerConfigurationManager, TaskManager)
}; };
foreach (var task in migrations) foreach (var task in migrations)

View File

@ -181,6 +181,7 @@
<Compile Include="Localization\LocalizationManager.cs" /> <Compile Include="Localization\LocalizationManager.cs" />
<Compile Include="MediaEncoder\EncodingManager.cs" /> <Compile Include="MediaEncoder\EncodingManager.cs" />
<Compile Include="Migrations\IVersionMigration.cs" /> <Compile Include="Migrations\IVersionMigration.cs" />
<Compile Include="Migrations\LibraryScanMigration.cs" />
<Compile Include="Migrations\UpdateLevelMigration.cs" /> <Compile Include="Migrations\UpdateLevelMigration.cs" />
<Compile Include="News\NewsEntryPoint.cs" /> <Compile Include="News\NewsEntryPoint.cs" />
<Compile Include="News\NewsService.cs" /> <Compile Include="News\NewsService.cs" />

View File

@ -328,15 +328,35 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
} }
await UpdateTimersForSeriesTimer(epgData, timer, true).ConfigureAwait(false); await UpdateTimersForSeriesTimer(epgData, timer, true).ConfigureAwait(false);
} }
}
public async Task RefreshTimers(CancellationToken cancellationToken, IProgress<double> progress)
{
var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false); var timers = await GetTimersAsync(cancellationToken).ConfigureAwait(false);
foreach (var timer in timers.ToList()) foreach (var timer in timers)
{ {
if (DateTime.UtcNow > timer.EndDate && !_activeRecordings.ContainsKey(timer.Id)) if (DateTime.UtcNow > timer.EndDate && !_activeRecordings.ContainsKey(timer.Id))
{ {
OnTimerOutOfDate(timer); OnTimerOutOfDate(timer);
continue;
} }
if (string.IsNullOrWhiteSpace(timer.ProgramId) || string.IsNullOrWhiteSpace(timer.ChannelId))
{
continue;
}
var epg = GetEpgDataForChannel(timer.ChannelId);
var program = epg.FirstOrDefault(i => string.Equals(i.Id, timer.ProgramId, StringComparison.OrdinalIgnoreCase));
if (program == null)
{
OnTimerOutOfDate(timer);
continue;
}
RecordingHelper.CopyProgramInfoToTimerInfo(program, timer);
_timerProvider.Update(timer);
} }
} }

View File

@ -41,6 +41,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
public static void CopyProgramInfoToTimerInfo(ProgramInfo programInfo, TimerInfo timerInfo) public static void CopyProgramInfoToTimerInfo(ProgramInfo programInfo, TimerInfo timerInfo)
{ {
timerInfo.Name = programInfo.Name;
timerInfo.StartDate = programInfo.StartDate;
timerInfo.EndDate = programInfo.EndDate;
timerInfo.ChannelId = programInfo.ChannelId;
timerInfo.SeasonNumber = programInfo.SeasonNumber; timerInfo.SeasonNumber = programInfo.SeasonNumber;
timerInfo.EpisodeNumber = programInfo.EpisodeNumber; timerInfo.EpisodeNumber = programInfo.EpisodeNumber;
timerInfo.IsMovie = programInfo.IsMovie; timerInfo.IsMovie = programInfo.IsMovie;
@ -54,6 +59,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
timerInfo.HomePageUrl = programInfo.HomePageUrl; timerInfo.HomePageUrl = programInfo.HomePageUrl;
timerInfo.CommunityRating = programInfo.CommunityRating; timerInfo.CommunityRating = programInfo.CommunityRating;
timerInfo.Overview = programInfo.Overview;
timerInfo.ShortOverview = programInfo.ShortOverview; timerInfo.ShortOverview = programInfo.ShortOverview;
timerInfo.OfficialRating = programInfo.OfficialRating; timerInfo.OfficialRating = programInfo.OfficialRating;
timerInfo.IsRepeat = programInfo.IsRepeat; timerInfo.IsRepeat = programInfo.IsRepeat;

View File

@ -1231,6 +1231,7 @@ namespace Emby.Server.Implementations.LiveTv
if (coreService != null) if (coreService != null)
{ {
await coreService.RefreshSeriesTimers(cancellationToken, new Progress<double>()).ConfigureAwait(false); await coreService.RefreshSeriesTimers(cancellationToken, new Progress<double>()).ConfigureAwait(false);
await coreService.RefreshTimers(cancellationToken, new Progress<double>()).ConfigureAwait(false);
} }
// Load these now which will prefetch metadata // Load these now which will prefetch metadata

View File

@ -201,6 +201,7 @@ namespace MediaBrowser.Model.Configuration
public bool DisplayCollectionsView { get; set; } public bool DisplayCollectionsView { get; set; }
public string[] LocalNetworkAddresses { get; set; } public string[] LocalNetworkAddresses { get; set; }
public string[] CodecsUsed { get; set; } public string[] CodecsUsed { get; set; }
public string[] Migrations { get; set; }
public bool EnableChannelView { get; set; } public bool EnableChannelView { get; set; }
public bool EnableExternalContentInSuggestions { get; set; } public bool EnableExternalContentInSuggestions { get; set; }
public bool EnableSimpleArtistDetection { get; set; } public bool EnableSimpleArtistDetection { get; set; }
@ -213,6 +214,7 @@ namespace MediaBrowser.Model.Configuration
{ {
LocalNetworkAddresses = new string[] { }; LocalNetworkAddresses = new string[] { };
CodecsUsed = new string[] { }; CodecsUsed = new string[] { };
Migrations = new string[] { };
ImageExtractionTimeoutMs = 0; ImageExtractionTimeoutMs = 0;
EnableLocalizedGuids = true; EnableLocalizedGuids = true;