diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs
index 62fcbd280e..8febe4a65d 100644
--- a/MediaBrowser.Api/BaseApiService.cs
+++ b/MediaBrowser.Api/BaseApiService.cs
@@ -1,13 +1,13 @@
-using System.IO;
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Net;
using MediaBrowser.Model.Logging;
+using ServiceStack.Web;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
-using ServiceStack.Web;
namespace MediaBrowser.Api
{
@@ -52,11 +52,6 @@ namespace MediaBrowser.Api
return ResultFactory.GetOptimizedResult(Request, result);
}
- protected object ToStreamResult(Stream stream, string contentType)
- {
- return ResultFactory.GetResult(stream, contentType);
- }
-
///
/// To the optimized result using cache.
///
diff --git a/MediaBrowser.Api/Library/LibraryHelpers.cs b/MediaBrowser.Api/Library/LibraryHelpers.cs
index e40cb7dd46..3836a08602 100644
--- a/MediaBrowser.Api/Library/LibraryHelpers.cs
+++ b/MediaBrowser.Api/Library/LibraryHelpers.cs
@@ -68,8 +68,6 @@ namespace MediaBrowser.Api.Library
var rootFolderPath = user != null ? user.RootFolderPath : appPaths.DefaultUserViewsPath;
var virtualFolderPath = Path.Combine(rootFolderPath, virtualFolderName);
- ValidateNewMediaPath(fileSystem, rootFolderPath, path);
-
var shortcutFilename = Path.GetFileNameWithoutExtension(path);
var lnk = Path.Combine(virtualFolderPath, shortcutFilename + ShortcutFileExtension);
@@ -82,73 +80,5 @@ namespace MediaBrowser.Api.Library
fileSystem.CreateShortcut(lnk, path);
}
-
- ///
- /// Validates that a new media path can be added
- ///
- /// The file system.
- /// The current view root folder path.
- /// The media path.
- ///
- ///
- private static void ValidateNewMediaPath(IFileSystem fileSystem, string currentViewRootFolderPath, string mediaPath)
- {
- var pathsInCurrentVIew = Directory.EnumerateFiles(currentViewRootFolderPath, ShortcutFileSearch, SearchOption.AllDirectories)
- .Select(fileSystem.ResolveShortcut)
- .ToList();
-
- // Don't allow duplicate sub-paths within the same user library, or it will result in duplicate items
- // See comments in IsNewPathValid
- var duplicate = pathsInCurrentVIew
- .FirstOrDefault(p => !IsNewPathValid(fileSystem, mediaPath, p));
-
- if (!string.IsNullOrEmpty(duplicate))
- {
- throw new ArgumentException(string.Format("The path cannot be added to the library because {0} already exists.", duplicate));
- }
-
- // Make sure the current root folder doesn't already have a shortcut to the same path
- duplicate = pathsInCurrentVIew
- .FirstOrDefault(p => string.Equals(mediaPath, p, StringComparison.OrdinalIgnoreCase));
-
- if (!string.IsNullOrEmpty(duplicate))
- {
- throw new ArgumentException(string.Format("The path {0} already exists in the library", mediaPath));
- }
- }
-
- ///
- /// Validates that a new path can be added based on an existing path
- ///
- /// The file system.
- /// The new path.
- /// The existing path.
- /// true if [is new path valid] [the specified new path]; otherwise, false.
- private static bool IsNewPathValid(IFileSystem fileSystem, string newPath, string existingPath)
- {
- // Example: D:\Movies is the existing path
- // D:\ cannot be added
- // Neither can D:\Movies\Kids
- // A D:\Movies duplicate is ok here since that will be caught later
-
- if (string.Equals(newPath, existingPath, StringComparison.OrdinalIgnoreCase))
- {
- return true;
- }
-
- // If enforceSubPathRestriction is true, validate the D:\Movies\Kids scenario
- if (fileSystem.ContainsSubPath(existingPath, newPath))
- {
- return false;
- }
-
- // Validate the D:\ scenario
- if (fileSystem.ContainsSubPath(newPath, existingPath))
- {
- return false;
- }
-
- return true;
- }
}
}
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 50e7319b9e..f92c4932e0 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -154,6 +154,23 @@ namespace MediaBrowser.Api.LiveTv
public string MaxEndDate { get; set; }
}
+ [Route("/LiveTv/Programs/Recommended", "GET")]
+ [Api(Description = "Gets available live tv epgs..")]
+ public class GetRecommendedPrograms : IReturn>
+ {
+ [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")]
+ public string UserId { get; set; }
+
+ [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
+ public int? Limit { get; set; }
+
+ [ApiMember(Name = "IsAiring", Description = "Optional. Filter by programs that are currently airing, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
+ public bool? IsAiring { get; set; }
+
+ [ApiMember(Name = "HasAired", Description = "Optional. Filter by programs that have completed airing, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
+ public bool? HasAired { get; set; }
+ }
+
[Route("/LiveTv/Programs/{Id}", "GET")]
[Api(Description = "Gets a live tv program")]
public class GetProgram : IReturn
@@ -331,6 +348,21 @@ namespace MediaBrowser.Api.LiveTv
return ToOptimizedResult(result);
}
+ public object Get(GetRecommendedPrograms request)
+ {
+ var query = new RecommendedProgramQuery
+ {
+ UserId = request.UserId,
+ IsAiring = request.IsAiring,
+ Limit = request.Limit,
+ HasAired = request.HasAired
+ };
+
+ var result = _liveTvManager.GetRecommendedPrograms(query, CancellationToken.None).Result;
+
+ return ToOptimizedResult(result);
+ }
+
public object Post(GetPrograms request)
{
return Get(request);
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs
index 329fd25768..270067685f 100644
--- a/MediaBrowser.Api/Playback/BaseStreamingService.cs
+++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs
@@ -1,6 +1,5 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
-using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
@@ -734,7 +733,7 @@ namespace MediaBrowser.Api.Playback
return "-";
}
- var type = InputType.AudioFile;
+ var type = InputType.File;
var inputPath = new[] { state.MediaPath };
@@ -1044,6 +1043,7 @@ namespace MediaBrowser.Api.Playback
}
itemId = recording.Id;
+ //state.RunTimeTicks = recording.RunTimeTicks;
state.SendInputOverStandardInput = recording.RecordingInfo.Status == RecordingStatus.InProgress;
}
else if (string.Equals(request.Type, "Channel", StringComparison.OrdinalIgnoreCase))
@@ -1092,6 +1092,7 @@ namespace MediaBrowser.Api.Playback
: video.PlayableStreamFileNames.ToList();
}
+ state.RunTimeTicks = item.RunTimeTicks;
itemId = item.Id;
}
diff --git a/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs b/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs
index d5bf223624..a64cdb119e 100644
--- a/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/AudioHlsService.cs
@@ -1,9 +1,9 @@
using MediaBrowser.Common.IO;
-using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.MediaInfo;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
index 8ac8dc9fc2..f244886dc4 100644
--- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
+++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs
@@ -1,11 +1,11 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
-using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.MediaInfo;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Dto;
@@ -75,18 +75,23 @@ namespace MediaBrowser.Api.Playback.Hls
/// System.Object.
protected object ProcessRequest(StreamRequest request)
{
- var state = GetState(request, CancellationToken.None).Result;
-
- return ProcessRequestAsync(state).Result;
+ return ProcessRequestAsync(request).Result;
}
///
/// Processes the request async.
///
- /// The state.
+ /// The request.
/// Task{System.Object}.
- public async Task