diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 6cec2118bc..e985fb615a 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Library;
+using System.Globalization;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.Querying;
@@ -118,6 +119,18 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string UserId { get; set; }
+
+ [ApiMember(Name = "MinStartDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string MinStartDate { get; set; }
+
+ [ApiMember(Name = "MaxStartDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string MaxStartDate { get; set; }
+
+ [ApiMember(Name = "MinEndDate", Description = "Optional. The minimum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string MinEndDate { get; set; }
+
+ [ApiMember(Name = "MaxEndDate", Description = "Optional. The maximum premiere date. Format = yyyyMMddHHmmss", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
+ public string MaxEndDate { get; set; }
}
[Route("/LiveTv/Programs/{Id}", "GET")]
@@ -253,12 +266,33 @@ namespace MediaBrowser.Api.LiveTv
public object Get(GetPrograms request)
{
- var result = _liveTvManager.GetPrograms(new ProgramQuery
+ var query = new ProgramQuery
{
- ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray(),
+ ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToArray(),
UserId = request.UserId
+ };
- }, CancellationToken.None).Result;
+ if (!string.IsNullOrEmpty(request.MinStartDate))
+ {
+ query.MinStartDate = DateTime.ParseExact(request.MinStartDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
+ }
+
+ if (!string.IsNullOrEmpty(request.MinEndDate))
+ {
+ query.MinEndDate = DateTime.ParseExact(request.MinEndDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
+ }
+
+ if (!string.IsNullOrEmpty(request.MaxStartDate))
+ {
+ query.MaxStartDate = DateTime.ParseExact(request.MaxStartDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
+ }
+
+ if (!string.IsNullOrEmpty(request.MaxEndDate))
+ {
+ query.MaxEndDate = DateTime.ParseExact(request.MaxEndDate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);
+ }
+
+ var result = _liveTvManager.GetPrograms(query, CancellationToken.None).Result;
return ToOptimizedResult(result);
}
diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs
index f96c2536e6..f3312d2cb8 100644
--- a/MediaBrowser.Controller/IServerApplicationHost.cs
+++ b/MediaBrowser.Controller/IServerApplicationHost.cs
@@ -25,5 +25,11 @@ namespace MediaBrowser.Controller
///
/// The HTTP server URL prefix.
string HttpServerUrlPrefix { get; }
+
+ ///
+ /// Gets a value indicating whether [supports automatic run at startup].
+ ///
+ /// true if [supports automatic run at startup]; otherwise, false.
+ bool SupportsAutoRunAtStartup { get; }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
index 8676540fd0..93de9d5c34 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
@@ -11,7 +11,14 @@ namespace MediaBrowser.Controller.LiveTv
/// System.String.
public override string GetUserDataKey()
{
- return GetClientTypeName() + "-" + Name;
+ var name = GetClientTypeName();
+
+ if (!string.IsNullOrEmpty(RecordingInfo.ProgramId))
+ {
+ return name + "-" + RecordingInfo.ProgramId;
+ }
+
+ return name + "-" + RecordingInfo.Name + (RecordingInfo.EpisodeTitle ?? string.Empty);
}
public RecordingInfo RecordingInfo { get; set; }
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
index 9dfc7f828d..bc4ed54934 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
@@ -11,7 +11,14 @@ namespace MediaBrowser.Controller.LiveTv
/// System.String.
public override string GetUserDataKey()
{
- return GetClientTypeName() + "-" + Name;
+ var name = GetClientTypeName();
+
+ if (!string.IsNullOrEmpty(RecordingInfo.ProgramId))
+ {
+ return name + "-" + RecordingInfo.ProgramId;
+ }
+
+ return name + "-" + RecordingInfo.Name + (RecordingInfo.EpisodeTitle ?? string.Empty);
}
public RecordingInfo RecordingInfo { get; set; }
diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.cs
index c2a913bc85..36c06d4c08 100644
--- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs
+++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs
@@ -1,4 +1,6 @@
-namespace MediaBrowser.Model.LiveTv
+using System;
+
+namespace MediaBrowser.Model.LiveTv
{
///
/// Class ProgramQuery.
@@ -17,6 +19,14 @@
/// The user identifier.
public string UserId { get; set; }
+ public DateTime? MinStartDate { get; set; }
+
+ public DateTime? MaxStartDate { get; set; }
+
+ public DateTime? MinEndDate { get; set; }
+
+ public DateTime? MaxEndDate { get; set; }
+
public ProgramQuery()
{
ChannelIdList = new string[] { };
diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs
index 733c9b6e5c..5fc5f363b6 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -128,6 +128,12 @@ namespace MediaBrowser.Model.System
/// true if this instance has update available; otherwise, false.
public bool HasUpdateAvailable { get; set; }
+ ///
+ /// Gets or sets a value indicating whether [supports automatic run at startup].
+ ///
+ /// true if [supports automatic run at startup]; otherwise, false.
+ public bool SupportsAutoRunAtStartup { get; set; }
+
///
/// Initializes a new instance of the class.
///
diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs
index 6269e1b78c..c6c7831e60 100644
--- a/MediaBrowser.Mono.userprefs
+++ b/MediaBrowser.Mono.userprefs
@@ -1,8 +1,10 @@
-
+
-
+
+
+
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 131c5c0fbe..332cbf0167 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -336,6 +336,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{
IEnumerable programs = _programs.Values;
+ if (query.MinEndDate.HasValue)
+ {
+ var val = query.MinEndDate.Value;
+
+ programs = programs.Where(i => i.ProgramInfo.EndDate >= val);
+ }
+
+ if (query.MinStartDate.HasValue)
+ {
+ var val = query.MinStartDate.Value;
+
+ programs = programs.Where(i => i.ProgramInfo.StartDate >= val);
+ }
+
+ if (query.MaxEndDate.HasValue)
+ {
+ var val = query.MaxEndDate.Value;
+
+ programs = programs.Where(i => i.ProgramInfo.EndDate <= val);
+ }
+
+ if (query.MaxStartDate.HasValue)
+ {
+ var val = query.MaxStartDate.Value;
+
+ programs = programs.Where(i => i.ProgramInfo.StartDate <= val);
+ }
+
if (query.ChannelIdList.Length > 0)
{
var guids = query.ChannelIdList.Select(i => new Guid(i)).ToList();
@@ -355,7 +383,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
if (user != null)
{
- programs = programs.Where(i => i.IsParentalAllowed(user));
+ // Avoid implicitly captured closure
+ var currentUser = user;
+ programs = programs.Where(i => i.IsParentalAllowed(currentUser));
}
var returnArray = programs
diff --git a/MediaBrowser.Server.Mono/Native/NativeApp.cs b/MediaBrowser.Server.Mono/Native/NativeApp.cs
index b8c4447e5f..deff79b4ba 100644
--- a/MediaBrowser.Server.Mono/Native/NativeApp.cs
+++ b/MediaBrowser.Server.Mono/Native/NativeApp.cs
@@ -46,5 +46,10 @@ namespace MediaBrowser.ServerApplication.Native
return MainClass.CanSelfUpdate;
}
}
+
+ public static bool SupportsAutoRunAtStartup
+ {
+ get { return false; }
+ }
}
}
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index 0e66f2caf9..e027728831 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -1,5 +1,4 @@
-using System.Globalization;
-using MediaBrowser.Api;
+using MediaBrowser.Api;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Constants;
@@ -58,6 +57,7 @@ using MediaBrowser.ServerApplication.Networking;
using MediaBrowser.WebDashboard.Api;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
@@ -186,6 +186,11 @@ namespace MediaBrowser.ServerApplication
get { return NativeApp.CanSelfRestart; }
}
+ public bool SupportsAutoRunAtStartup
+ {
+ get { return NativeApp.SupportsAutoRunAtStartup; }
+ }
+
///
/// Runs the startup tasks.
///
@@ -629,7 +634,8 @@ namespace MediaBrowser.ServerApplication
CanSelfRestart = CanSelfRestart,
CanSelfUpdate = CanSelfUpdate,
WanAddress = GetWanAddress(),
- HasUpdateAvailable = _hasUpdateAvailable
+ HasUpdateAvailable = _hasUpdateAvailable,
+ SupportsAutoRunAtStartup = SupportsAutoRunAtStartup
};
}
@@ -736,9 +742,16 @@ namespace MediaBrowser.ServerApplication
OnApplicationUpdated(package.version);
}
+ ///
+ /// Configures the automatic run at startup.
+ ///
+ /// if set to true [autorun].
protected override void ConfigureAutoRunAtStartup(bool autorun)
{
- Autorun.Configure(autorun);
+ if (SupportsAutoRunAtStartup)
+ {
+ Autorun.Configure(autorun);
+ }
}
}
}
diff --git a/MediaBrowser.ServerApplication/Native/NativeApp.cs b/MediaBrowser.ServerApplication/Native/NativeApp.cs
index c0d3e876a5..646a7bc98b 100644
--- a/MediaBrowser.ServerApplication/Native/NativeApp.cs
+++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs
@@ -34,6 +34,18 @@ namespace MediaBrowser.ServerApplication.Native
}
}
+ ///
+ /// Gets a value indicating whether [supports automatic run at startup].
+ ///
+ /// true if [supports automatic run at startup]; otherwise, false.
+ public static bool SupportsAutoRunAtStartup
+ {
+ get
+ {
+ return true;
+ }
+ }
+
///
/// Gets a value indicating whether this instance can self update.
///