From 8c34f863fb6c6c282a87837138b3d620170099d8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 29 Dec 2013 13:53:56 -0500 Subject: [PATCH] make live tv channels playable --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 14 +++++++ .../Playback/BaseStreamingService.cs | 16 ++++++++ .../LiveTv/ILiveTvManager.cs | 8 ++++ .../LiveTv/ILiveTvService.cs | 4 +- MediaBrowser.Mono.userprefs | 2 +- .../Movies/MovieDbProvider.cs | 38 +++---------------- .../TV/SeriesPostScanTask.cs | 2 +- .../LiveTv/LiveTvManager.cs | 9 +++++ Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 11 files changed, 61 insertions(+), 42 deletions(-) diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 588fad8bd3..61883ddaae 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -198,6 +198,13 @@ namespace MediaBrowser.Api.LiveTv public string Id { get; set; } } + [Route("/LiveTv/Channels/{Id}/Stream", "GET")] + public class GetInternalChannelStream + { + [ApiMember(Name = "Id", Description = "Channel Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] + public string Id { get; set; } + } + public class LiveTvService : BaseApiService { private readonly ILiveTvManager _liveTvManager; @@ -399,6 +406,13 @@ namespace MediaBrowser.Api.LiveTv return ToStreamResult(stream.Stream, stream.MimeType); } + public object Get(GetInternalChannelStream request) + { + var stream = _liveTvManager.GetChannelStream(request.Id, CancellationToken.None).Result; + + return ToStreamResult(stream.Stream, stream.MimeType); + } + public object Get(GetRecordingGroups request) { var result = _liveTvManager.GetRecordingGroups(new RecordingGroupQuery diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 34ec15a709..1e2ae58b25 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -902,6 +902,22 @@ namespace MediaBrowser.Api.Playback item = recording; } + else if (string.Equals(request.Type, "Channel", StringComparison.OrdinalIgnoreCase)) + { + var channel = LiveTvManager.GetInternalChannel(request.Id); + + state.VideoType = VideoType.VideoFile; + state.IsInputVideo = string.Equals(channel.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase); + state.PlayableStreamFileNames = new List(); + + state.MediaPath = string.Format("http://localhost:{0}/mediabrowser/LiveTv/Channels/{1}/Stream", + ServerConfigurationManager.Configuration.HttpServerPortNumber, + request.Id); + + state.IsRemote = true; + + item = channel; + } else { item = DtoService.GetItemByDtoId(request.Id); diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 2458d4db4d..c26e29d942 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -162,6 +162,14 @@ namespace MediaBrowser.Controller.LiveTv /// The cancellation token. /// Task{Stream}. Task GetRecordingStream(string id, CancellationToken cancellationToken); + + /// + /// Gets the channel stream. + /// + /// The identifier. + /// The cancellation token. + /// Task{StreamResponseInfo}. + Task GetChannelStream(string id, CancellationToken cancellationToken); /// /// Gets the program. diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 31dbd8e998..f8efbce635 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -150,9 +150,9 @@ namespace MediaBrowser.Controller.LiveTv /// /// Gets the channel stream. /// - /// The recording identifier. + /// The channel identifier. /// The cancellation token. /// Task{Stream}. - Task GetChannelStream(string recordingId, CancellationToken cancellationToken); + Task GetChannelStream(string channelId, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Mono.userprefs b/MediaBrowser.Mono.userprefs index 3ca97e6bdd..d303a7993e 100644 --- a/MediaBrowser.Mono.userprefs +++ b/MediaBrowser.Mono.userprefs @@ -2,7 +2,7 @@ - + diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index c6c9df6f7d..dc267b37cc 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -751,41 +751,13 @@ namespace MediaBrowser.Providers.Movies ? minimunRelease.iso_3166_1 + "-" + minimunRelease.certification : null; } - - if (ourRelease.release_date != default(DateTime)) - { - if (ourRelease.release_date.Year != 1) - { - movie.PremiereDate = ourRelease.release_date.ToUniversalTime(); - movie.ProductionYear = ourRelease.release_date.Year; - } - } - else if (usRelease.release_date != default(DateTime)) - { - if (usRelease.release_date.Year != 1) - { - movie.PremiereDate = usRelease.release_date.ToUniversalTime(); - movie.ProductionYear = usRelease.release_date.Year; - } - } - else if (minimunRelease.release_date != default(DateTime)) - { - if (minimunRelease.release_date.Year != 1) - { - - movie.PremiereDate = minimunRelease.release_date.ToUniversalTime(); - movie.ProductionYear = minimunRelease.release_date.Year; - } - } } - else + + if (movieData.release_date.Year != 1) { - if (movieData.release_date.Year != 1) - { - //no specific country release info at all - movie.PremiereDate = movieData.release_date.ToUniversalTime(); - movie.ProductionYear = movieData.release_date.Year; - } + //no specific country release info at all + movie.PremiereDate = movieData.release_date.ToUniversalTime(); + movie.ProductionYear = movieData.release_date.Year; } // If that didn't find a rating and we are a boxset, use the one from our first child diff --git a/MediaBrowser.Providers/TV/SeriesPostScanTask.cs b/MediaBrowser.Providers/TV/SeriesPostScanTask.cs index b889b991e9..8663c0b4c8 100644 --- a/MediaBrowser.Providers/TV/SeriesPostScanTask.cs +++ b/MediaBrowser.Providers/TV/SeriesPostScanTask.cs @@ -441,7 +441,7 @@ namespace MediaBrowser.Providers.TV { _logger.Info("Creating Season {0} entry for {1}", seasonNumber, series.Name); - var name = string.Format("Season {0}", seasonNumber.ToString(UsCulture)); + var name = seasonNumber == 0 ? _config.Configuration.SeasonZeroDisplayName : string.Format("Season {0}", seasonNumber.ToString(UsCulture)); var season = new Season { diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 2ef68c2392..a3790b097a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -166,6 +166,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv return await service.GetRecordingStream(recording.Id, cancellationToken).ConfigureAwait(false); } + public async Task GetChannelStream(string id, CancellationToken cancellationToken) + { + var service = ActiveService; + + var channel = GetInternalChannel(id); + + return await service.GetRecordingStream(channel.ChannelInfo.Id, cancellationToken).ConfigureAwait(false); + } + private async Task GetChannel(ChannelInfo channelInfo, string serviceName, CancellationToken cancellationToken) { var path = Path.Combine(_appPaths.ItemsByNamePath, "channels", _fileSystem.GetValidFilename(serviceName), _fileSystem.GetValidFilename(channelInfo.Name)); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 1df7b17bf3..cdbd51d84e 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.292 + 3.0.293 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 14e09d90cf..20bdf1300a 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.292 + 3.0.293 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index d49dfb85db..8f040c00ff 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.292 + 3.0.293 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +