diff options
| -rw-r--r-- | MediaBrowser.Api/LiveTv/LiveTvService.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 14 | ||||
| -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/ApiClient/IApiClient.cs | 14 | ||||
| -rw-r--r-- | MediaBrowser.Model/Dto/BaseItemDto.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/ChannelInfoDto.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/ProgramInfoDto.cs | 250 | ||||
| -rw-r--r-- | MediaBrowser.Model/LiveTv/TimerInfoDto.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Model/MediaBrowser.Model.csproj | 1 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/Dto/DtoService.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs | 82 | ||||
| -rw-r--r-- | MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 89 |
13 files changed, 97 insertions, 384 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 86d8b9f99..c474642d5 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -161,7 +161,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/Programs", "GET,POST", Summary = "Gets available live tv epgs..")] [Authenticated] - public class GetPrograms : IReturn<QueryResult<ProgramInfoDto>> + public class GetPrograms : IReturn<QueryResult<BaseItemDto>> { [ApiMember(Name = "ChannelIds", Description = "The channels to return guide information for.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")] public string ChannelIds { get; set; } @@ -208,7 +208,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/Programs/Recommended", "GET", Summary = "Gets available live tv epgs..")] [Authenticated] - public class GetRecommendedPrograms : IReturn<QueryResult<ProgramInfoDto>> + public class GetRecommendedPrograms : IReturn<QueryResult<BaseItemDto>> { [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")] public string UserId { get; set; } @@ -231,7 +231,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/Programs/{Id}", "GET", Summary = "Gets a live tv program")] [Authenticated] - public class GetProgram : IReturn<ProgramInfoDto> + public class GetProgram : IReturn<BaseItemDto> { [ApiMember(Name = "Id", Description = "Program Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] public string Id { get; set; } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index e84fe902d..3aa1f66ef 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="cancellationToken">The cancellation token.</param> /// <param name="user">The user.</param> /// <returns>Task{ProgramInfoDto}.</returns> - Task<ProgramInfoDto> GetProgram(string id, CancellationToken cancellationToken, User user = null); + Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null); /// <summary> /// Gets the programs. @@ -178,7 +178,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="query">The query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>IEnumerable{ProgramInfo}.</returns> - Task<QueryResult<ProgramInfoDto>> GetPrograms(ProgramQuery query, CancellationToken cancellationToken); + Task<QueryResult<BaseItemDto>> GetPrograms(ProgramQuery query, CancellationToken cancellationToken); /// <summary> /// Updates the timer. @@ -240,7 +240,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="query">The query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{QueryResult{ProgramInfoDto}}.</returns> - Task<QueryResult<ProgramInfoDto>> GetRecommendedPrograms(RecommendedProgramQuery query, + Task<QueryResult<BaseItemDto>> GetRecommendedPrograms(RecommendedProgramQuery query, CancellationToken cancellationToken); /// <summary> @@ -329,5 +329,13 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="dto">The dto.</param> /// <param name="user">The user.</param> void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null); + + /// <summary> + /// Adds the information to program dto. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="dto">The dto.</param> + /// <param name="user">The user.</param> + void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, User user = null); } } diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index a63b0a7c6..de9360e40 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -743,9 +743,6 @@ <Compile Include="..\MediaBrowser.Model\LiveTv\ProgramAudio.cs"> <Link>LiveTv\ProgramAudio.cs</Link> </Compile> - <Compile Include="..\MediaBrowser.Model\LiveTv\ProgramInfoDto.cs"> - <Link>LiveTv\ProgramInfoDto.cs</Link> - </Compile> <Compile Include="..\MediaBrowser.Model\LiveTv\ProgramQuery.cs"> <Link>LiveTv\ProgramQuery.cs</Link> </Compile> diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 036064238..ec7c3be5c 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -699,9 +699,6 @@ <Compile Include="..\MediaBrowser.Model\LiveTv\ProgramAudio.cs"> <Link>LiveTv\ProgramAudio.cs</Link> </Compile> - <Compile Include="..\MediaBrowser.Model\LiveTv\ProgramInfoDto.cs"> - <Link>LiveTv\ProgramInfoDto.cs</Link> - </Compile> <Compile Include="..\MediaBrowser.Model\LiveTv\ProgramQuery.cs"> <Link>LiveTv\ProgramQuery.cs</Link> </Compile> diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index 71ac0b14e..e52e7535b 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -930,14 +930,6 @@ namespace MediaBrowser.Model.ApiClient string GetImageUrl(ChannelInfoDto item, ImageOptions options); /// <summary> - /// Gets the image URL. - /// </summary> - /// <param name="item">The item.</param> - /// <param name="options">The options.</param> - /// <returns>System.String.</returns> - string GetImageUrl(ProgramInfoDto item, ImageOptions options); - - /// <summary> /// Gets the subtitle URL. /// </summary> /// <param name="options">The options.</param> @@ -1111,7 +1103,7 @@ namespace MediaBrowser.Model.ApiClient /// <param name="query">The query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{QueryResult{ProgramInfoDto}}.</returns> - Task<QueryResult<ProgramInfoDto>> GetLiveTvProgramsAsync(ProgramQuery query, CancellationToken cancellationToken = default(CancellationToken)); + Task<QueryResult<BaseItemDto>> GetLiveTvProgramsAsync(ProgramQuery query, CancellationToken cancellationToken = default(CancellationToken)); /// <summary> /// Gets the live tv program asynchronous. @@ -1120,7 +1112,7 @@ namespace MediaBrowser.Model.ApiClient /// <param name="userId">The user identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{ProgramInfoDto}.</returns> - Task<ProgramInfoDto> GetLiveTvProgramAsync(string id, string userId, CancellationToken cancellationToken = default(CancellationToken)); + Task<BaseItemDto> GetLiveTvProgramAsync(string id, string userId, CancellationToken cancellationToken = default(CancellationToken)); /// <summary> /// Gets the recommended live tv programs asynchronous. @@ -1128,7 +1120,7 @@ namespace MediaBrowser.Model.ApiClient /// <param name="query">The query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{QueryResult{ProgramInfoDto}}.</returns> - Task<QueryResult<ProgramInfoDto>> GetRecommendedLiveTvProgramsAsync(RecommendedProgramQuery query, CancellationToken cancellationToken = default(CancellationToken)); + Task<QueryResult<BaseItemDto>> GetRecommendedLiveTvProgramsAsync(RecommendedProgramQuery query, CancellationToken cancellationToken = default(CancellationToken)); /// <summary> /// Creates the live tv timer asynchronous. diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 0f6ce4334..fb157e9ae 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -1175,5 +1175,11 @@ namespace MediaBrowser.Model.Dto /// <value><c>true</c> if this instance is premiere; otherwise, <c>false</c>.</value> public bool? IsPremiere { get; set; } + /// <summary> + /// Gets or sets the timer identifier. + /// </summary> + /// <value>The timer identifier.</value> + public string TimerId { get; set; } + } } diff --git a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs index 667ad4f14..fd901f29e 100644 --- a/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/ChannelInfoDto.cs @@ -97,7 +97,7 @@ namespace MediaBrowser.Model.LiveTv /// Gets or sets the now playing program. /// </summary> /// <value>The now playing program.</value> - public ProgramInfoDto CurrentProgram { get; set; } + public BaseItemDto CurrentProgram { get; set; } /// <summary> /// Gets or sets the primary image aspect ratio, after image enhancements. diff --git a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs b/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs deleted file mode 100644 index 06136459f..000000000 --- a/MediaBrowser.Model/LiveTv/ProgramInfoDto.cs +++ /dev/null @@ -1,250 +0,0 @@ -using MediaBrowser.Model.Dto; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.Extensions; -using MediaBrowser.Model.Library; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics; -using System.Runtime.Serialization; - -namespace MediaBrowser.Model.LiveTv -{ - [DebuggerDisplay("Name = {Name}, StartTime = {StartDate}, EndTime = {EndDate}")] - public class ProgramInfoDto : IHasPropertyChangedEvent, IItemDto, IHasServerId - { - /// <summary> - /// Id of the program. - /// </summary> - public string Id { get; set; } - - /// <summary> - /// Gets or sets the primary image aspect ratio. - /// </summary> - /// <value>The primary image aspect ratio.</value> - public double? PrimaryImageAspectRatio { get; set; } - - /// <summary> - /// Gets or sets the server identifier. - /// </summary> - /// <value>The server identifier.</value> - public string ServerId { get; set; } - - /// <summary> - /// Gets or sets the original primary image aspect ratio. - /// </summary> - /// <value>The original primary image aspect ratio.</value> - public double? OriginalPrimaryImageAspectRatio { get; set; } - - /// <summary> - /// Gets or sets the type of the media. - /// </summary> - /// <value>The type of the media.</value> - public string MediaType { get; set; } - - /// <summary> - /// Gets or sets the timer identifier. - /// </summary> - /// <value>The timer identifier.</value> - public string TimerId { get; set; } - - /// <summary> - /// Gets or sets the series timer identifier. - /// </summary> - /// <value>The series timer identifier.</value> - public string SeriesTimerId { get; set; } - - /// <summary> - /// Gets or sets the external identifier. - /// </summary> - /// <value>The external identifier.</value> - public string ExternalId { get; set; } - - /// <summary> - /// Gets or sets the channel identifier. - /// </summary> - /// <value>The channel identifier.</value> - public string ChannelId { get; set; } - - /// <summary> - /// Gets or sets the channel primary image tag. - /// </summary> - /// <value>The channel primary image tag.</value> - public string ChannelPrimaryImageTag { get; set; } - - /// <summary> - /// Gets or sets the play access. - /// </summary> - /// <value>The play access.</value> - public PlayAccess PlayAccess { get; set; } - - /// <summary> - /// Gets or sets the name of the channel. - /// </summary> - /// <value>The name of the channel.</value> - public string ChannelName { get; set; } - - /// <summary> - /// Gets or sets the community rating. - /// </summary> - /// <value>The community rating.</value> - public float? CommunityRating { 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 production year. - /// </summary> - /// <value>The production year.</value> - public int? ProductionYear { get; set; } - - /// <summary> - /// Gets or sets the name of the service. - /// </summary> - /// <value>The name of the service.</value> - public string ServiceName { get; set; } - - /// <summary> - /// Name of the program - /// </summary> - public string Name { get; set; } - - /// <summary> - /// Overview of the recording. - /// </summary> - public string Overview { get; set; } - - /// <summary> - /// The start date of the program, in UTC. - /// </summary> - public DateTime StartDate { get; set; } - - /// <summary> - /// The end date of the program, in UTC. - /// </summary> - public DateTime EndDate { get; set; } - - /// <summary> - /// Genre of the program. - /// </summary> - public List<string> Genres { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is hd. - /// </summary> - /// <value><c>true</c> if this instance is hd; otherwise, <c>false</c>.</value> - public bool? IsHD { 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; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is repeat. - /// </summary> - /// <value><c>true</c> if this instance is repeat; otherwise, <c>false</c>.</value> - public bool IsRepeat { get; set; } - - /// <summary> - /// Gets or sets the episode title. - /// </summary> - /// <value>The episode title.</value> - public string EpisodeTitle { get; set; } - - /// <summary> - /// Gets or sets the image tags. - /// </summary> - /// <value>The image tags.</value> - public Dictionary<ImageType, string> ImageTags { get; set; } - - /// <summary> - /// Gets or sets the user data. - /// </summary> - /// <value>The user data.</value> - public UserItemDataDto UserData { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is movie. - /// </summary> - /// <value><c>true</c> if this instance is movie; otherwise, <c>false</c>.</value> - public bool IsMovie { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is sports. - /// </summary> - /// <value><c>true</c> if this instance is sports; otherwise, <c>false</c>.</value> - public bool IsSports { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is series. - /// </summary> - /// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value> - public bool IsSeries { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is live. - /// </summary> - /// <value><c>true</c> if this instance is live; otherwise, <c>false</c>.</value> - public bool IsLive { get; set; } - - /// <summary> - /// Gets or sets the type. - /// </summary> - /// <value>The type.</value> - public string Type { get; set; } - - /// <summary> - /// Gets or sets the run time ticks. - /// </summary> - /// <value>The run time ticks.</value> - public long? RunTimeTicks { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is news. - /// </summary> - /// <value><c>true</c> if this instance is news; otherwise, <c>false</c>.</value> - public bool IsNews { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is kids. - /// </summary> - /// <value><c>true</c> if this instance is kids; otherwise, <c>false</c>.</value> - public bool IsKids { get; set; } - - /// <summary> - /// Gets or sets a value indicating whether this instance is premiere. - /// </summary> - /// <value><c>true</c> if this instance is premiere; otherwise, <c>false</c>.</value> - public bool IsPremiere { get; set; } - - /// <summary> - /// Gets a value indicating whether this instance has primary image. - /// </summary> - /// <value><c>true</c> if this instance has primary image; otherwise, <c>false</c>.</value> - [IgnoreDataMember] - public bool HasPrimaryImage - { - get { return ImageTags != null && ImageTags.ContainsKey(ImageType.Primary); } - } - - public ProgramInfoDto() - { - Genres = new List<string>(); - ImageTags = new Dictionary<ImageType, string>(); - } - - public event PropertyChangedEventHandler PropertyChanged; - } -}
\ No newline at end of file diff --git a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs index 16cac945f..c33535a3d 100644 --- a/MediaBrowser.Model/LiveTv/TimerInfoDto.cs +++ b/MediaBrowser.Model/LiveTv/TimerInfoDto.cs @@ -1,4 +1,6 @@ -namespace MediaBrowser.Model.LiveTv +using MediaBrowser.Model.Dto; + +namespace MediaBrowser.Model.LiveTv { public class TimerInfoDto : BaseTimerInfoDto { @@ -30,7 +32,7 @@ /// Gets or sets the program information. /// </summary> /// <value>The program information.</value> - public ProgramInfoDto ProgramInfo { get; set; } + public BaseItemDto ProgramInfo { get; set; } } } diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index c567c1f6a..d134cb2e3 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -259,7 +259,6 @@ <Compile Include="LiveTv\LiveTvTunerInfoDto.cs" /> <Compile Include="LiveTv\LiveTvTunerStatus.cs" /> <Compile Include="LiveTv\ProgramAudio.cs" /> - <Compile Include="LiveTv\ProgramInfoDto.cs" /> <Compile Include="LiveTv\ProgramQuery.cs" /> <Compile Include="LiveTv\RecommendedProgramQuery.cs" /> <Compile Include="LiveTv\RecordingGroupQuery.cs" /> diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index cf56fc9ce..5853b5b75 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -357,6 +357,11 @@ namespace MediaBrowser.Server.Implementations.Dto _livetvManager().AddInfoToRecordingDto(item, dto, user); } + else if (item is LiveTvProgram) + { + _livetvManager().AddInfoToProgramDto(item, dto, user); + } + return dto; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index 939d057cb..f24fe0019 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -68,7 +68,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (program != null) { - dto.ProgramInfo = GetProgramInfoDto(program, channel); + dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions()); dto.ProgramInfo.TimerId = dto.Id; dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId; @@ -238,77 +238,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (currentProgram != null) { - dto.CurrentProgram = GetProgramInfoDto(currentProgram, info, user); - } - - return dto; - } - - public ProgramInfoDto GetProgramInfoDto(LiveTvProgram item, LiveTvChannel channel, User user = null) - { - var dto = new ProgramInfoDto - { - Id = GetInternalProgramId(item.ServiceName, item.ExternalId).ToString("N"), - ChannelId = GetInternalChannelId(item.ServiceName, item.ExternalChannelId).ToString("N"), - Overview = item.Overview, - Genres = item.Genres, - ExternalId = item.ExternalId, - Name = item.Name, - ServiceName = item.ServiceName, - StartDate = item.StartDate, - OfficialRating = item.OfficialRating, - IsHD = item.IsHD, - OriginalAirDate = item.OriginalAirDate, - Audio = item.Audio, - CommunityRating = GetClientCommunityRating(item.CommunityRating), - IsRepeat = item.IsRepeat, - EpisodeTitle = item.EpisodeTitle, - IsMovie = item.IsMovie, - IsSeries = item.IsSeries, - IsSports = item.IsSports, - IsLive = item.IsLive, - IsNews = item.IsNews, - IsKids = item.IsKids, - IsPremiere = item.IsPremiere, - Type = "Program", - MediaType = item.MediaType, - ServerId = _appHost.SystemId, - ProductionYear = item.ProductionYear - }; - - if (item.EndDate.HasValue) - { - dto.EndDate = item.EndDate.Value; - - dto.RunTimeTicks = (item.EndDate.Value - item.StartDate).Ticks; - } - - if (channel != null) - { - dto.ChannelName = channel.Name; - - if (!string.IsNullOrEmpty(channel.PrimaryImagePath)) - { - dto.ChannelPrimaryImageTag = GetImageTag(channel); - } - } - - var imageTag = GetImageTag(item); - - if (imageTag != null) - { - dto.ImageTags[ImageType.Primary] = imageTag; - _dtoService.AttachPrimaryImageAspectRatio(dto, item, new List<ItemFields> - { - ItemFields.PrimaryImageAspectRatio - }); - } - - if (user != null) - { - dto.UserData = _userDataManager.GetUserDataDto(item, user); - - dto.PlayAccess = item.GetPlayAccess(user); + dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, new DtoOptions(), user); } return dto; @@ -365,7 +295,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return name.ToLower().GetMBId(typeof(ILiveTvRecording)); } - public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, ILiveTvManager liveTv, CancellationToken cancellationToken) + public async Task<TimerInfo> GetTimerInfo(TimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken) { var info = new TimerInfo { @@ -405,7 +335,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (!string.IsNullOrEmpty(dto.ProgramId) && string.IsNullOrEmpty(info.ProgramId)) { - var program = await liveTv.GetProgram(dto.ProgramId, cancellationToken).ConfigureAwait(false); + var program = liveTv.GetInternalProgram(dto.ProgramId); if (program != null) { @@ -426,7 +356,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return info; } - public async Task<SeriesTimerInfo> GetSeriesTimerInfo(SeriesTimerInfoDto dto, bool isNew, ILiveTvManager liveTv, CancellationToken cancellationToken) + public async Task<SeriesTimerInfo> GetSeriesTimerInfo(SeriesTimerInfoDto dto, bool isNew, LiveTvManager liveTv, CancellationToken cancellationToken) { var info = new SeriesTimerInfo { @@ -468,7 +398,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (!string.IsNullOrEmpty(dto.ProgramId) && string.IsNullOrEmpty(info.ProgramId)) { - var program = await liveTv.GetProgram(dto.ProgramId, cancellationToken).ConfigureAwait(false); + var program = liveTv.GetInternalProgram(dto.ProgramId); if (program != null) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 52c96bca6..dbae6d03e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -284,7 +284,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return _libraryManager.GetItemById(id) as LiveTvChannel; } - private LiveTvProgram GetInternalProgram(string id) + internal LiveTvProgram GetInternalProgram(string id) { var guid = new Guid(id); @@ -732,20 +732,18 @@ namespace MediaBrowser.Server.Implementations.LiveTv return GetInternalChannel(internalProgramChannelId); } - public async Task<ProgramInfoDto> GetProgram(string id, CancellationToken cancellationToken, User user = null) + public async Task<BaseItemDto> GetProgram(string id, CancellationToken cancellationToken, User user = null) { var program = GetInternalProgram(id); - var channel = GetChannel(program); - - var dto = _tvDtoService.GetProgramInfoDto(program, channel, user); + var dto = _dtoService.GetBaseItemDto(program, new DtoOptions(), user); await AddRecordingInfo(new[] { dto }, cancellationToken).ConfigureAwait(false); return dto; } - public async Task<QueryResult<ProgramInfoDto>> GetPrograms(ProgramQuery query, CancellationToken cancellationToken) + public async Task<QueryResult<BaseItemDto>> GetPrograms(ProgramQuery query, CancellationToken cancellationToken) { IEnumerable<LiveTvProgram> programs = GetPrograms(); @@ -839,19 +837,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv } var returnArray = returnPrograms - .Select(i => - { - var channel = GetChannel(i); - - return _tvDtoService.GetProgramInfoDto(i, channel, user); - }) + .Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions(), user)) .ToArray(); RefreshIfNeeded(programList); await AddRecordingInfo(returnArray, cancellationToken).ConfigureAwait(false); - var result = new QueryResult<ProgramInfoDto> + var result = new QueryResult<BaseItemDto> { Items = returnArray, TotalRecordCount = programList.Count @@ -924,24 +917,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv return result; } - public async Task<QueryResult<ProgramInfoDto>> GetRecommendedPrograms(RecommendedProgramQuery query, CancellationToken cancellationToken) + public async Task<QueryResult<BaseItemDto>> GetRecommendedPrograms(RecommendedProgramQuery query, CancellationToken cancellationToken) { var internalResult = await GetRecommendedProgramsInternal(query, cancellationToken).ConfigureAwait(false); var user = _userManager.GetUserById(query.UserId); var returnArray = internalResult.Items - .Select(i => - { - var channel = GetChannel(i); - - return _tvDtoService.GetProgramInfoDto(i, channel, user); - }) + .Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions(), user)) .ToArray(); await AddRecordingInfo(returnArray, cancellationToken).ConfigureAwait(false); - var result = new QueryResult<ProgramInfoDto> + var result = new QueryResult<BaseItemDto> { Items = returnArray, TotalRecordCount = internalResult.TotalRecordCount @@ -1020,37 +1008,40 @@ namespace MediaBrowser.Server.Implementations.LiveTv }).Sum(); } - private async Task AddRecordingInfo(IEnumerable<ProgramInfoDto> programs, CancellationToken cancellationToken) + private async Task AddRecordingInfo(IEnumerable<BaseItemDto> programs, CancellationToken cancellationToken) { var timers = new Dictionary<string, List<TimerInfo>>(); foreach (var program in programs) { + var internalProgram = GetInternalProgram(program.Id); + List<TimerInfo> timerList; - if (!timers.TryGetValue(program.ServiceName, out timerList)) + if (!timers.TryGetValue(internalProgram.ServiceName, out timerList)) { try { - var tempTimers = await GetService(program.ServiceName).GetTimersAsync(cancellationToken).ConfigureAwait(false); - timers[program.ServiceName] = timerList = tempTimers.ToList(); + var tempTimers = await GetService(internalProgram.ServiceName).GetTimersAsync(cancellationToken).ConfigureAwait(false); + timers[internalProgram.ServiceName] = timerList = tempTimers.ToList(); } catch (Exception ex) { _logger.ErrorException("Error getting timer infos", ex); - timers[program.ServiceName] = timerList = new List<TimerInfo>(); + timers[internalProgram.ServiceName] = timerList = new List<TimerInfo>(); } } - var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, program.ExternalId, StringComparison.OrdinalIgnoreCase)); + + var timer = timerList.FirstOrDefault(i => string.Equals(i.ProgramId, internalProgram.ExternalId, StringComparison.OrdinalIgnoreCase)); if (timer != null) { - program.TimerId = _tvDtoService.GetInternalTimerId(program.ServiceName, timer.Id) + program.TimerId = _tvDtoService.GetInternalTimerId(internalProgram.ServiceName, timer.Id) .ToString("N"); if (!string.IsNullOrEmpty(timer.SeriesTimerId)) { - program.SeriesTimerId = _tvDtoService.GetInternalSeriesTimerId(program.ServiceName, timer.SeriesTimerId) + program.SeriesTimerId = _tvDtoService.GetInternalSeriesTimerId(internalProgram.ServiceName, timer.SeriesTimerId) .ToString("N"); } } @@ -1362,6 +1353,43 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } + public void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, User user = null) + { + var program = (LiveTvProgram)item; + var service = GetService(program); + + var channel = string.IsNullOrEmpty(program.ExternalChannelId) ? null : GetInternalChannel(_tvDtoService.GetInternalChannelId(service.Name, program.ExternalChannelId)); + + dto.Id = _tvDtoService.GetInternalProgramId(service.Name, program.ExternalId).ToString("N"); + + dto.ChannelId = _tvDtoService.GetInternalChannelId(service.Name, program.ExternalChannelId).ToString("N"); + + dto.StartDate = program.StartDate; + dto.IsRepeat = program.IsRepeat; + dto.EpisodeTitle = program.EpisodeTitle; + dto.ChannelType = program.ChannelType; + dto.Audio = program.Audio; + dto.IsHD = program.IsHD; + dto.IsMovie = program.IsMovie; + dto.IsSeries = program.IsSeries; + dto.IsSports = program.IsSports; + dto.IsLive = program.IsLive; + dto.IsNews = program.IsNews; + dto.IsKids = program.IsKids; + dto.IsPremiere = program.IsPremiere; + dto.OriginalAirDate = program.OriginalAirDate; + + if (channel != null) + { + dto.ChannelName = channel.Name; + + if (!string.IsNullOrEmpty(channel.PrimaryImagePath)) + { + dto.ChannelPrimaryImageTag = _tvDtoService.GetImageTag(channel); + } + } + } + public void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, User user = null) { var recording = (ILiveTvRecording)item; @@ -1392,7 +1420,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv dto.IsNews = info.IsNews; dto.IsKids = info.IsKids; dto.IsPremiere = info.IsPremiere; - dto.RunTimeTicks = (info.EndDate - info.StartDate).Ticks; dto.OriginalAirDate = info.OriginalAirDate; dto.CanDelete = user == null @@ -1751,7 +1778,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv info.Name = program.Name; info.Overview = program.Overview; info.ProgramId = programDto.Id; - info.ExternalProgramId = programDto.ExternalId; + info.ExternalProgramId = program.ExternalId; if (program.EndDate.HasValue) { |
