The Free Software Media System - Server Backend & API
added recording status enum
Luke Pulverenti6a9ed5f87f2d
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.csindex 5cd23a738f..183b2bacb6 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/// <value>The id.</value>[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<QueryResult<RecordingInfoDto>>+ {+ }+[Route("/LiveTv/Programs", "GET")][Api(Description = "Gets available live tv epgs..")]public class GetPrograms : IReturn<QueryResult<ProgramInfoDto>>@@ -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.LiveTvpublic 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.LiveTvvar 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 filediff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.csindex e7b5d733b9..9e49813318 100644--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs@@ -29,11 +29,10 @@ namespace MediaBrowser.Controller.LiveTvQueryResult<ChannelInfoDto> GetChannels(ChannelQuery query);/// <summary>- /// Gets the channel information dto.+ /// Gets the recordings./// </summary>- /// <param name="info">The information.</param>- /// <returns>ChannelInfoDto.</returns>- ChannelInfoDto GetChannelInfoDto(Channel info);+ /// <returns>QueryResult{RecordingInfoDto}.</returns>+ QueryResult<RecordingInfoDto> GetRecordings();/// <summary>/// Gets the channel.@@ -42,6 +41,14 @@ namespace MediaBrowser.Controller.LiveTv/// <returns>Channel.</returns>Channel GetChannel(string id);+ /// <summary>+ /// Gets the channel.+ /// </summary>+ /// <param name="id">The identifier.</param>+ /// <param name="userId">The user identifier.</param>+ /// <returns>Channel.</returns>+ ChannelInfoDto GetChannelInfoDto(string id, string userId);+/// <summary>/// Gets the programs./// </summary>diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.csindex 8314b91705..2231b4eaa9 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/// </summary>public string Name { get; set; }+ /// <summary>+ /// Gets or sets the official rating.+ /// </summary>+ /// <value>The official rating.</value>+ public string OfficialRating { get; set; }+/// <summary>/// Description of the progam./// </summary>@@ -41,6 +48,24 @@ namespace MediaBrowser.Controller.LiveTv/// </summary>public List<string> Genres { get; set; }+ /// <summary>+ /// Gets or sets the quality.+ /// </summary>+ /// <value>The quality.</value>+ public ProgramVideoQuality Quality { get; set; }++ /// <summary>+ /// Gets or sets the original air date.+ /// </summary>+ /// <value>The original air date.</value>+ public DateTime? OriginalAirDate { get; set; }++ /// <summary>+ /// Gets or sets the audio.+ /// </summary>+ /// <value>The audio.</value>+ public ProgramAudio Audio { get; set; }+public ProgramInfo(){Genres = new List<string>();diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.csindex 0e4be52e3a..f61bd9e785 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.LiveTvpublic DateTime EndDate { get; set; }/// <summary>- /// Status of the recording.+ /// Gets or sets the status./// </summary>- public string Status { get; set; } //TODO: Enum for status?? Difference NextPvr,Argus,...+ /// <value>The status.</value>+ public RecordingStatus Status { get; set; }/// <summary>/// 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.csprojindex e7003219a4..6962cb470b 100644--- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj+++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj@@ -248,6 +248,9 @@<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingQuery.cs"><Link>LiveTv\RecordingQuery.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\LiveTv\RecordingStatus.cs">+ <Link>LiveTv\RecordingStatus.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs"><Link>Logging\ILogger.cs</Link></Compile>diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csprojindex f0d23c959b..0bf2684bfd 100644--- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj+++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj@@ -235,6 +235,9 @@<Compile Include="..\MediaBrowser.Model\LiveTv\RecordingQuery.cs"><Link>LiveTv\RecordingQuery.cs</Link></Compile>+ <Compile Include="..\MediaBrowser.Model\LiveTv\RecordingStatus.cs">+ <Link>LiveTv\RecordingStatus.cs</Link>+ </Compile><Compile Include="..\MediaBrowser.Model\Logging\ILogger.cs"><Link>Logging\ILogger.cs</Link></Compile>diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.csindex c8d351bd05..f1d550e77a 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/// </summary>/// <value>The type of the media.</value>public string MediaType { get; set; }++ /// <summary>+ /// Gets or sets the user data.+ /// </summary>+ /// <value>The user data.</value>+ public UserItemDataDto UserData { get; set; }}}diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.csindex 15387d5204..8b0976671d 100644--- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs@@ -27,6 +27,12 @@ namespace MediaBrowser.Model.LiveTv/// </summary>/// <value>The recording identifier.</value>public string RecordingId { get; set; }++ /// <summary>+ /// Gets or sets the official rating.+ /// </summary>+ /// <value>The official rating.</value>+ public string OfficialRating { get; set; }/// <summary>/// Gets or sets the name of the service.@@ -59,9 +65,38 @@ namespace MediaBrowser.Model.LiveTv/// </summary>public List<string> Genres { get; set; }+ /// <summary>+ /// Gets or sets the quality.+ /// </summary>+ /// <value>The quality.</value>+ public ProgramVideoQuality Quality { get; set; }++ /// <summary>+ /// Gets or sets the audio.+ /// </summary>+ /// <value>The audio.</value>+ public ProgramAudio Audio { get; set; }++ /// <summary>+ /// Gets or sets the original air date.+ /// </summary>+ /// <value>The original air date.</value>+ public DateTime? OriginalAirDate { get; set; }+public ProgramInfoDto(){Genres = new List<string>();}}++ public enum ProgramVideoQuality+ {+ StandardDefinition,+ HighDefinition+ }++ public enum ProgramAudio+ {+ Stereo+ }}\ No newline at end of filediff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.csindex 1276ddb9e4..ce0639aa0e 100644--- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs+++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs@@ -17,6 +17,12 @@/// <value>The channel identifier.</value>public string[] ChannelIdList { get; set; }+ /// <summary>+ /// Gets or sets the user identifier.+ /// </summary>+ /// <value>The user identifier.</value>+ public string UserId { get; set; }+public ProgramQuery(){ChannelIdList = new string[] { };diff --git a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs b/MediaBrowser.Model/LiveTv/RecordingInfoDto.csindex 782652f37b..8b0a28ed0c 100644--- a/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs+++ b/MediaBrowser.Model/LiveTv/RecordingInfoDto.cs@@ -55,5 +55,11 @@ namespace MediaBrowser.Model.LiveTv/// IsRecurring recording?/// </summary>public bool IsRecurring { get; set; }++ /// <summary>+ /// Gets or sets the status.+ /// </summary>+ /// <value>The status.</value>+ public RecordingStatus Status { get; set; }}}\ No newline at end of filediff --git a/MediaBrowser.Model/LiveTv/RecordingStatus.cs b/MediaBrowser.Model/LiveTv/RecordingStatus.csnew file mode 100644index 0000000000..b8af8f6e22--- /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.csprojindex 1e94c6b5fb..1cbdc60efa 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -65,6 +65,7 @@<Compile Include="LiveTv\ProgramInfoDto.cs" /><Compile Include="LiveTv\ProgramQuery.cs" /><Compile Include="LiveTv\RecordingQuery.cs" />+ <Compile Include="LiveTv\RecordingStatus.cs" /><Compile Include="Providers\ImageProviderInfo.cs" /><Compile Include="Providers\RemoteImageInfo.cs" /><Compile Include="Dto\StudioDto.cs" />diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.csindex 791da74e05..fda5496c76 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.LiveTvprivate 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<ILiveTvService> _services = new List<ILiveTvService>();private List<Channel> _channels = new List<Channel>();@@ -36,13 +45,17 @@ namespace MediaBrowser.Server.Implementations.LiveTvprivate 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;}/// <summary>@@ -67,10 +80,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv/// Gets the channel info dto./// </summary>/// <param name="info">The info.</param>+ /// <param name="user">The user.</param>/// <returns>ChannelInfoDto.</returns>- 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.LiveTvId = 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.LiveTvpublic QueryResult<ChannelInfoDto> GetChannels(ChannelQuery query){- var channels = _channels.OrderBy(i =>+ var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(new Guid(query.UserId));++ IEnumerable<Channel> 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.LiveTvreturn number;}).ThenBy(i => i.Name)- .Select(GetChannelInfoDto)+ .Select(i => GetChannelInfoDto(i, user)).ToArray();return new QueryResult<ChannelInfoDto>{- Items = channels,- TotalRecordCount = channels.Length+ Items = returnChannels,+ TotalRecordCount = returnChannels.Length};}@@ -140,6 +182,15 @@ namespace MediaBrowser.Server.Implementations.LiveTvreturn _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.LiveTvId = 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.LiveTvStartDate = 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.LiveTvreturn dto;}++ public QueryResult<RecordingInfoDto> GetRecordings()+ {+ var returnArray = _recordings.ToArray();++ return new QueryResult<RecordingInfoDto>+ {+ Items = returnArray,+ TotalRecordCount = returnArray.Length+ };+ }}}diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.csindex cd6ec18e13..c53277d778 100644--- a/MediaBrowser.ServerApplication/ApplicationHost.cs+++ b/MediaBrowser.ServerApplication/ApplicationHost.cs@@ -294,7 +294,7 @@ namespace MediaBrowser.ServerApplicationDtoService = 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));