From 45a4d25e2615e5ec05befc61560ad54b419504eb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 30 Nov 2013 01:49:38 -0500 Subject: [PATCH] updated live tv methods + nuget --- .../HttpClientManager/HttpClientManager.cs | 13 +++- .../LiveTv/ILiveTvService.cs | 7 ++ .../LiveTv/RecurringTimerInfo.cs | 73 +++++++++++++++++++ MediaBrowser.Controller/LiveTv/TimerInfo.cs | 12 +-- .../MediaBrowser.Controller.csproj | 1 + MediaBrowser.Model/LiveTv/RecordingStatus.cs | 6 +- MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 6 +- .../LiveTv/LiveTvManager.cs | 2 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 109 insertions(+), 21 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs diff --git a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs index ea1a5c7266..8d80185add 100644 --- a/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs +++ b/MediaBrowser.Common.Implementations/HttpClientManager/HttpClientManager.cs @@ -24,6 +24,11 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager /// public class HttpClientManager : IHttpClient { + /// + /// When one request to a host times out, we'll ban all other requests for this period of time, to prevent scans from stalling + /// + private int TimeoutSeconds = 30; + /// /// The _logger /// @@ -122,13 +127,13 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager request.UserAgent = options.UserAgent; } + // This is a hack to prevent KeepAlive from getting disabled internally by the HttpWebRequest + // May need to remove this for mono var sp = request.ServicePoint; - if (_httpBehaviorPropertyInfo == null) { _httpBehaviorPropertyInfo = sp.GetType().GetProperty("HttpBehaviour", BindingFlags.Instance | BindingFlags.NonPublic); } - _httpBehaviorPropertyInfo.SetValue(sp, (byte)0, null); return request; @@ -150,7 +155,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager var client = GetHttpClient(GetHostFromUrl(options.Url), options.EnableHttpCompression); - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < TimeoutSeconds) { throw new HttpException(string.Format("Cancelling connection to {0} due to a previous timeout.", options.Url)) { IsTimedOut = true }; } @@ -162,7 +167,7 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager await options.ResourcePool.WaitAsync(options.CancellationToken).ConfigureAwait(false); } - if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < 30) + if ((DateTime.UtcNow - client.LastTimeout).TotalSeconds < TimeoutSeconds) { if (options.ResourcePool != null) { diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 9bc032af35..2b58d8bc56 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -68,6 +68,13 @@ namespace MediaBrowser.Controller.LiveTv /// The cancellation token. /// Task{IEnumerable{RecordingInfo}}. Task> GetTimersAsync(CancellationToken cancellationToken); + + /// + /// Gets the recurring timers asynchronous. + /// + /// The cancellation token. + /// Task{IEnumerable{RecurringTimerInfo}}. + Task> GetRecurringTimersAsync(CancellationToken cancellationToken); /// /// Gets the programs asynchronous. diff --git a/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs new file mode 100644 index 0000000000..08a8b1f92f --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/RecurringTimerInfo.cs @@ -0,0 +1,73 @@ +using MediaBrowser.Model.LiveTv; +using System; + +namespace MediaBrowser.Controller.LiveTv +{ + public class RecurringTimerInfo + { + /// + /// Id of the recording. + /// + public string Id { get; set; } + + /// + /// ChannelId of the recording. + /// + public string ChannelId { get; set; } + + /// + /// ChannelName of the recording. + /// + public string ChannelName { get; set; } + + /// + /// Gets or sets the program identifier. + /// + /// The program identifier. + public string ProgramId { get; set; } + + /// + /// Name of the recording. + /// + public string Name { get; set; } + + /// + /// Description of the recording. + /// + public string Description { get; set; } + + /// + /// The start date of the recording, in UTC. + /// + public DateTime StartDate { get; set; } + + /// + /// The end date of the recording, in UTC. + /// + public DateTime EndDate { get; set; } + + /// + /// Gets or sets the status. + /// + /// The status. + public RecordingStatus Status { get; set; } + + /// + /// Gets or sets the pre padding seconds. + /// + /// The pre padding seconds. + public int PrePaddingSeconds { get; set; } + + /// + /// Gets or sets the post padding seconds. + /// + /// The post padding seconds. + public int PostPaddingSeconds { get; set; } + + /// + /// Gets or sets the type of the recurrence. + /// + /// The type of the recurrence. + public RecurrenceType RecurrenceType { get; set; } + } +} diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 624dc62cab..0fe7c34f2d 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -10,6 +10,12 @@ namespace MediaBrowser.Controller.LiveTv /// public string Id { get; set; } + /// + /// Gets or sets the recurring timer identifier. + /// + /// The recurring timer identifier. + public string RecurringTimerId { get; set; } + /// /// ChannelId of the recording. /// @@ -52,12 +58,6 @@ namespace MediaBrowser.Controller.LiveTv /// The status. public RecordingStatus Status { get; set; } - /// - /// Gets or sets a value indicating whether this instance is recurring. - /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } - /// /// Gets or sets the pre padding seconds. /// diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 2068fccf83..ec0439c2c7 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -110,6 +110,7 @@ + diff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.cs index 7789773407..08a7cfb0c2 100644 --- a/MediaBrowser.Model/LiveTv/RecordingStatus.cs +++ b/MediaBrowser.Model/LiveTv/RecordingStatus.cs @@ -14,7 +14,9 @@ namespace MediaBrowser.Model.LiveTv public enum RecurrenceType { Manual, - NewProgramEvents, - AllProgramEvents + NewProgramEventsOneChannel, + AllProgramEventsOneChannel, + NewProgramEventsAllChannels, + AllProgramEventsAllChannels } } diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index 5d8ac20c45..f7d63e9687 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -58,10 +58,10 @@ namespace MediaBrowser.Model.LiveTv public RecordingStatus Status { get; set; } /// - /// Gets or sets a value indicating whether this instance is recurring. + /// Gets or sets the recurring timer identifier. /// - /// true if this instance is recurring; otherwise, false. - public bool IsRecurring { get; set; } + /// The recurring timer identifier. + public string RecurringTimerId { get; set; } /// /// Gets or sets the pre padding seconds. diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index b55393213c..ea8ea45b69 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -514,7 +514,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv ExternalId = info.Id, ChannelId = GetInternalChannelId(service.Name, info.ChannelId, info.ChannelName).ToString("N"), Status = info.Status, - IsRecurring = info.IsRecurring, + RecurringTimerId = info.RecurringTimerId, PrePaddingSeconds = info.PrePaddingSeconds, PostPaddingSeconds = info.PostPaddingSeconds }; diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 77765ddc62..17311530fa 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.253 + 3.0.254 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index ac6b606cda..e95a638ab8 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.253 + 3.0.254 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index a6c1bee112..38bb37530e 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.253 + 3.0.254 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +