diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-11-25 21:53:48 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-11-25 21:53:48 -0500 |
| commit | 6a9ed5f87f2d9ec0e07d860d36666f0fea2e1e45 (patch) | |
| tree | 0f4ef99808685a2b97e27304c33d49a965162757 | |
| parent | 3b4c35583808a84af2ee636a00fea8355e645b2e (diff) | |
added recording status enum
| -rw-r--r-- | MediaBrowser.Api/LiveTv/LiveTvService.cs | 28 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 15 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ProgramInfo.cs | 25 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/RecordingInfo.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj | 3 | ||||
| -rw-r--r-- | MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj | 3 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/ChannelInfoDto.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/ProgramInfoDto.cs | 35 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/ProgramQuery.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/RecordingInfoDto.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/RecordingStatus.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.Model/MediaBrowser.Model.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 85 | ||||
| -rw-r--r-- | MediaBrowser.ServerApplication/ApplicationHost.cs | 2 |
14 files changed, 216 insertions, 21 deletions
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 /// <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.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<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. @@ -43,6 +42,14 @@ namespace MediaBrowser.Controller.LiveTv 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> /// <param name="query">The query.</param> 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 { @@ -22,6 +23,12 @@ namespace MediaBrowser.Controller.LiveTv 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> public string Description { get; set; } @@ -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.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; } /// <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.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 @@ <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.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 @@ <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.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 /// </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.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 /// </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 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 @@ /// <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.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? /// </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 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 @@ <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.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<ILiveTvService> _services = new List<ILiveTvService>(); private List<Channel> _channels = new List<Channel>(); @@ -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; } /// <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.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<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.LiveTv return 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.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<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.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)); |
