mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 01:24:44 +01:00
filter duplicate recordings based on showId
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user