From 1279c6d8b5179017efb3fb9503d6937dcd84bc97 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 17 Jul 2015 22:52:27 -0400 Subject: fix roku live tv stream closing --- MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index b6441053d..9b46a8057 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -230,7 +230,7 @@ namespace MediaBrowser.Server.Implementations.Library private void SetKeyProperties(IMediaSourceProvider provider, MediaSourceInfo mediaSource) { - var prefix = provider.GetType().FullName.GetMD5().ToString("N") + "|"; + var prefix = provider.GetType().FullName.GetMD5().ToString("N") + LiveStreamIdDelimeter; if (!string.IsNullOrWhiteSpace(mediaSource.OpenToken) && !mediaSource.OpenToken.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)) { @@ -463,10 +463,13 @@ namespace MediaBrowser.Server.Implementations.Library _liveStreamSemaphore.Release(); } } + + // Do not use a pipe here because Roku http requests to the server will fail, without any explicit error message. + private const char LiveStreamIdDelimeter = '_'; private Tuple GetProvider(string key) { - var keys = key.Split(new[] { '|' }, 2); + var keys = key.Split(new[] { LiveStreamIdDelimeter }, 2); var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N"), keys[0], StringComparison.OrdinalIgnoreCase)); -- cgit v1.2.3 From ba9ed26c4a60b29f25c0cf53d215b617142c0fc3 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 23 Jul 2015 19:40:54 -0400 Subject: update emby tv --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/Playback/StreamState.cs | 2 +- MediaBrowser.Controller/LiveTv/ITunerHost.cs | 8 ++ MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs | 2 +- MediaBrowser.Model/Dto/MediaSourceInfo.cs | 4 +- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 1 + .../Library/MediaSourceManager.cs | 2 +- .../LiveTv/EmbyTV/EmbyTV.cs | 130 +++++++++++++++++---- .../LiveTv/EmbyTV/ItemDataProvider.cs | 5 +- .../LiveTv/Listings/SchedulesDirect.cs | 51 ++++++-- .../LiveTv/LiveTvManager.cs | 4 +- .../LiveTv/LiveTvMediaSourceProvider.cs | 24 ++-- .../TunerHosts/HdHomerun/HdHomerunDiscovery.cs | 12 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 62 ++++++---- .../LiveTv/TunerHosts/M3UTunerHost.cs | 10 +- .../Localization/Server/server.json | 2 +- 17 files changed, 236 insertions(+), 87 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index e7885a3f8..8505b5d3a 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -924,7 +924,7 @@ namespace MediaBrowser.Api.Playback state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationTokenSource.Token).ConfigureAwait(false); } - if (state.MediaSource.RequiresOpening) + if (state.MediaSource.RequiresOpening ?? false) { var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest { diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 02b7720a4..4df696096 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -185,7 +185,7 @@ namespace MediaBrowser.Api.Playback private async void DisposeLiveStream() { - if (MediaSource.RequiresClosing && string.IsNullOrWhiteSpace(Request.LiveStreamId)) + if ((MediaSource.RequiresClosing ?? false) && string.IsNullOrWhiteSpace(Request.LiveStreamId)) { try { diff --git a/MediaBrowser.Controller/LiveTv/ITunerHost.cs b/MediaBrowser.Controller/LiveTv/ITunerHost.cs index 38ed43bd9..c9a96a9ca 100644 --- a/MediaBrowser.Controller/LiveTv/ITunerHost.cs +++ b/MediaBrowser.Controller/LiveTv/ITunerHost.cs @@ -47,6 +47,14 @@ namespace MediaBrowser.Controller.LiveTv /// Task<MediaSourceInfo>. Task GetChannelStream(TunerHostInfo info, string channelId, string streamId, CancellationToken cancellationToken); /// + /// Gets the channel stream media sources. + /// + /// The information. + /// The channel identifier. + /// The cancellation token. + /// Task<List<MediaSourceInfo>>. + Task> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken); + /// /// Validates the specified information. /// /// The information. diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index fbfe79272..9153045e6 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -436,7 +436,7 @@ namespace MediaBrowser.MediaEncoding.Encoder state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationToken).ConfigureAwait(false); } - if (state.MediaSource.RequiresOpening) + if (state.MediaSource.RequiresOpening ?? false) { var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest { diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs index efce5abb0..bb32ac95b 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs @@ -137,7 +137,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private async void DisposeLiveStream() { - if (MediaSource.RequiresClosing) + if (MediaSource.RequiresClosing ?? false) { try { diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 8897edcbd..75edc6a52 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -26,9 +26,9 @@ namespace MediaBrowser.Model.Dto public bool SupportsDirectStream { get; set; } public bool SupportsDirectPlay { get; set; } - public bool RequiresOpening { get; set; } + public bool? RequiresOpening { get; set; } public string OpenToken { get; set; } - public bool RequiresClosing { get; set; } + public bool? RequiresClosing { get; set; } public string LiveStreamId { get; set; } public int? BufferMs { get; set; } diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 90cd8924d..3fc841645 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -34,5 +34,6 @@ namespace MediaBrowser.Model.LiveTv public string Password { get; set; } public string ListingsId { get; set; } public string ZipCode { get; set; } + public string Country { get; set; } } } \ No newline at end of file diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 9b46a8057..765acd578 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -439,7 +439,7 @@ namespace MediaBrowser.Server.Implementations.Library LiveStreamInfo current; if (_openStreams.TryGetValue(id, out current)) { - if (current.MediaSource.RequiresClosing) + if (current.MediaSource.RequiresClosing ?? false) { var tuple = GetProvider(id); diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 37b6bf086..c32b8da10 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1,5 +1,6 @@ using MediaBrowser.Common; using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.LiveTv; @@ -74,20 +75,17 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV var status = new LiveTvServiceStatusInfo(); var list = new List(); - foreach (var host in _liveTvManager.TunerHosts) + foreach (var hostInstance in GetTunerHosts()) { - foreach (var hostInstance in host.GetTunerHosts()) + try { - try - { - var tuners = await host.GetTunerInfos(hostInstance, cancellationToken).ConfigureAwait(false); + var tuners = await hostInstance.Item1.GetTunerInfos(hostInstance.Item2, cancellationToken).ConfigureAwait(false); - list.AddRange(tuners); - } - catch (Exception ex) - { - _logger.ErrorException("Error getting tuners", ex); - } + list.AddRange(tuners); + } + catch (Exception ex) + { + _logger.ErrorException("Error getting tuners", ex); } } @@ -102,20 +100,23 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { var list = new List(); - foreach (var host in _liveTvManager.TunerHosts) + foreach (var hostInstance in GetTunerHosts()) { - foreach (var hostInstance in host.GetTunerHosts()) + try { - try - { - var channels = await host.GetChannels(hostInstance, cancellationToken).ConfigureAwait(false); + var channels = await hostInstance.Item1.GetChannels(hostInstance.Item2, cancellationToken).ConfigureAwait(false); + var newChannels = channels.ToList(); - list.AddRange(channels); - } - catch (Exception ex) + foreach (var channel in newChannels) { - _logger.ErrorException("Error getting channels", ex); + channel.Id = hostInstance.Item1.Type.GetMD5().ToString("N") + "-" + channel.Id; } + + list.AddRange(newChannels); + } + catch (Exception ex) + { + _logger.ErrorException("Error getting channels", ex); } } @@ -130,6 +131,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV return list; } + private List> GetTunerHosts() + { + return GetConfiguration().TunerHosts + .Select(i => + { + var provider = _liveTvManager.TunerHosts.FirstOrDefault(l => string.Equals(l.Type, i.Type, StringComparison.OrdinalIgnoreCase)); + + return provider == null ? null : new Tuple(provider, i); + }) + .Where(i => i != null) + .ToList(); + } + public Task CancelSeriesTimerAsync(string timerId, CancellationToken cancellationToken) { var remove = _seriesTimerProvider.GetAll().SingleOrDefault(r => r.Id == timerId); @@ -255,14 +269,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV return Task.FromResult((IEnumerable)_seriesTimerProvider.GetAll()); } + private string GetOriginalChannelId(string channelId) + { + var parts = channelId.Split('-'); + + return string.Join("-", parts.Skip(1).ToArray()); + } + public async Task> GetProgramsAsync(string channelId, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken) { foreach (var provider in GetListingProviders()) { - var programs = await provider.Item1.GetProgramsAsync(provider.Item2, channelId, startDateUtc, endDateUtc, cancellationToken) + var programs = await provider.Item1.GetProgramsAsync(provider.Item2, GetOriginalChannelId(channelId), startDateUtc, endDateUtc, cancellationToken) .ConfigureAwait(false); var list = programs.ToList(); + // Replace the value that came from the provider with a normalized value + foreach (var program in list) + { + program.ChannelId = channelId; + } + if (list.Count > 0) { return list; @@ -290,14 +317,67 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV throw new NotImplementedException(); } - public Task GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken) + public async Task GetChannelStream(string channelId, string streamId, CancellationToken cancellationToken) { - throw new NotImplementedException(); + _logger.Info("Streaming Channel " + channelId); + + var configurationId = channelId.Split('-')[0]; + + foreach (var hostInstance in GetTunerHosts()) + { + if (!string.Equals(configurationId, hostInstance.Item1.Type.GetMD5().ToString("N"), StringComparison.OrdinalIgnoreCase)) + { + continue; + } + + if (!string.IsNullOrWhiteSpace(streamId)) + { + var originalStreamId = string.Join("-", streamId.Split('-').Skip(1).ToArray()); + + if (!string.Equals(hostInstance.Item2.Id, originalStreamId, StringComparison.OrdinalIgnoreCase)) + { + continue; + } + } + + MediaSourceInfo mediaSourceInfo = null; + try + { + mediaSourceInfo = await hostInstance.Item1.GetChannelStream(hostInstance.Item2, GetOriginalChannelId(channelId), streamId, cancellationToken).ConfigureAwait(false); + } + catch (ApplicationException e) + { + _logger.Info(e.Message); + continue; + } + + mediaSourceInfo.Id = Guid.NewGuid().ToString("N"); + return mediaSourceInfo; + } + + throw new ApplicationException("Tuner not found."); } - public Task> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken) + public async Task> GetChannelStreamMediaSources(string channelId, CancellationToken cancellationToken) { - throw new NotImplementedException(); + var configurationId = channelId.Split('-')[0]; + + foreach (var hostInstance in GetTunerHosts()) + { + if (string.Equals(configurationId, hostInstance.Item1.Type.GetMD5().ToString("N"), StringComparison.OrdinalIgnoreCase)) + { + var sources = await hostInstance.Item1.GetChannelStreamMediaSources(hostInstance.Item2, GetOriginalChannelId(channelId), cancellationToken).ConfigureAwait(false); + + foreach (var source in sources) + { + source.Id = hostInstance.Item2.Id + "-" + source.Id; + } + + return sources; + } + } + + throw new ApplicationException("Tuner not found."); } public Task> GetRecordingStreamMediaSources(string recordingId, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index e7feeee5a..75dec5f97 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -68,9 +68,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private void UpdateList(List newList) { + var file = _dataPath + ".json"; + Directory.CreateDirectory(Path.GetDirectoryName(file)); + lock (_fileDataLock) { - _jsonSerializer.SerializeToFile(newList, _dataPath + ".json"); + _jsonSerializer.SerializeToFile(newList, file); _items = newList; } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index ed265d416..72a965c6a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -218,7 +218,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings private ProgramInfo GetProgram(string channel, ScheduleDirect.Program programInfo, ScheduleDirect.ProgramDetails details) { - _logger.Debug("Show type is: " + (details.showType ?? "No ShowType")); + //_logger.Debug("Show type is: " + (details.showType ?? "No ShowType")); DateTime startAt = DateTime.ParseExact(programInfo.airDateTime, "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'", CultureInfo.InvariantCulture); DateTime endAt = startAt.AddSeconds(programInfo.duration); @@ -401,7 +401,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings _logger.Info("Headends on account "); var countryParam = string.Equals("ca", country, StringComparison.OrdinalIgnoreCase) - ? "Canada" + ? "can" : "USA"; var options = new HttpRequestOptions() @@ -562,6 +562,44 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings get { return "SchedulesDirect"; } } + private async Task HasLineup(ListingsProviderInfo info, CancellationToken cancellationToken) + { + var token = await GetToken(info, cancellationToken); + + _logger.Info("Headends on account "); + + var options = new HttpRequestOptions() + { + Url = ApiUrl + "/lineups", + UserAgent = UserAgent, + CancellationToken = cancellationToken + }; + + options.RequestHeaders["token"] = token; + + using (Stream responce = await _httpClient.Get(options).ConfigureAwait(false)) + { + var root = _jsonSerializer.DeserializeFromStream(responce); + + return root.lineups.Any(i => string.Equals(info.ListingsId, i.lineup, StringComparison.OrdinalIgnoreCase)); + } + } + + public async Task Validate(ListingsProviderInfo info) + { + var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false); + + if (!hasLineup) + { + await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); + } + } + + public Task> GetLineups(ListingsProviderInfo info, string country, string location) + { + return GetHeadends(info, country, location, CancellationToken.None); + } + public class ScheduleDirect { public class Token @@ -841,14 +879,5 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings } - public async Task Validate(ListingsProviderInfo info) - { - //await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); - } - - public Task> GetLineups(ListingsProviderInfo info, string country, string location) - { - return GetHeadends(info, country, location, CancellationToken.None); - } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 5be90e6cc..6ef565129 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -367,7 +367,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv info = await service.GetChannelStream(channel.ExternalId, mediaSourceId, cancellationToken).ConfigureAwait(false); info.RequiresClosing = true; - if (info.RequiresClosing) + if (info.RequiresClosing ?? false) { var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; @@ -384,7 +384,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv info = await service.GetRecordingStream(recording.ExternalId, null, cancellationToken).ConfigureAwait(false); info.RequiresClosing = true; - if (info.RequiresClosing) + if (info.RequiresClosing ?? false) { var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index 5ebb79629..cf34b6b99 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -53,7 +53,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv // Do not use a pipe here because Roku http requests to the server will fail, without any explicit error message. private const char StreamIdDelimeter = '_'; - private const string StreamIdDelimeterString = "|"; + private const string StreamIdDelimeterString = "_"; private async Task> GetMediaSourcesInternal(ILiveTvItem item, CancellationToken cancellationToken) { @@ -86,14 +86,22 @@ namespace MediaBrowser.Server.Implementations.LiveTv foreach (var source in list) { source.Type = MediaSourceType.Default; - source.RequiresOpening = true; - source.BufferMs = source.BufferMs ?? 1500; - var openKeys = new List(); - openKeys.Add(item.GetType().Name); - openKeys.Add(item.Id.ToString("N")); - openKeys.Add(source.Id ?? string.Empty); - source.OpenToken = string.Join(StreamIdDelimeterString, openKeys.ToArray()); + if (!source.RequiresOpening.HasValue) + { + source.RequiresOpening = true; + } + + if (source.RequiresOpening.HasValue && source.RequiresOpening.Value) + { + var openKeys = new List(); + openKeys.Add(item.GetType().Name); + openKeys.Add(item.Id.ToString("N")); + openKeys.Add(source.Id ?? string.Empty); + source.OpenToken = string.Join(StreamIdDelimeterString, openKeys.ToArray()); + } + + source.BufferMs = source.BufferMs ?? 1500; // Dummy this up so that direct play checks can still run if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs index 4777003d6..cc2bb2d52 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs @@ -72,6 +72,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun return; } + // Strip off the port + url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped); + await _liveTvManager.SaveTunerHost(new TunerHostInfo { Type = HdHomerunHost.DeviceType, @@ -103,13 +106,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun url = url.TrimEnd('/'); - // If there isn't a port, add the default port of 80 - if (url.Split(':').Length < 3) - { - url += ":80"; - } - - return url; + // Strip off the port + return new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped); } private LiveTvOptions GetConfiguration() diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 187569ab4..d9f1541c8 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun { var options = new HttpRequestOptions { - Url = string.Format("{0}/lineup.json", GetApiUrl(info)), + Url = string.Format("{0}/lineup.json", GetApiUrl(info, false)), CancellationToken = cancellationToken }; using (var stream = await _httpClient.Get(options)) @@ -79,7 +79,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun using (var stream = await _httpClient.Get(new HttpRequestOptions() { - Url = string.Format("{0}/", GetApiUrl(info)), + Url = string.Format("{0}/", GetApiUrl(info, false)), CancellationToken = cancellationToken })) { @@ -97,7 +97,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun using (var stream = await _httpClient.Get(new HttpRequestOptions() { - Url = string.Format("{0}/tuners.html", GetApiUrl(info)), + Url = string.Format("{0}/tuners.html", GetApiUrl(info, false)), CancellationToken = cancellationToken })) { @@ -128,7 +128,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun } } - public string GetApiUrl(TunerHostInfo info) + private string GetApiUrl(TunerHostInfo info, bool isPlayback) { var url = info.Url; @@ -137,7 +137,16 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun url = "http://" + url; } - return url.TrimEnd('/'); + var uri = new Uri(url); + + if (isPlayback) + { + var builder = new UriBuilder(uri); + builder.Port = 5004; + uri = builder.Uri; + } + + return uri.AbsoluteUri.TrimEnd('/'); } private static string StripXML(string source) @@ -187,21 +196,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun return GetConfiguration().TunerHosts.Where(i => string.Equals(i.Type, Type, StringComparison.OrdinalIgnoreCase)).ToList(); } - public async Task GetChannelStream(TunerHostInfo info, string channelId, string streamId, CancellationToken cancellationToken) + private MediaSourceInfo GetMediaSource(TunerHostInfo info, string channelId, string profile) { - var channels = await GetChannels(info, cancellationToken).ConfigureAwait(false); - var tuners = await GetTunerInfos(info, cancellationToken).ConfigureAwait(false); - - var channel = channels.FirstOrDefault(c => string.Equals(c.Id, channelId, StringComparison.OrdinalIgnoreCase)); - if (channel != null) + var mediaSource = new MediaSourceInfo { - if (tuners.FindIndex(t => t.Status == LiveTvTunerStatus.Available) >= 0) - { - return new MediaSourceInfo - { - Path = GetApiUrl(info) + "/auto/v" + channelId, - Protocol = MediaProtocol.Http, - MediaStreams = new List + Path = GetApiUrl(info, true) + "/auto/v" + channelId, + Protocol = MediaProtocol.Http, + MediaStreams = new List { new MediaStream { @@ -217,15 +218,28 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun Index = -1 } - } - }; - } + }, + RequiresOpening = false, + RequiresClosing = false, + BufferMs = 1000 + }; - throw new ApplicationException("No tuners avaliable."); - } - throw new ApplicationException("Channel not found."); + return mediaSource; } + public Task> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) + { + var list = new List(); + + list.Add(GetMediaSource(info, channelId, null)); + + return Task.FromResult(list); + } + + public async Task GetChannelStream(TunerHostInfo info, string channelId, string streamId, CancellationToken cancellationToken) + { + return GetMediaSource(info, channelId, null); + } public async Task Validate(TunerHostInfo info) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs index e91bd0f0b..91f25bbee 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/M3UTunerHost.cs @@ -171,7 +171,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts Index = -1 } - } + }, + RequiresOpening = false, + RequiresClosing = false }; } throw new ApplicationException("Host doesnt provide this channel"); @@ -193,5 +195,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts throw new FileNotFoundException(); } } + + + public Task> GetChannelStreamMediaSources(TunerHostInfo info, string channelId, CancellationToken cancellationToken) + { + throw new NotImplementedException(); + } } } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 24df7c983..194d406f3 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -1489,5 +1489,5 @@ "GuideProviderListingsStep": "Step 2: Select Listings", "GuideProviderLoginStep": "Step 1: Login", "LabelLineup": "Lineup", - "MessageTunerDeviceNotListed": "Is your tuner device not listed? Try installing an external service plugin for more Live TV options." + "MessageTunerDeviceNotListed": "Is your tuner device not listed? Try installing an external service provider for more Live TV options." } -- cgit v1.2.3 From 7a74213914fd5ca166f148ec47d65c7041082847 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 28 Jul 2015 15:54:45 -0400 Subject: update subtitle conversion --- MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 765acd578..87e71e327 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -72,6 +72,12 @@ namespace MediaBrowser.Server.Implementations.Library private bool InternalTextStreamSupportsExternalStream(MediaStream stream) { + // These usually have styles and fonts that won't convert to text very well + if (string.Equals(stream.Codec, "ass", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + return true; } @@ -463,7 +469,7 @@ namespace MediaBrowser.Server.Implementations.Library _liveStreamSemaphore.Release(); } } - + // Do not use a pipe here because Roku http requests to the server will fail, without any explicit error message. private const char LiveStreamIdDelimeter = '_'; -- cgit v1.2.3 From edecae6ed5bcd7159ac2ba2c12d8d38824915129 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 2 Aug 2015 13:02:23 -0400 Subject: improve guide loading performance --- Emby.Drawing/ImageProcessor.cs | 26 +++---- MediaBrowser.Api/LiveTv/LiveTvService.cs | 80 +++++++++++++++++++--- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 15 ++-- MediaBrowser.Dlna/Didl/DidlBuilder.cs | 18 ++--- MediaBrowser.Model/Channels/ChannelQuery.cs | 14 +++- MediaBrowser.Model/LiveTv/ProgramQuery.cs | 10 +++ .../LiveTv/RecommendedProgramQuery.cs | 14 +++- MediaBrowser.Model/LiveTv/RecordingQuery.cs | 14 +++- .../Dto/DtoService.cs | 5 -- .../Library/MediaSourceManager.cs | 4 ++ .../LiveTv/LiveTvDtoService.cs | 5 +- .../LiveTv/LiveTvManager.cs | 14 ++-- 12 files changed, 166 insertions(+), 53 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 2ba4f5aab..1e4537bae 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -410,18 +410,20 @@ namespace Emby.Drawing { ImageSize size; - try - { - size = ImageHeader.GetDimensions(path, _logger, _fileSystem); - } - catch - { - _logger.Info("Failed to read image header for {0}. Doing it the slow way.", path); - - CheckDisposed(); - - size = _imageEncoder.GetImageSize(path); - } + size = ImageHeader.GetDimensions(path, _logger, _fileSystem); + //try + //{ + // size = ImageHeader.GetDimensions(path, _logger, _fileSystem); + //} + //catch + //{ + // return; + // //_logger.Info("Failed to read image header for {0}. Doing it the slow way.", path); + + // //CheckDisposed(); + + // //size = _imageEncoder.GetImageSize(path); + //} StartSaveImageSizeTimer(); diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 6814ad751..3ff4c4828 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/Channels", "GET", Summary = "Gets available live tv channels.")] [Authenticated] - public class GetChannels : IReturn> + public class GetChannels : IReturn>, IHasDtoOptions { [ApiMember(Name = "Type", Description = "Optional filter by channel type.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public ChannelType? Type { get; set; } @@ -62,6 +62,22 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "EnableFavoriteSorting", Description = "Incorporate favorite and like status into channel sorting.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool EnableFavoriteSorting { get; set; } + + [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableImages { get; set; } + + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? ImageTypeLimit { get; set; } + + [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string EnableImageTypes { get; set; } + + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string Fields { get; set; } } [Route("/LiveTv/Channels/{Id}", "GET", Summary = "Gets a live tv channel")] @@ -81,7 +97,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/Recordings", "GET", Summary = "Gets live tv recordings")] [Authenticated] - public class GetRecordings : IReturn> + public class GetRecordings : IReturn>, IHasDtoOptions { [ApiMember(Name = "ChannelId", Description = "Optional filter by channel id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string ChannelId { get; set; } @@ -106,6 +122,22 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "SeriesTimerId", Description = "Optional filter by recordings belonging to a series timer", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string SeriesTimerId { get; set; } + + [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableImages { get; set; } + + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? ImageTypeLimit { get; set; } + + [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string EnableImageTypes { get; set; } + + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string Fields { get; set; } } [Route("/LiveTv/Recordings/Groups", "GET", Summary = "Gets live tv recording groups")] @@ -164,7 +196,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/Programs", "GET,POST", Summary = "Gets available live tv epgs..")] [Authenticated] - public class GetPrograms : IReturn> + public class GetPrograms : IReturn>, IHasDtoOptions { [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; } @@ -207,11 +239,27 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "Genres", Description = "The genres to return guide information for.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")] public string Genres { get; set; } + + [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableImages { get; set; } + + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? ImageTypeLimit { get; set; } + + [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string EnableImageTypes { get; set; } + + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string Fields { get; set; } } [Route("/LiveTv/Programs/Recommended", "GET", Summary = "Gets available live tv epgs..")] [Authenticated] - public class GetRecommendedPrograms : IReturn> + public class GetRecommendedPrograms : IReturn>, IHasDtoOptions { [ApiMember(Name = "UserId", Description = "Optional filter by user id.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET,POST")] public string UserId { get; set; } @@ -230,6 +278,22 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "IsMovie", Description = "Optional filter for movies.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsMovie { get; set; } + + [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableImages { get; set; } + + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? ImageTypeLimit { get; set; } + + [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string EnableImageTypes { get; set; } + + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string Fields { get; set; } } [Route("/LiveTv/Programs/{Id}", "GET", Summary = "Gets a live tv program")] @@ -490,7 +554,7 @@ namespace MediaBrowser.Api.LiveTv IsDisliked = request.IsDisliked, EnableFavoriteSorting = request.EnableFavoriteSorting - }, CancellationToken.None).ConfigureAwait(false); + }, GetDtoOptions(request), CancellationToken.None).ConfigureAwait(false); return ToOptimizedSerializedResultUsingCache(result); } @@ -546,7 +610,7 @@ namespace MediaBrowser.Api.LiveTv query.IsSports = request.IsSports; query.Genres = (request.Genres ?? String.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - var result = await _liveTvManager.GetPrograms(query, CancellationToken.None).ConfigureAwait(false); + var result = await _liveTvManager.GetPrograms(query, GetDtoOptions(request), CancellationToken.None).ConfigureAwait(false); return ToOptimizedResult(result); } @@ -563,7 +627,7 @@ namespace MediaBrowser.Api.LiveTv IsSports = request.IsSports }; - var result = await _liveTvManager.GetRecommendedPrograms(query, CancellationToken.None).ConfigureAwait(false); + var result = await _liveTvManager.GetRecommendedPrograms(query, GetDtoOptions(request), CancellationToken.None).ConfigureAwait(false); return ToOptimizedResult(result); } @@ -575,7 +639,7 @@ namespace MediaBrowser.Api.LiveTv public async Task Get(GetRecordings request) { - var options = new DtoOptions(); + var options = GetDtoOptions(request); options.DeviceId = AuthorizationContext.GetAuthorizationInfo(Request).DeviceId; var result = await _liveTvManager.GetRecordings(new RecordingQuery diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 53ad6dbdc..889875383 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -69,9 +69,10 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the channels. /// /// The query. + /// The options. /// The cancellation token. /// IEnumerable{Channel}. - Task> GetChannels(LiveTvChannelQuery query, CancellationToken cancellationToken); + Task> GetChannels(LiveTvChannelQuery query, DtoOptions options, CancellationToken cancellationToken); /// /// Gets the recording. @@ -173,14 +174,15 @@ namespace MediaBrowser.Controller.LiveTv /// The user. /// Task{ProgramInfoDto}. Task GetProgram(string id, CancellationToken cancellationToken, User user = null); - + /// /// Gets the programs. /// /// The query. + /// The options. /// The cancellation token. /// IEnumerable{ProgramInfo}. - Task> GetPrograms(ProgramQuery query, CancellationToken cancellationToken); + Task> GetPrograms(ProgramQuery query, DtoOptions options, CancellationToken cancellationToken); /// /// Updates the timer. @@ -240,10 +242,10 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the recommended programs. /// /// The query. + /// The options. /// The cancellation token. /// Task{QueryResult{ProgramInfoDto}}. - Task> GetRecommendedPrograms(RecommendedProgramQuery query, - CancellationToken cancellationToken); + Task> GetRecommendedPrograms(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken); /// /// Gets the recommended programs internal. @@ -251,8 +253,7 @@ namespace MediaBrowser.Controller.LiveTv /// The query. /// The cancellation token. /// Task<QueryResult<LiveTvProgram>>. - Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, - CancellationToken cancellationToken); + Task> GetRecommendedProgramsInternal(RecommendedProgramQuery query, CancellationToken cancellationToken); /// /// Gets the live tv information. diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.cs index 0e4cf7392..25514f1dc 100644 --- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs +++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs @@ -971,17 +971,17 @@ namespace MediaBrowser.Dlna.Didl int? width = null; int? height = null; - try - { - var size = _imageProcessor.GetImageSize(imageInfo); + //try + //{ + // var size = _imageProcessor.GetImageSize(imageInfo); - width = Convert.ToInt32(size.Width); - height = Convert.ToInt32(size.Height); - } - catch - { + // width = Convert.ToInt32(size.Width); + // height = Convert.ToInt32(size.Height); + //} + //catch + //{ - } + //} return new ImageDownloadInfo { diff --git a/MediaBrowser.Model/Channels/ChannelQuery.cs b/MediaBrowser.Model/Channels/ChannelQuery.cs index 3c6e43fde..b63d797f4 100644 --- a/MediaBrowser.Model/Channels/ChannelQuery.cs +++ b/MediaBrowser.Model/Channels/ChannelQuery.cs @@ -1,7 +1,19 @@ -namespace MediaBrowser.Model.Channels +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Model.Channels { public class ChannelQuery { + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + public ItemFields[] Fields { get; set; } + public bool? EnableImages { get; set; } + public int? ImageTypeLimit { get; set; } + public ImageType[] EnableImageTypes { get; set; } + /// /// Gets or sets the user identifier. /// diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.cs index c19ba54bd..3f652ea6f 100644 --- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs +++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs @@ -1,5 +1,6 @@ using MediaBrowser.Model.Entities; using System; +using MediaBrowser.Model.Querying; namespace MediaBrowser.Model.LiveTv { @@ -15,6 +16,15 @@ namespace MediaBrowser.Model.LiveTv Genres = new string[] { }; } + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + public ItemFields[] Fields { get; set; } + public bool? EnableImages { get; set; } + public int? ImageTypeLimit { get; set; } + public ImageType[] EnableImageTypes { get; set; } + /// /// Gets or sets the channel ids. /// diff --git a/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs b/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs index 4a8ae2365..09d45066b 100644 --- a/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs +++ b/MediaBrowser.Model/LiveTv/RecommendedProgramQuery.cs @@ -1,7 +1,19 @@ -namespace MediaBrowser.Model.LiveTv +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Model.LiveTv { public class RecommendedProgramQuery { + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + public ItemFields[] Fields { get; set; } + public bool? EnableImages { get; set; } + public int? ImageTypeLimit { get; set; } + public ImageType[] EnableImageTypes { get; set; } + /// /// Gets or sets the user identifier. /// diff --git a/MediaBrowser.Model/LiveTv/RecordingQuery.cs b/MediaBrowser.Model/LiveTv/RecordingQuery.cs index daa137db6..0cf997602 100644 --- a/MediaBrowser.Model/LiveTv/RecordingQuery.cs +++ b/MediaBrowser.Model/LiveTv/RecordingQuery.cs @@ -1,4 +1,7 @@ -namespace MediaBrowser.Model.LiveTv +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.Querying; + +namespace MediaBrowser.Model.LiveTv { /// /// Class RecordingQuery. @@ -58,5 +61,14 @@ /// /// The series timer identifier. public string SeriesTimerId { get; set; } + + /// + /// Fields to return within the items, in addition to basic information + /// + /// The fields. + public ItemFields[] Fields { get; set; } + public bool? EnableImages { get; set; } + public int? ImageTypeLimit { get; set; } + public ImageType[] EnableImageTypes { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 31f1b17dd..2ff9a2813 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1767,11 +1767,6 @@ namespace MediaBrowser.Server.Implementations.Dto { size = _imageProcessor.GetImageSize(imageInfo); } - catch (FileNotFoundException) - { - _logger.Error("Image file does not exist: {0}", path); - return; - } catch (Exception ex) { _logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path); diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 87e71e327..2263b3e1f 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -77,6 +77,10 @@ namespace MediaBrowser.Server.Implementations.Library { return false; } + if (string.Equals(stream.Codec, "ssa", StringComparison.OrdinalIgnoreCase)) + { + return false; + } return true; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index 72fea2c79..9ffd8a500 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -198,10 +198,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv /// Gets the channel info dto. /// /// The info. + /// The options. /// The current program. /// The user. /// ChannelInfoDto. - public ChannelInfoDto GetChannelInfoDto(LiveTvChannel info, LiveTvProgram currentProgram, User user = null) + public ChannelInfoDto GetChannelInfoDto(LiveTvChannel info, DtoOptions options, LiveTvProgram currentProgram, User user = null) { var dto = new ChannelInfoDto { @@ -238,7 +239,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (currentProgram != null) { - dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, new DtoOptions(), user); + dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user); } return dto; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index d8954724a..f73e648fa 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -238,7 +238,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return result; } - public async Task> GetChannels(LiveTvChannelQuery query, CancellationToken cancellationToken) + public async Task> GetChannels(LiveTvChannelQuery query, DtoOptions options, CancellationToken cancellationToken) { var user = string.IsNullOrEmpty(query.UserId) ? null : _userManager.GetUserById(query.UserId); @@ -261,7 +261,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv var channelIdString = channel.Id.ToString("N"); var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString, StringComparison.OrdinalIgnoreCase)); - returnList.Add(_tvDtoService.GetChannelInfoDto(channel, currentProgram, user)); + returnList.Add(_tvDtoService.GetChannelInfoDto(channel, options, currentProgram, user)); } var result = new QueryResult @@ -762,7 +762,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return dto; } - public async Task> GetPrograms(ProgramQuery query, CancellationToken cancellationToken) + public async Task> GetPrograms(ProgramQuery query, DtoOptions options, CancellationToken cancellationToken) { var internalQuery = new InternalItemsQuery { @@ -822,7 +822,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv .Select(i => { RefreshIfNeeded(i); - return _dtoService.GetBaseItemDto(i, new DtoOptions(), user); + return _dtoService.GetBaseItemDto(i, options, user); }) .ToArray(); @@ -907,14 +907,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv return result; } - public async Task> GetRecommendedPrograms(RecommendedProgramQuery query, CancellationToken cancellationToken) + public async Task> GetRecommendedPrograms(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken) { var internalResult = await GetRecommendedProgramsInternal(query, cancellationToken).ConfigureAwait(false); var user = _userManager.GetUserById(query.UserId); var returnArray = internalResult.Items - .Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions(), user)) + .Select(i => _dtoService.GetBaseItemDto(i, options, user)) .ToArray(); await AddRecordingInfo(returnArray, cancellationToken).ConfigureAwait(false); @@ -1712,7 +1712,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv .OrderBy(i => i.StartDate) .FirstOrDefault(); - var dto = _tvDtoService.GetChannelInfoDto(channel, currentProgram, user); + var dto = _tvDtoService.GetChannelInfoDto(channel, new DtoOptions(), currentProgram, user); return dto; } -- cgit v1.2.3 From 47b1a4cafd0cc1882503e46fb8a5082a3b061078 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 2 Aug 2015 15:08:55 -0400 Subject: update image processing --- Emby.Drawing/ImageProcessor.cs | 16 +++++++++++++++- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/Playback/StreamState.cs | 2 +- MediaBrowser.Api/StartupWizardService.cs | 1 + MediaBrowser.Controller/Library/IMetadataFileSaver.cs | 5 +++++ MediaBrowser.LocalMetadata/Savers/EpisodeXmlSaver.cs | 9 +++++++-- MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs | 9 +++++++-- MediaBrowser.LocalMetadata/Savers/SeriesXmlSaver.cs | 9 +++++++-- MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs | 2 +- MediaBrowser.Model/Configuration/ServerConfiguration.cs | 2 ++ MediaBrowser.Model/Dto/MediaSourceInfo.cs | 4 ++-- MediaBrowser.Providers/Manager/ProviderManager.cs | 8 +++++++- .../Library/MediaSourceManager.cs | 2 +- .../LiveTv/LiveTvManager.cs | 4 ++-- .../LiveTv/LiveTvMediaSourceProvider.cs | 8 ++++++-- Nuget/MediaBrowser.Common.Internal.nuspec | 4 ++-- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Model.Signed.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 ++-- 20 files changed, 72 insertions(+), 25 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 1e4537bae..9db2c1c20 100644 --- a/Emby.Drawing/ImageProcessor.cs +++ b/Emby.Drawing/ImageProcessor.cs @@ -189,7 +189,21 @@ namespace Emby.Drawing dateModified = tuple.Item2; } - var originalImageSize = GetImageSize(originalImagePath, dateModified); + ImageSize originalImageSize; + + try + { + originalImageSize = GetImageSize(originalImagePath, dateModified); + } + catch + { + // This is an arbitrary default, but don't fail the whole process over this + originalImageSize = new ImageSize + { + Width = 100, + Height = 100 + }; + } // Determine the output size based on incoming parameters var newSize = DrawingUtils.Resize(originalImageSize, options.Width, options.Height, options.MaxWidth, options.MaxHeight); diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 3bef397f9..f108b344f 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -854,7 +854,7 @@ namespace MediaBrowser.Api.Playback state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationTokenSource.Token).ConfigureAwait(false); } - if (state.MediaSource.RequiresOpening ?? false) + if (state.MediaSource.RequiresOpening) { var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest { diff --git a/MediaBrowser.Api/Playback/StreamState.cs b/MediaBrowser.Api/Playback/StreamState.cs index 4df696096..34dc5ea12 100644 --- a/MediaBrowser.Api/Playback/StreamState.cs +++ b/MediaBrowser.Api/Playback/StreamState.cs @@ -185,7 +185,7 @@ namespace MediaBrowser.Api.Playback private async void DisposeLiveStream() { - if ((MediaSource.RequiresClosing ?? false) && string.IsNullOrWhiteSpace(Request.LiveStreamId)) + if ((MediaSource.RequiresClosing) && string.IsNullOrWhiteSpace(Request.LiveStreamId)) { try { diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index 6ee8d3603..277e02bf9 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -67,6 +67,7 @@ namespace MediaBrowser.Api _config.Configuration.EnableLibraryMetadataSubFolder = true; _config.Configuration.EnableUserSpecificUserViews = true; _config.Configuration.EnableCustomPathSubFolders = true; + _config.Configuration.DisableXmlSavers = true; _config.SaveConfiguration(); } diff --git a/MediaBrowser.Controller/Library/IMetadataFileSaver.cs b/MediaBrowser.Controller/Library/IMetadataFileSaver.cs index 0883da48f..e09e58302 100644 --- a/MediaBrowser.Controller/Library/IMetadataFileSaver.cs +++ b/MediaBrowser.Controller/Library/IMetadataFileSaver.cs @@ -11,4 +11,9 @@ namespace MediaBrowser.Controller.Library /// System.String. string GetSavePath(IHasMetadata item); } + + public interface IConfigurableProvider + { + bool IsEnabled { get; } + } } \ No newline at end of file diff --git a/MediaBrowser.LocalMetadata/Savers/EpisodeXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/EpisodeXmlSaver.cs index 7a2a97c0c..96d95d40b 100644 --- a/MediaBrowser.LocalMetadata/Savers/EpisodeXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/EpisodeXmlSaver.cs @@ -12,7 +12,7 @@ using System.Threading; namespace MediaBrowser.LocalMetadata.Savers { - public class EpisodeXmlSaver : IMetadataFileSaver + public class EpisodeXmlProvider : IMetadataFileSaver, IConfigurableProvider { private readonly IItemRepository _itemRepository; @@ -20,7 +20,7 @@ namespace MediaBrowser.LocalMetadata.Savers private readonly IServerConfigurationManager _config; private readonly ILibraryManager _libraryManager; - public EpisodeXmlSaver(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) + public EpisodeXmlProvider(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) { _itemRepository = itemRepository; _config = config; @@ -51,6 +51,11 @@ namespace MediaBrowser.LocalMetadata.Savers } } + public bool IsEnabled + { + get { return !_config.Configuration.DisableXmlSavers; } + } + /// /// Saves the specified item. /// diff --git a/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs index dc5b45259..a6fba3e9b 100644 --- a/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/MovieXmlSaver.cs @@ -15,13 +15,13 @@ namespace MediaBrowser.LocalMetadata.Savers /// /// Saves movie.xml for movies, trailers and music videos /// - public class MovieXmlSaver : IMetadataFileSaver + public class MovieXmlProvider : IMetadataFileSaver, IConfigurableProvider { private readonly IItemRepository _itemRepository; private readonly IServerConfigurationManager _config; private readonly ILibraryManager _libraryManager; - public MovieXmlSaver(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) + public MovieXmlProvider(IItemRepository itemRepository, IServerConfigurationManager config, ILibraryManager libraryManager) { _itemRepository = itemRepository; _config = config; @@ -36,6 +36,11 @@ namespace MediaBrowser.LocalMetadata.Savers } } + public bool IsEnabled + { + get { return !_config.Configuration.DisableXmlSavers; } + } + /// /// Determines whether [is enabled for] [the specified item]. /// diff --git a/MediaBrowser.LocalMetadata/Savers/SeriesXmlSaver.cs b/MediaBrowser.LocalMetadata/Savers/SeriesXmlSaver.cs index 45aff5e2c..44b1cd8d3 100644 --- a/MediaBrowser.LocalMetadata/Savers/SeriesXmlSaver.cs +++ b/MediaBrowser.LocalMetadata/Savers/SeriesXmlSaver.cs @@ -12,12 +12,12 @@ using System.Threading; namespace MediaBrowser.LocalMetadata.Savers { - public class SeriesXmlSaver : IMetadataFileSaver + public class SeriesXmlProvider : IMetadataFileSaver, IConfigurableProvider { private readonly IServerConfigurationManager _config; private readonly ILibraryManager _libraryManager; - public SeriesXmlSaver(IServerConfigurationManager config, ILibraryManager libraryManager) + public SeriesXmlProvider(IServerConfigurationManager config, ILibraryManager libraryManager) { _config = config; _libraryManager = libraryManager; @@ -47,6 +47,11 @@ namespace MediaBrowser.LocalMetadata.Savers return item is Series && updateType >= ItemUpdateType.MetadataDownload; } + public bool IsEnabled + { + get { return !_config.Configuration.DisableXmlSavers; } + } + private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); /// diff --git a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs index 140e84963..dd88512fb 100644 --- a/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/BaseEncoder.cs @@ -436,7 +436,7 @@ namespace MediaBrowser.MediaEncoding.Encoder state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationToken).ConfigureAwait(false); } - if (state.MediaSource.RequiresOpening ?? false) + if (state.MediaSource.RequiresOpening) { var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest { diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs index 2eeb580e3..806910d89 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingJob.cs @@ -136,7 +136,7 @@ namespace MediaBrowser.MediaEncoding.Encoder private async void DisposeLiveStream() { - if (MediaSource.RequiresClosing ?? false) + if (MediaSource.RequiresClosing) { try { diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 0a2fabc1b..072416684 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -213,6 +213,8 @@ namespace MediaBrowser.Model.Configuration public int SharingExpirationDays { get; set; } + public bool DisableXmlSavers { get; set; } + /// /// Initializes a new instance of the class. /// diff --git a/MediaBrowser.Model/Dto/MediaSourceInfo.cs b/MediaBrowser.Model/Dto/MediaSourceInfo.cs index 75edc6a52..8897edcbd 100644 --- a/MediaBrowser.Model/Dto/MediaSourceInfo.cs +++ b/MediaBrowser.Model/Dto/MediaSourceInfo.cs @@ -26,9 +26,9 @@ namespace MediaBrowser.Model.Dto public bool SupportsDirectStream { get; set; } public bool SupportsDirectPlay { get; set; } - public bool? RequiresOpening { get; set; } + public bool RequiresOpening { get; set; } public string OpenToken { get; set; } - public bool? RequiresClosing { get; set; } + public bool RequiresClosing { get; set; } public string LiveStreamId { get; set; } public int? BufferMs { get; set; } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index beef968fb..453e07987 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -106,9 +106,15 @@ namespace MediaBrowser.Providers.Manager _identityProviders = identityProviders.ToArray(); _identityConverters = identityConverters.ToArray(); _metadataProviders = metadataProviders.ToArray(); - _savers = metadataSavers.ToArray(); _imageSavers = imageSavers.ToArray(); _externalIds = externalIds.OrderBy(i => i.Name).ToArray(); + + _savers = metadataSavers.Where(i => + { + var configurable = i as IConfigurableProvider; + + return configurable == null || configurable.IsEnabled; + }).ToArray(); } public Task RefreshSingleItem(IHasMetadata item, MetadataRefreshOptions options, CancellationToken cancellationToken) diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 2263b3e1f..c5ff100f9 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -449,7 +449,7 @@ namespace MediaBrowser.Server.Implementations.Library LiveStreamInfo current; if (_openStreams.TryGetValue(id, out current)) { - if (current.MediaSource.RequiresClosing ?? false) + if (current.MediaSource.RequiresClosing) { var tuple = GetProvider(id); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index f73e648fa..b4669f53e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -368,7 +368,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv info = await service.GetChannelStream(channel.ExternalId, mediaSourceId, cancellationToken).ConfigureAwait(false); info.RequiresClosing = true; - if (info.RequiresClosing ?? false) + if (info.RequiresClosing) { var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; @@ -385,7 +385,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv info = await service.GetRecordingStream(recording.ExternalId, null, cancellationToken).ConfigureAwait(false); info.RequiresClosing = true; - if (info.RequiresClosing ?? false) + if (info.RequiresClosing) { var idPrefix = service.GetType().FullName.GetMD5().ToString("N") + "_"; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index cf34b6b99..66a21830e 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -59,6 +59,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv { IEnumerable sources; + var forceRequireOpening = false; + try { if (item is ILiveTvRecording) @@ -78,6 +80,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv sources = _mediaSourceManager.GetStaticMediaSources(hasMediaSources, false) .ToList(); + + forceRequireOpening = true; } var list = sources.ToList(); @@ -87,12 +91,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv { source.Type = MediaSourceType.Default; - if (!source.RequiresOpening.HasValue) + if (source.RequiresOpening || forceRequireOpening) { source.RequiresOpening = true; } - if (source.RequiresOpening.HasValue && source.RequiresOpening.Value) + if (source.RequiresOpening) { var openKeys = new List(); openKeys.Add(item.GetType().Name); diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index fffb68e36..c43b90c8c 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.629 + 3.0.631 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption. Copyright © Emby 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 856e63199..32e3b2fc6 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.629 + 3.0.631 MediaBrowser.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Model.Signed.nuspec b/Nuget/MediaBrowser.Model.Signed.nuspec index 30175007d..fc33477a9 100644 --- a/Nuget/MediaBrowser.Model.Signed.nuspec +++ b/Nuget/MediaBrowser.Model.Signed.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Model.Signed - 3.0.629 + 3.0.631 MediaBrowser.Model - Signed Edition Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index c688c6f2c..704c30f95 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.629 + 3.0.631 Media Browser.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + -- cgit v1.2.3 From 474cbbb87a51cb0fe82c408789c75b3971b58227 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 23 Aug 2015 22:08:20 -0400 Subject: added default padding settings --- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 5 ++++- .../Library/LibraryManager.cs | 2 +- .../Library/MediaSourceManager.cs | 5 ++++- MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 6 ++++-- MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 3 +-- .../LiveTv/LiveTvMediaSourceProvider.cs | 7 ++++++- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 13 +++++++++++-- SharedVersion.cs | 4 ++-- 8 files changed, 33 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 7881231a2..2b45422ec 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -11,7 +11,10 @@ namespace MediaBrowser.Model.LiveTv public List TunerHosts { get; set; } public List ListingProviders { get; set; } - + + public int PrePaddingSeconds { get; set; } + public int PostPaddingSeconds { get; set; } + public LiveTvOptions() { EnableMovieProviders = true; diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index a67e3d732..cc9d9551c 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -937,7 +937,7 @@ namespace MediaBrowser.Server.Implementations.Library (item as MusicArtist).IsAccessedByName = true; } - var task = item.UpdateToRepository(ItemUpdateType.None, CancellationToken.None); + var task = CreateItem(item, CancellationToken.None); Task.WaitAll(task); } diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index c5ff100f9..1f4dff277 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -483,7 +483,10 @@ namespace MediaBrowser.Server.Implementations.Library var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N"), keys[0], StringComparison.OrdinalIgnoreCase)); - return new Tuple(provider, keys[1]); + var splitIndex = key.IndexOf(LiveStreamIdDelimeter); + var keyId = key.Substring(splitIndex + 1); + + return new Tuple(provider, keyId); } private Timer _closeTimer; diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 96e14a21c..b69cdacef 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -339,10 +339,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV public Task GetNewTimerDefaultsAsync(CancellationToken cancellationToken, ProgramInfo program = null) { + var config = GetConfiguration(); + var defaults = new SeriesTimerInfo() { - PostPaddingSeconds = 0, - PrePaddingSeconds = 0, + PostPaddingSeconds = Math.Max(config.PostPaddingSeconds, 0), + PrePaddingSeconds = Math.Max(config.PrePaddingSeconds, 0), RecordAnyChannel = false, RecordAnyTime = false, RecordNewOnly = false diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 1721d6101..653adb716 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -889,8 +889,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv if (query.Limit.HasValue) { - programs = programs.Take(query.Limit.Value) - .OrderBy(i => i.StartDate); + programs = programs.Take(query.Limit.Value); } programList = programs.ToList(); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index 66a21830e..d9d9b76b9 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -125,7 +125,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv const bool isAudio = false; var keys = openToken.Split(new[] { StreamIdDelimeter }, 3); - var mediaSourceId = keys.Length >= 3 ? keys[2] : null; + string mediaSourceId = null; + + if (keys.Length >= 3) + { + mediaSourceId = openToken.Substring(keys[0].Length + keys[1].Length + 2); + } if (string.Equals(keys[0], typeof(LiveTvChannel).Name, StringComparison.OrdinalIgnoreCase)) { diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 5890e24eb..4bbbf5a4d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -22,7 +22,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun private readonly IHttpClient _httpClient; private readonly IJsonSerializer _jsonSerializer; - public HdHomerunHost(IConfigurationManager config, ILogger logger, IHttpClient httpClient, IJsonSerializer jsonSerializer) : base(config, logger) + public HdHomerunHost(IConfigurationManager config, ILogger logger, IHttpClient httpClient, IJsonSerializer jsonSerializer) + : base(config, logger) { _httpClient = httpClient; _jsonSerializer = jsonSerializer; @@ -166,6 +167,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun { var url = info.Url; + if (string.IsNullOrWhiteSpace(url)) + { + throw new ArgumentException("Invalid tuner info"); + } + if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { url = "http://" + url; @@ -382,7 +388,10 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun public async Task Validate(TunerHostInfo info) { - await GetChannels(info, false, CancellationToken.None).ConfigureAwait(false); + if (info.IsEnabled) + { + await GetChannels(info, false, CancellationToken.None).ConfigureAwait(false); + } } protected override async Task IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken) diff --git a/SharedVersion.cs b/SharedVersion.cs index 3d8be801e..2b8644211 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -//[assembly: AssemblyVersion("3.0.*")] -[assembly: AssemblyVersion("3.0.5713.0")] +[assembly: AssemblyVersion("3.0.*")] +//[assembly: AssemblyVersion("3.0.5713.0")] -- cgit v1.2.3 From 9e387b2ecf44bf5613221fdbfbb873d725abe7b0 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 24 Aug 2015 08:54:10 -0400 Subject: 3.0.5713.1 --- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- .../Library/MediaSourceManager.cs | 5 +++++ .../LiveTv/LiveTvMediaSourceProvider.cs | 12 +++--------- SharedVersion.cs | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs') diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6fba6052f..33f3210a9 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -854,7 +854,7 @@ namespace MediaBrowser.Api.Playback state.IsoMount = await IsoManager.Mount(state.MediaPath, cancellationTokenSource.Token).ConfigureAwait(false); } - if (state.MediaSource.RequiresOpening) + if (state.MediaSource.RequiresOpening && string.IsNullOrWhiteSpace(state.Request.LiveStreamId)) { var liveStreamResponse = await MediaSourceManager.OpenLiveStream(new LiveStreamRequest { diff --git a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs index 1f4dff277..e3ec99392 100644 --- a/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MediaSourceManager.cs @@ -479,6 +479,11 @@ namespace MediaBrowser.Server.Implementations.Library private Tuple GetProvider(string key) { + if (string.IsNullOrWhiteSpace(key)) + { + throw new ArgumentException("key"); + } + var keys = key.Split(new[] { LiveStreamIdDelimeter }, 2); var provider = _providers.FirstOrDefault(i => string.Equals(i.GetType().FullName.GetMD5().ToString("N"), keys[0], StringComparison.OrdinalIgnoreCase)); diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs index d9d9b76b9..ff102b0f7 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvMediaSourceProvider.cs @@ -90,6 +90,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv foreach (var source in list) { source.Type = MediaSourceType.Default; + source.BufferMs = source.BufferMs ?? 1500; if (source.RequiresOpening || forceRequireOpening) { @@ -103,9 +104,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv openKeys.Add(item.Id.ToString("N")); openKeys.Add(source.Id ?? string.Empty); source.OpenToken = string.Join(StreamIdDelimeterString, openKeys.ToArray()); - } - - source.BufferMs = source.BufferMs ?? 1500; + } // Dummy this up so that direct play checks can still run if (string.IsNullOrEmpty(source.Path) && source.Protocol == MediaProtocol.Http) @@ -125,12 +124,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv const bool isAudio = false; var keys = openToken.Split(new[] { StreamIdDelimeter }, 3); - string mediaSourceId = null; - - if (keys.Length >= 3) - { - mediaSourceId = openToken.Substring(keys[0].Length + keys[1].Length + 2); - } + var mediaSourceId = keys.Length >= 3 ? keys[2] : null; if (string.Equals(keys[0], typeof(LiveTvChannel).Name, StringComparison.OrdinalIgnoreCase)) { diff --git a/SharedVersion.cs b/SharedVersion.cs index 2b8644211..d77ca5d8f 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.0.*")] -//[assembly: AssemblyVersion("3.0.5713.0")] +//[assembly: AssemblyVersion("3.0.*")] +[assembly: AssemblyVersion("3.0.5713.1")] -- cgit v1.2.3