diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-02-09 19:39:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-09 19:39:51 -0500 |
| commit | f1c7b860819abdec1a92068a1494a806a76954d9 (patch) | |
| tree | fc9ac5c0adeef0574e69ce0d1c98816b72ee22b0 /Emby.Server.Implementations/LiveTv | |
| parent | 926b7fd42d0738f3afc39d6ab353535bb9fb948c (diff) | |
| parent | 57637565ca72e4126dd29e669c7c8bf13af556d4 (diff) | |
Merge pull request #2458 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Implementations/LiveTv')
7 files changed, 77 insertions, 35 deletions
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 89ef87c8ef..bbb0602034 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -423,6 +423,11 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { tunerChannel.Name = epgChannel.Name; } + if (!string.IsNullOrWhiteSpace(epgChannel.ImageUrl)) + { + tunerChannel.ImageUrl = epgChannel.ImageUrl; + tunerChannel.HasImage = true; + } } } } @@ -469,16 +474,20 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV public ChannelInfo GetEpgChannelFromTunerChannel(List<NameValuePair> mappings, ChannelInfo tunerChannel, List<ChannelInfo> epgChannels) { - if (!string.IsNullOrWhiteSpace(tunerChannel.TunerChannelId)) + var tunerChannelId = string.IsNullOrWhiteSpace(tunerChannel.TunerChannelId) + ? tunerChannel.Id + : tunerChannel.TunerChannelId; + + if (!string.IsNullOrWhiteSpace(tunerChannelId)) { - var tunerChannelId = GetMappedChannel(tunerChannel.TunerChannelId, mappings); + var mappedTunerChannelId = GetMappedChannel(tunerChannelId, mappings); - if (string.IsNullOrWhiteSpace(tunerChannelId)) + if (string.IsNullOrWhiteSpace(mappedTunerChannelId)) { - tunerChannelId = tunerChannel.TunerChannelId; + mappedTunerChannelId = tunerChannelId; } - var channel = epgChannels.FirstOrDefault(i => string.Equals(tunerChannelId, i.Id, StringComparison.OrdinalIgnoreCase)); + var channel = epgChannels.FirstOrDefault(i => string.Equals(mappedTunerChannelId, i.Id, StringComparison.OrdinalIgnoreCase)); if (channel != null) { @@ -1163,7 +1172,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV }; var isAudio = false; - await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, cancellationToken).ConfigureAwait(false); + await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, false, cancellationToken).ConfigureAwait(false); return new List<MediaSourceInfo> { @@ -2092,13 +2101,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV writer.WriteElementString("credits", person); } - var rt = item.GetProviderId(MetadataProviders.RottenTomatoes); - - if (!string.IsNullOrEmpty(rt)) - { - writer.WriteElementString("rottentomatoesid", rt); - } - var tmdbCollection = item.GetProviderId(MetadataProviders.TmdbCollection); if (!string.IsNullOrEmpty(tmdbCollection)) diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index 1f739b3c6c..9a8282250c 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -155,7 +155,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks); var inputModifiers = "-fflags +genpts -async 1 -vsync -1"; var mapArgs = string.Equals(OutputFormat, "mkv", StringComparison.OrdinalIgnoreCase) ? "-map 0" : "-sn"; - // temporary mapArgs = "-sn"; var commandLineArgs = "-i \"{0}\"{4} " + mapArgs + " {2} -map_metadata -1 -threads 0 {3} -y \"{1}\""; diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 1b7a1c8c62..0d7a26553a 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -152,7 +152,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings responseString); var programDict = programDetails.ToDictionary(p => p.programID, y => y); - var images = await GetImageForPrograms(info, programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID).ToList(), cancellationToken); + var programIdsWithImages = + programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID) + .ToList(); + + var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken); var schedules = dailySchedules.SelectMany(d => d.programs); foreach (ScheduleDirect.Program schedule in schedules) @@ -439,13 +443,20 @@ namespace Emby.Server.Implementations.LiveTv.Listings List<string> programIds, CancellationToken cancellationToken) { + if (programIds.Count == 0) + { + return new List<ScheduleDirect.ShowImages>(); + } + var imageIdString = "["; foreach (var i in programIds) { - if (!imageIdString.Contains(i.Substring(0, 10))) + var imageId = i.Substring(0, 10); + + if (!imageIdString.Contains(imageId)) { - imageIdString += "\"" + i.Substring(0, 10) + "\","; + imageIdString += "\"" + imageId + "\","; } } @@ -461,14 +472,21 @@ namespace Emby.Server.Implementations.LiveTv.Listings // The data can be large so give it some extra time TimeoutMs = 60000 }; - List<ScheduleDirect.ShowImages> images; - using (var innerResponse2 = await Post(httpOptions, true, info).ConfigureAwait(false)) + + try { - images = _jsonSerializer.DeserializeFromStream<List<ScheduleDirect.ShowImages>>( - innerResponse2.Content); + using (var innerResponse2 = await Post(httpOptions, true, info).ConfigureAwait(false)) + { + return _jsonSerializer.DeserializeFromStream<List<ScheduleDirect.ShowImages>>( + innerResponse2.Content); + } } + catch (Exception ex) + { + _logger.ErrorException("Error getting image info from schedules direct", ex); - return images; + return new List<ScheduleDirect.ShowImages>(); + } } public async Task<List<NameIdPair>> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken) diff --git a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs index 0313e6fdec..2ee6869f68 100644 --- a/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs +++ b/Emby.Server.Implementations/LiveTv/LiveStreamHelper.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Logging; namespace Emby.Server.Implementations.LiveTv @@ -21,7 +22,7 @@ namespace Emby.Server.Implementations.LiveTv _logger = logger; } - public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, CancellationToken cancellationToken) + public async Task AddMediaInfoWithProbe(MediaSourceInfo mediaSource, bool isAudio, bool assumeInterlaced, CancellationToken cancellationToken) { var originalRuntime = mediaSource.RunTimeTicks; @@ -95,6 +96,17 @@ namespace Emby.Server.Implementations.LiveTv videoStream.IsAVC = null; } + if (assumeInterlaced) + { + foreach (var mediaStream in mediaSource.MediaStreams) + { + if (mediaStream.Type == MediaStreamType.Video) + { + mediaStream.IsInterlaced = true; + } + } + } + // Try to estimate this mediaSource.InferTotalBitrate(true); } diff --git a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs index e59a8f93c0..e30280967f 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvManager.cs @@ -246,9 +246,9 @@ namespace Emby.Server.Implementations.LiveTv return info.Item1; } - public async Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken) + public Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetChannelStream(string id, string mediaSourceId, CancellationToken cancellationToken) { - return await GetLiveStream(id, mediaSourceId, true, cancellationToken).ConfigureAwait(false); + return GetLiveStream(id, mediaSourceId, true, cancellationToken); } private string GetItemExternalId(BaseItem item) @@ -308,7 +308,7 @@ namespace Emby.Server.Implementations.LiveTv return _services.FirstOrDefault(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); } - private async Task<Tuple<MediaSourceInfo, IDirectStreamProvider>> GetLiveStream(string id, string mediaSourceId, bool isChannel, CancellationToken cancellationToken) + private async Task<Tuple<MediaSourceInfo, IDirectStreamProvider, bool>> GetLiveStream(string id, string mediaSourceId, bool isChannel, CancellationToken cancellationToken) { if (string.Equals(id, mediaSourceId, StringComparison.OrdinalIgnoreCase)) { @@ -319,6 +319,7 @@ namespace Emby.Server.Implementations.LiveTv bool isVideo; ILiveTvService service; IDirectStreamProvider directStreamProvider = null; + var assumeInterlaced = false; if (isChannel) { @@ -365,10 +366,14 @@ namespace Emby.Server.Implementations.LiveTv } } - _logger.Info("Live stream info: {0}", _jsonSerializer.SerializeToString(info)); Normalize(info, service, isVideo); - return new Tuple<MediaSourceInfo, IDirectStreamProvider>(info, directStreamProvider); + if (!(service is EmbyTV.EmbyTV)) + { + assumeInterlaced = true; + } + + return new Tuple<MediaSourceInfo, IDirectStreamProvider, bool>(info, directStreamProvider, assumeInterlaced); } private void Normalize(MediaSourceInfo mediaSource, ILiveTvService service, bool isVideo) diff --git a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index dd95660c78..e25e284849 100644 --- a/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/Emby.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -126,12 +126,14 @@ namespace Emby.Server.Implementations.LiveTv var keys = openToken.Split(new[] { StreamIdDelimeter }, 3); var mediaSourceId = keys.Length >= 3 ? keys[2] : null; IDirectStreamProvider directStreamProvider = null; + var assumeInterlaced = false; if (string.Equals(keys[0], typeof(LiveTvChannel).Name, StringComparison.OrdinalIgnoreCase)) { var info = await _liveTvManager.GetChannelStream(keys[1], mediaSourceId, cancellationToken).ConfigureAwait(false); stream = info.Item1; directStreamProvider = info.Item2; + assumeInterlaced = info.Item3; } else { @@ -146,7 +148,7 @@ namespace Emby.Server.Implementations.LiveTv } else { - await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, cancellationToken).ConfigureAwait(false); + await new LiveStreamHelper(_mediaEncoder, _logger).AddMediaInfoWithProbe(stream, isAudio, assumeInterlaced, cancellationToken).ConfigureAwait(false); } } catch (Exception ex) @@ -154,6 +156,7 @@ namespace Emby.Server.Implementations.LiveTv _logger.ErrorException("Error probing live tv stream", ex); } + _logger.Info("Live stream info: {0}", _jsonSerializer.SerializeToString(stream)); return new Tuple<MediaSourceInfo, IDirectStreamProvider>(stream, directStreamProvider); } diff --git a/Emby.Server.Implementations/LiveTv/ProgramImageProvider.cs b/Emby.Server.Implementations/LiveTv/ProgramImageProvider.cs index 5a0389b16a..5cff88a676 100644 --- a/Emby.Server.Implementations/LiveTv/ProgramImageProvider.cs +++ b/Emby.Server.Implementations/LiveTv/ProgramImageProvider.cs @@ -50,13 +50,16 @@ namespace Emby.Server.Implementations.LiveTv { var channel = _liveTvManager.GetInternalChannel(liveTvItem.ChannelId); - var response = await service.GetProgramImageAsync(GetItemExternalId(liveTvItem), GetItemExternalId(channel), cancellationToken).ConfigureAwait(false); - - if (response != null) + if (channel != null) { - imageResponse.HasImage = true; - imageResponse.Stream = response.Stream; - imageResponse.Format = response.Format; + var response = await service.GetProgramImageAsync(GetItemExternalId(liveTvItem), GetItemExternalId(channel), cancellationToken).ConfigureAwait(false); + + if (response != null) + { + imageResponse.HasImage = true; + imageResponse.Stream = response.Stream; + imageResponse.Format = response.Format; + } } } catch (NotImplementedException) |
