aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-01-05 20:59:21 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-01-05 20:59:21 -0500
commitb4ac51aa1052c895ade917c5b4d314c09d3b29d8 (patch)
tree3bdcaf0b5da1648513e85627e5ea1819fcb908b5
parent6ed380ed1be293ef636570cf2f16c9c95f0858eb (diff)
Added SupportsAutoRunAtStartup
-rw-r--r--MediaBrowser.Api/LiveTv/LiveTvService.cs42
-rw-r--r--MediaBrowser.Controller/IServerApplicationHost.cs6
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs9
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs9
-rw-r--r--MediaBrowser.Model/LiveTv/ProgramQuery.cs12
-rw-r--r--MediaBrowser.Model/System/SystemInfo.cs6
-rw-r--r--MediaBrowser.Mono.userprefs6
-rw-r--r--MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs32
-rw-r--r--MediaBrowser.Server.Mono/Native/NativeApp.cs5
-rw-r--r--MediaBrowser.ServerApplication/ApplicationHost.cs21
-rw-r--r--MediaBrowser.ServerApplication/Native/NativeApp.cs12
11 files changed, 146 insertions, 14 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 6cec2118b..e985fb615 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 f96c2536e..f3312d2cb 100644
--- a/MediaBrowser.Controller/IServerApplicationHost.cs
+++ b/MediaBrowser.Controller/IServerApplicationHost.cs
@@ -25,5 +25,11 @@ namespace MediaBrowser.Controller
/// </summary>
/// <value>The HTTP server URL prefix.</value>
string HttpServerUrlPrefix { get; }
+
+ /// <summary>
+ /// Gets a value indicating whether [supports automatic run at startup].
+ /// </summary>
+ /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
+ bool SupportsAutoRunAtStartup { get; }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
index 8676540fd..93de9d5c3 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs
@@ -11,7 +11,14 @@ namespace MediaBrowser.Controller.LiveTv
/// <returns>System.String.</returns>
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 9dfc7f828..bc4ed5493 100644
--- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
+++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs
@@ -11,7 +11,14 @@ namespace MediaBrowser.Controller.LiveTv
/// <returns>System.String.</returns>
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 c2a913bc8..36c06d4c0 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
{
/// <summary>
/// Class ProgramQuery.
@@ -17,6 +19,14 @@
/// <value>The user identifier.</value>
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 733c9b6e5..5fc5f363b 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -129,6 +129,12 @@ namespace MediaBrowser.Model.System
public bool HasUpdateAvailable { get; set; }
/// <summary>
+ /// Gets or sets a value indicating whether [supports automatic run at startup].
+ /// </summary>
+ /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
+ public bool SupportsAutoRunAtStartup { get; set; }
+
+ /// <summary>
/// Initializes a new instance of the <see cref="SystemInfo" /> class.
/// </summary>
public SystemInfo()
diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs
index 6269e1b78..c6c7831e6 100644
--- a/MediaBrowser.Mono.userprefs
+++ b/MediaBrowser.Mono.userprefs
@@ -1,8 +1,10 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Release Mono" />
- <MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Server.Mono\app.config">
+ <MonoDevelop.Ide.Workbench ActiveDocument="MediaBrowser.Server.Mono\Native\NativeApp.cs">
<Files>
- <File FileName="MediaBrowser.Server.Mono\app.config" Line="1" Column="1" />
+ <File FileName="MediaBrowser.Server.Mono\app.config" Line="14" Column="3" />
+ <File FileName="MediaBrowser.ServerApplication\ApplicationHost.cs" Line="189" Column="1" />
+ <File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="40" Column="17" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 131c5c0fb..332cbf016 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<LiveTvProgram> 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 b8c4447e5..deff79b4b 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 0e66f2caf..e02772883 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; }
+ }
+
/// <summary>
/// Runs the startup tasks.
/// </summary>
@@ -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);
}
+ /// <summary>
+ /// Configures the automatic run at startup.
+ /// </summary>
+ /// <param name="autorun">if set to <c>true</c> [autorun].</param>
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 c0d3e876a..646a7bc98 100644
--- a/MediaBrowser.ServerApplication/Native/NativeApp.cs
+++ b/MediaBrowser.ServerApplication/Native/NativeApp.cs
@@ -35,6 +35,18 @@ namespace MediaBrowser.ServerApplication.Native
}
/// <summary>
+ /// Gets a value indicating whether [supports automatic run at startup].
+ /// </summary>
+ /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value>
+ public static bool SupportsAutoRunAtStartup
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ /// <summary>
/// Gets a value indicating whether this instance can self update.
/// </summary>
/// <value><c>true</c> if this instance can self update; otherwise, <c>false</c>.</value>