aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-24 11:29:23 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2016-11-24 11:29:23 -0500
commit9606a2a710614404b4dda96cceff688314a1ec89 (patch)
tree024ecd23b21be91f752c73ed7a6278e922c6276b /Emby.Server.Implementations
parent8bc4d49c8967f850d0b76ee8896bbc8ce3e50424 (diff)
filter duplicate recordings based on showId
Diffstat (limited to 'Emby.Server.Implementations')
-rw-r--r--Emby.Server.Implementations/HttpServer/HttpResultFactory.cs3
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs50
-rw-r--r--Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs1
-rw-r--r--Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs7
4 files changed, 56 insertions, 5 deletions
diff --git a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
index f65331ec7..313db6a75 100644
--- a/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
+++ b/Emby.Server.Implementations/HttpServer/HttpResultFactory.cs
@@ -100,7 +100,8 @@ namespace Emby.Server.Implementations.HttpServer
responseHeaders = new Dictionary<string, string>();
}
- if (addCachePrevention)
+ string expires;
+ if (addCachePrevention && !responseHeaders.TryGetValue("Expires", out expires))
{
responseHeaders["Expires"] = "-1";
}
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
index b7d2d1748..1fe5d87ce 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs
@@ -645,6 +645,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
existingTimer.SeasonNumber = updatedTimer.SeasonNumber;
existingTimer.ShortOverview = updatedTimer.ShortOverview;
existingTimer.StartDate = updatedTimer.StartDate;
+ existingTimer.ShowId = updatedTimer.ShowId;
}
public Task<ImageStream> GetChannelImageAsync(string channelId, CancellationToken cancellationToken)
@@ -1836,6 +1837,39 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
return seriesTimer.SkipEpisodesInLibrary && IsProgramAlreadyInLibrary(timer);
}
+ private void HandleDuplicateShowIds(List<TimerInfo> timers)
+ {
+ foreach (var timer in timers.Skip(1))
+ {
+ // TODO: Get smarter, prefer HD, etc
+
+ timer.Status = RecordingStatus.Cancelled;
+ _timerProvider.Update(timer);
+ }
+ }
+
+ private void SearchForDuplicateShowIds(List<TimerInfo> timers)
+ {
+ var groups = timers.ToLookup(i => i.ShowId ?? string.Empty).ToList();
+
+ foreach (var group in groups)
+ {
+ if (string.IsNullOrWhiteSpace(group.Key))
+ {
+ continue;
+ }
+
+ var groupTimers = group.ToList();
+
+ if (groupTimers.Count < 2)
+ {
+ continue;
+ }
+
+ HandleDuplicateShowIds(groupTimers);
+ }
+ }
+
private async Task UpdateTimersForSeriesTimer(List<ProgramInfo> epgData, SeriesTimerInfo seriesTimer, bool deleteInvalidTimers)
{
var allTimers = GetTimersForSeries(seriesTimer, epgData)
@@ -1843,6 +1877,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
var registration = await _liveTvManager.GetRegistrationInfo("seriesrecordings").ConfigureAwait(false);
+ var enabledTimersForSeries = new List<TimerInfo>();
+
if (registration.IsValid)
{
foreach (var timer in allTimers)
@@ -1855,6 +1891,10 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
{
timer.Status = RecordingStatus.Cancelled;
}
+ else
+ {
+ enabledTimersForSeries.Add(timer);
+ }
_timerProvider.Add(timer);
}
else
@@ -1870,6 +1910,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
existingTimer.Status = RecordingStatus.Cancelled;
}
+ if (existingTimer.Status != RecordingStatus.Cancelled)
+ {
+ enabledTimersForSeries.Add(existingTimer);
+ }
+
existingTimer.SeriesTimerId = seriesTimer.Id;
_timerProvider.Update(existingTimer);
}
@@ -1877,6 +1922,8 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
+ SearchForDuplicateShowIds(enabledTimersForSeries);
+
if (deleteInvalidTimers)
{
var allTimerIds = allTimers
@@ -1901,8 +1948,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
}
}
- private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer,
- IEnumerable<ProgramInfo> allPrograms)
+ private IEnumerable<TimerInfo> GetTimersForSeries(SeriesTimerInfo seriesTimer, IEnumerable<ProgramInfo> allPrograms)
{
if (seriesTimer == null)
{
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
index 0ae5971bc..1b6ddc73f 100644
--- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs
@@ -31,6 +31,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV
timer.Name = parent.Name;
timer.Overview = parent.Overview;
timer.SeriesTimerId = seriesTimer.Id;
+ timer.ShowId = parent.ShowId;
CopyProgramInfoToTimerInfo(parent, timer);
diff --git a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
index 33db69ee2..45158b3c2 100644
--- a/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
+++ b/Emby.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs
@@ -124,12 +124,14 @@ namespace Emby.Server.Implementations.LiveTv.Listings
private ProgramInfo GetProgramInfo(XmlTvProgram p, ListingsProviderInfo info)
{
+ var episodeTitle = p.Episode == null ? null : p.Episode.Title;
+
var programInfo = new ProgramInfo
{
ChannelId = p.ChannelId,
EndDate = GetDate(p.EndDate),
EpisodeNumber = p.Episode == null ? null : p.Episode.Episode,
- EpisodeTitle = p.Episode == null ? null : p.Episode.Title,
+ EpisodeTitle = episodeTitle,
Genres = p.Categories,
Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate), // Construct an id from the channel and start date,
StartDate = GetDate(p.StartDate),
@@ -149,7 +151,8 @@ namespace Emby.Server.Implementations.LiveTv.Listings
HasImage = p.Icon != null && !String.IsNullOrEmpty(p.Icon.Source),
OfficialRating = p.Rating != null && !String.IsNullOrEmpty(p.Rating.Value) ? p.Rating.Value : null,
CommunityRating = p.StarRating.HasValue ? p.StarRating.Value : (float?)null,
- SeriesId = p.Episode != null ? p.Title.GetMD5().ToString("N") : null
+ SeriesId = p.Episode != null ? p.Title.GetMD5().ToString("N") : null,
+ ShowId = ((p.Title ?? string.Empty) + (episodeTitle ?? string.Empty)).GetMD5().ToString("N")
};
if (programInfo.IsMovie)