diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs
index 5cd23a738..183b2bacb 100644
--- a/MediaBrowser.Api/LiveTv/LiveTvService.cs
+++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs
@@ -26,7 +26,7 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "Type", Description = "Optional filter by channel type.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public ChannelType? Type { get; set; }
- [ApiMember(Name = "UserId", Description = "Optional filter by channel user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string UserId { get; set; }
}
@@ -40,8 +40,17 @@ namespace MediaBrowser.Api.LiveTv
/// The id.
[ApiMember(Name = "Id", Description = "Channel Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Id { get; set; }
+
+ [ApiMember(Name = "UserId", Description = "Optional user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string UserId { get; set; }
}
+ [Route("/LiveTv/Recordings", "GET")]
+ [Api(Description = "Gets live tv recordings")]
+ public class GetRecordings : IReturn>
+ {
+ }
+
[Route("/LiveTv/Programs", "GET")]
[Api(Description = "Gets available live tv epgs..")]
public class GetPrograms : IReturn>
@@ -51,6 +60,9 @@ namespace MediaBrowser.Api.LiveTv
[ApiMember(Name = "ChannelIds", Description = "The channels to return guide information for.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ChannelIds { get; set; }
+
+ [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
+ public string UserId { get; set; }
}
public class LiveTvService : BaseApiService
@@ -106,9 +118,9 @@ namespace MediaBrowser.Api.LiveTv
public object Get(GetChannel request)
{
- var result = _liveTvManager.GetChannel(request.Id);
+ var result = _liveTvManager.GetChannelInfoDto(request.Id, request.UserId);
- return ToOptimizedResult(_liveTvManager.GetChannelInfoDto(result));
+ return ToOptimizedResult(result);
}
public object Get(GetPrograms request)
@@ -116,10 +128,18 @@ namespace MediaBrowser.Api.LiveTv
var result = _liveTvManager.GetPrograms(new ProgramQuery
{
ServiceName = request.ServiceName,
- ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray()
+ ChannelIdList = (request.ChannelIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToArray(),
+ UserId = request.UserId
});
return ToOptimizedResult(result);
}
+
+ public object Get(GetRecordings request)
+ {
+ var result = _liveTvManager.GetRecordings();
+
+ return ToOptimizedResult(result);
+ }
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index e7b5d733b..9e4981331 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -29,11 +29,10 @@ namespace MediaBrowser.Controller.LiveTv
QueryResult GetChannels(ChannelQuery query);
///
- /// Gets the channel information dto.
+ /// Gets the recordings.
///
- /// The information.
- /// ChannelInfoDto.
- ChannelInfoDto GetChannelInfoDto(Channel info);
+ /// QueryResult{RecordingInfoDto}.
+ QueryResult GetRecordings();
///
/// Gets the channel.
@@ -42,6 +41,14 @@ namespace MediaBrowser.Controller.LiveTv
/// Channel.
Channel GetChannel(string id);
+ ///
+ /// Gets the channel.
+ ///
+ /// The identifier.
+ /// The user identifier.
+ /// Channel.
+ ChannelInfoDto GetChannelInfoDto(string id, string userId);
+
///
/// Gets the programs.
///
diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs
index 8314b9170..2231b4eaa 100644
--- a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using MediaBrowser.Model.LiveTv;
namespace MediaBrowser.Controller.LiveTv
{
@@ -21,6 +22,12 @@ namespace MediaBrowser.Controller.LiveTv
///
public string Name { get; set; }
+ ///
+ /// Gets or sets the official rating.
+ ///
+ /// The official rating.
+ public string OfficialRating { get; set; }
+
///
/// Description of the progam.
///
@@ -41,6 +48,24 @@ namespace MediaBrowser.Controller.LiveTv
///
public List Genres { get; set; }
+ ///
+ /// Gets or sets the quality.
+ ///
+ /// The quality.
+ public ProgramVideoQuality Quality { get; set; }
+
+ ///
+ /// Gets or sets the original air date.
+ ///
+ /// The original air date.
+ public DateTime? OriginalAirDate { get; set; }
+
+ ///
+ /// Gets or sets the audio.
+ ///
+ /// The audio.
+ public ProgramAudio Audio { get; set; }
+
public ProgramInfo()
{
Genres = new List();
diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
index 0e4be52e3..f61bd9e78 100644
--- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
@@ -1,4 +1,5 @@
-using System;
+using MediaBrowser.Model.LiveTv;
+using System;
using System.Collections.Generic;
namespace MediaBrowser.Controller.LiveTv
@@ -47,9 +48,10 @@ namespace MediaBrowser.Controller.LiveTv
public DateTime EndDate { get; set; }
///
- /// Status of the recording.
+ /// Gets or sets the status.
///
- public string Status { get; set; } //TODO: Enum for status?? Difference NextPvr,Argus,...
+ /// The status.
+ public RecordingStatus Status { get; set; }
///
/// Gets or sets a value indicating whether this instance is recurring.
diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj
index e7003219a..6962cb470 100644
--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj
+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj
@@ -248,6 +248,9 @@
LiveTv\RecordingQuery.cs
+
+ LiveTv\RecordingStatus.cs
+
Logging\ILogger.cs
diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj
index f0d23c959..0bf2684bf 100644
--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj
+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj
@@ -235,6 +235,9 @@
LiveTv\RecordingQuery.cs
+
+ LiveTv\RecordingStatus.cs
+
Logging\ILogger.cs
diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
index c8d351bd0..f1d550e77 100644
--- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
+++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs
@@ -1,4 +1,5 @@
using System;
+using MediaBrowser.Model.Dto;
namespace MediaBrowser.Model.LiveTv
{
@@ -54,5 +55,11 @@ namespace MediaBrowser.Model.LiveTv
///
/// The type of the media.
public string MediaType { get; set; }
+
+ ///
+ /// Gets or sets the user data.
+ ///
+ /// The user data.
+ public UserItemDataDto UserData { get; set; }
}
}
diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs
index 15387d520..8b0976671 100644
--- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs
+++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs
@@ -27,6 +27,12 @@ namespace MediaBrowser.Model.LiveTv
///
/// The recording identifier.
public string RecordingId { get; set; }
+
+ ///
+ /// Gets or sets the official rating.
+ ///
+ /// The official rating.
+ public string OfficialRating { get; set; }
///
/// Gets or sets the name of the service.
@@ -59,9 +65,38 @@ namespace MediaBrowser.Model.LiveTv
///
public List Genres { get; set; }
+ ///
+ /// Gets or sets the quality.
+ ///
+ /// The quality.
+ public ProgramVideoQuality Quality { get; set; }
+
+ ///
+ /// Gets or sets the audio.
+ ///
+ /// The audio.
+ public ProgramAudio Audio { get; set; }
+
+ ///
+ /// Gets or sets the original air date.
+ ///
+ /// The original air date.
+ public DateTime? OriginalAirDate { get; set; }
+
public ProgramInfoDto()
{
Genres = new List();
}
}
+
+ public enum ProgramVideoQuality
+ {
+ StandardDefinition,
+ HighDefinition
+ }
+
+ public enum ProgramAudio
+ {
+ Stereo
+ }
}
\ No newline at end of file
diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.cs
index 1276ddb9e..ce0639aa0 100644
--- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs
+++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs
@@ -17,6 +17,12 @@
/// The channel identifier.
public string[] ChannelIdList { get; set; }
+ ///
+ /// Gets or sets the user identifier.
+ ///
+ /// The user identifier.
+ public string UserId { get; set; }
+
public ProgramQuery()
{
ChannelIdList = new string[] { };
diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
index 782652f37..8b0a28ed0 100644
--- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
+++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs
@@ -55,5 +55,11 @@ namespace MediaBrowser.Model.LiveTv
/// IsRecurring recording?
///
public bool IsRecurring { get; set; }
+
+ ///
+ /// Gets or sets the status.
+ ///
+ /// The status.
+ public RecordingStatus Status { get; set; }
}
}
\ No newline at end of file
diff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.cs
new file mode 100644
index 000000000..b8af8f6e2
--- /dev/null
+++ b/MediaBrowser.Model/LiveTv/RecordingStatus.cs
@@ -0,0 +1,13 @@
+
+namespace MediaBrowser.Model.LiveTv
+{
+ public enum RecordingStatus
+ {
+ Pending,
+ InProgress,
+ Completed,
+ CompletedWithError,
+ Conflicted,
+ Deleted
+ }
+}
diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj
index 1e94c6b5f..1cbdc60ef 100644
--- a/MediaBrowser.Model/MediaBrowser.Model.csproj
+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj
@@ -65,6 +65,7 @@
+
diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
index 791da74e0..fda5496c7 100644
--- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
+++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs
@@ -2,7 +2,11 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Controller.Dto;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
+using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.LiveTv;
@@ -28,6 +32,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private readonly IItemRepository _itemRepo;
private readonly IImageProcessor _imageProcessor;
+ private readonly IUserManager _userManager;
+ private readonly ILocalizationManager _localization;
+ private readonly IUserDataManager _userDataManager;
+ private readonly IDtoService _dtoService;
+
private readonly List _services = new List();
private List _channels = new List();
@@ -36,13 +45,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv
private readonly SemaphoreSlim _updateSemaphore = new SemaphoreSlim(1, 1);
- public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor)
+ public LiveTvManager(IServerApplicationPaths appPaths, IFileSystem fileSystem, ILogger logger, IItemRepository itemRepo, IImageProcessor imageProcessor, IUserManager userManager, ILocalizationManager localization, IUserDataManager userDataManager, IDtoService dtoService)
{
_appPaths = appPaths;
_fileSystem = fileSystem;
_logger = logger;
_itemRepo = itemRepo;
_imageProcessor = imageProcessor;
+ _userManager = userManager;
+ _localization = localization;
+ _userDataManager = userDataManager;
+ _dtoService = dtoService;
}
///
@@ -67,10 +80,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
/// Gets the channel info dto.
///
/// The info.
+ /// The user.
/// ChannelInfoDto.
- public ChannelInfoDto GetChannelInfoDto(Channel info)
+ public ChannelInfoDto GetChannelInfoDto(Channel info, User user)
{
- return new ChannelInfoDto
+ var dto = new ChannelInfoDto
{
Name = info.Name,
ServiceName = info.ServiceName,
@@ -81,6 +95,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
Id = info.Id.ToString("N"),
MediaType = info.MediaType
};
+
+ if (user != null)
+ {
+ dto.UserData = _dtoService.GetUserItemDataDto(_userDataManager.GetUserData(user.Id, info.GetUserDataKey()));
+ }
+
+ return dto;
}
private ILiveTvService GetService(ChannelInfo channel)
@@ -111,7 +132,28 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public QueryResult GetChannels(ChannelQuery query)
{
- var channels = _channels.OrderBy(i =>
+ var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId));
+
+ IEnumerable channels = _channels;
+
+ if (user != null)
+ {
+ channels = channels.Where(i => i.IsParentalAllowed(user, _localization))
+ .OrderBy(i =>
+ {
+ double number = 0;
+
+ if (!string.IsNullOrEmpty(i.ChannelNumber))
+ {
+ double.TryParse(i.ChannelNumber, out number);
+ }
+
+ return number;
+
+ });
+ }
+
+ var returnChannels = channels.OrderBy(i =>
{
double number = 0;
@@ -123,13 +165,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return number;
}).ThenBy(i => i.Name)
- .Select(GetChannelInfoDto)
+ .Select(i => GetChannelInfoDto(i, user))
.ToArray();
return new QueryResult
{
- Items = channels,
- TotalRecordCount = channels.Length
+ Items = returnChannels,
+ TotalRecordCount = returnChannels.Length
};
}
@@ -140,6 +182,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return _channels.FirstOrDefault(i => i.Id == guid);
}
+ public ChannelInfoDto GetChannelInfoDto(string id, string userId)
+ {
+ var channel = GetChannel(id);
+
+ var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(new Guid(userId));
+
+ return channel == null ? null : GetChannelInfoDto(channel, user);
+ }
+
private ProgramInfoDto GetProgramInfoDto(ProgramInfo program, Channel channel)
{
var id = GetInternalProgramIdId(channel.ServiceName, program.Id).ToString("N");
@@ -154,7 +205,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
Id = id,
Name = program.Name,
ServiceName = channel.ServiceName,
- StartDate = program.StartDate
+ StartDate = program.StartDate,
+ OfficialRating = program.OfficialRating,
+ Quality = program.Quality,
+ OriginalAirDate = program.OriginalAirDate,
+ Audio = program.Audio
};
}
@@ -367,7 +422,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv
StartDate = info.StartDate,
Id = id,
ExternalId = info.Id,
- ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N")
+ ChannelId = GetInternalChannelId(service.Name, info.ChannelId).ToString("N"),
+ Status = info.Status
};
if (!string.IsNullOrEmpty(info.ProgramId))
@@ -377,5 +433,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return dto;
}
+
+ public QueryResult GetRecordings()
+ {
+ var returnArray = _recordings.ToArray();
+
+ return new QueryResult
+ {
+ Items = returnArray,
+ TotalRecordCount = returnArray.Length
+ };
+ }
}
}
diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs
index cd6ec18e1..c53277d77 100644
--- a/MediaBrowser.ServerApplication/ApplicationHost.cs
+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs
@@ -294,7 +294,7 @@ namespace MediaBrowser.ServerApplication
DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataManager, ItemRepository, ImageProcessor);
RegisterSingleInstance(DtoService);
- LiveTvManager = new LiveTvManager(ApplicationPaths, FileSystemManager, Logger, ItemRepository, ImageProcessor);
+ LiveTvManager = new LiveTvManager(ApplicationPaths, FileSystemManager, Logger, ItemRepository, ImageProcessor, UserManager, LocalizationManager, UserDataManager, DtoService);
RegisterSingleInstance(LiveTvManager);
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));