From 3fda8ec5c264f077b625247ab29ce504be25774c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 23 Jul 2015 09:23:22 -0400 Subject: update tuner setup --- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 3aa1f66efb..3dbf9a9e90 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -56,12 +56,14 @@ namespace MediaBrowser.Controller.LiveTv /// The identifier. /// Task. Task CancelSeriesTimer(string id); - + /// /// Adds the parts. /// /// The services. - void AddParts(IEnumerable services); + /// The tuner hosts. + /// The listing providers. + void AddParts(IEnumerable services, IEnumerable tunerHosts, IEnumerable listingProviders); /// /// Gets the channels. @@ -337,5 +339,24 @@ namespace MediaBrowser.Controller.LiveTv /// The dto. /// The user. void AddInfoToProgramDto(BaseItem item, BaseItemDto dto, User user = null); + /// + /// Saves the tuner host. + /// + /// The information. + /// Task. + Task SaveTunerHost(TunerHostInfo info); + /// + /// Saves the listing provider. + /// + /// The information. + /// Task. + Task SaveListingProvider(ListingsProviderInfo info); + /// + /// Gets the lineups. + /// + /// The provider identifier. + /// The location. + /// Task<List<NameIdPair>>. + Task> GetLineups(string providerId, string location); } } -- cgit v1.2.3 From f7c1a88166e4ba756f05db12db2c61865cfc6712 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 23 Jul 2015 13:58:20 -0400 Subject: update schedules direct --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 5 ++++- MediaBrowser.Controller/LiveTv/IListingsProvider.cs | 2 +- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 3 ++- .../LiveTv/Listings/SchedulesDirect.cs | 14 +++++++++----- .../LiveTv/LiveTvManager.cs | 4 ++-- .../LiveTv/RefreshChannelsScheduledTask.cs | 15 ++++++++++++--- .../TunerHosts/HdHomerun/HdHomerunDiscovery.cs | 20 +++++++++++++++----- 7 files changed, 45 insertions(+), 18 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index f40048ce40..d05e0951a4 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -369,6 +369,9 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "Location", Description = "Location", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string Location { get; set; } + + [ApiMember(Name = "Country", Description = "Country", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string Country { get; set; } } public class LiveTvService : BaseApiService @@ -436,7 +439,7 @@ namespace MediaBrowser.Api.LiveTv public async Task Get(GetLineups request) { - var info = await _liveTvManager.GetLineups(request.Id, request.Location).ConfigureAwait(false); + var info = await _liveTvManager.GetLineups(request.Id, request.Country, request.Location).ConfigureAwait(false); return ToOptimizedSerializedResultUsingCache(info); } diff --git a/MediaBrowser.Controller/LiveTv/IListingsProvider.cs b/MediaBrowser.Controller/LiveTv/IListingsProvider.cs index 54977c8d3c..5e43f1d27a 100644 --- a/MediaBrowser.Controller/LiveTv/IListingsProvider.cs +++ b/MediaBrowser.Controller/LiveTv/IListingsProvider.cs @@ -14,6 +14,6 @@ namespace MediaBrowser.Controller.LiveTv Task> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken); Task AddMetadata(ListingsProviderInfo info, List channels, CancellationToken cancellationToken); Task Validate(ListingsProviderInfo info); - Task> GetLineups(ListingsProviderInfo info, string location); + Task> GetLineups(ListingsProviderInfo info, string country, string location); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 3dbf9a9e90..a0deb34f0b 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -355,8 +355,9 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the lineups. /// /// The provider identifier. + /// The country. /// The location. /// Task<List<NameIdPair>>. - Task> GetLineups(string providerId, string location); + Task> GetLineups(string providerId, string country, string location); } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 269da57683..ed265d416f 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -387,7 +387,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings return images; } - public async Task> GetHeadends(ListingsProviderInfo info, string location, CancellationToken cancellationToken) + public async Task> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken) { var token = await GetToken(info, cancellationToken); @@ -400,9 +400,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings _logger.Info("Headends on account "); + var countryParam = string.Equals("ca", country, StringComparison.OrdinalIgnoreCase) + ? "Canada" + : "USA"; + var options = new HttpRequestOptions() { - Url = ApiUrl + "/headends?country=USA&postalcode=" + location, + Url = ApiUrl + "/headends?country=" + countryParam + "&postalcode=" + location, UserAgent = UserAgent, CancellationToken = cancellationToken }; @@ -839,12 +843,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings public async Task Validate(ListingsProviderInfo info) { - await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); + //await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); } - public Task> GetLineups(ListingsProviderInfo info, string location) + public Task> GetLineups(ListingsProviderInfo info, string country, string location) { - return GetHeadends(info, location, CancellationToken.None); + return GetHeadends(info, country, location, CancellationToken.None); } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 52bb41ba19..5be90e6ccc 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2238,7 +2238,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return info; } - public Task> GetLineups(string providerId, string location) + public Task> GetLineups(string providerId, string country, string location) { var config = GetConfiguration(); @@ -2251,7 +2251,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv throw new ResourceNotFoundException(); } - return provider.GetLineups(info, location); + return provider.GetLineups(info, country, location); } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs index de2351434f..7cb616d3fc 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/RefreshChannelsScheduledTask.cs @@ -1,5 +1,7 @@ -using MediaBrowser.Common.ScheduledTasks; +using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.ScheduledTasks; using MediaBrowser.Controller.LiveTv; +using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Tasks; using System; using System.Collections.Generic; @@ -10,10 +12,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv class RefreshChannelsScheduledTask : IScheduledTask, IConfigurableScheduledTask, IHasKey { private readonly ILiveTvManager _liveTvManager; + private readonly IConfigurationManager _config; - public RefreshChannelsScheduledTask(ILiveTvManager liveTvManager) + public RefreshChannelsScheduledTask(ILiveTvManager liveTvManager, IConfigurationManager config) { _liveTvManager = liveTvManager; + _config = config; } public string Name @@ -50,9 +54,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv }; } + private LiveTvOptions GetConfiguration() + { + return _config.GetConfiguration("livetv"); + } + public bool IsHidden { - get { return _liveTvManager.Services.Count == 0; } + get { return _liveTvManager.Services.Count == 1 && GetConfiguration().TunerHosts.Count == 0; } } public bool IsEnabled diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs index 41652ae9f0..4777003d63 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs @@ -91,15 +91,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun private bool UriEquals(string savedUri, string location) { - if (!savedUri.StartsWith("http", StringComparison.OrdinalIgnoreCase)) + return string.Equals(NormalizeUrl(location), NormalizeUrl(savedUri), StringComparison.OrdinalIgnoreCase); + } + + private string NormalizeUrl(string url) + { + if (!url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { - savedUri = "http://" + savedUri; + url = "http://" + url; } - savedUri = savedUri.TrimEnd('/'); - location = location.TrimEnd('/'); + url = url.TrimEnd('/'); + + // If there isn't a port, add the default port of 80 + if (url.Split(':').Length < 3) + { + url += ":80"; + } - return string.Equals(location, savedUri, StringComparison.OrdinalIgnoreCase); + return url; } private LiveTvOptions GetConfiguration() -- cgit v1.2.3 From 14f97d61765c07b406127fec5937aea1e9e81e0f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 25 Jul 2015 13:21:10 -0400 Subject: update schedules direct --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 10 +++--- MediaBrowser.Api/Playback/BaseStreamingService.cs | 12 +++---- MediaBrowser.Api/Playback/Dash/MpegDashService.cs | 4 +-- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 4 +-- MediaBrowser.Api/Playback/Hls/VideoHlsService.cs | 4 +-- .../Playback/Progressive/VideoService.cs | 4 +-- .../LiveTv/IListingsProvider.cs | 2 +- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 4 ++- MediaBrowser.Dlna/Didl/DidlBuilder.cs | 40 +++++++++++++++------- .../LiveTv/Listings/SchedulesDirect.cs | 34 +++++++++++------- .../LiveTv/Listings/XmlTv.cs | 2 +- .../LiveTv/LiveTvManager.cs | 4 +-- 12 files changed, 77 insertions(+), 47 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index d05e0951a4..6c61ef66ff 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -1,5 +1,4 @@ -using System.Collections.Generic; -using MediaBrowser.Common.Configuration; +using MediaBrowser.Common.Configuration; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; @@ -10,6 +9,7 @@ using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using ServiceStack; using System; +using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Threading; @@ -350,6 +350,8 @@ namespace MediaBrowser.Api.LiveTv [Authenticated] public class AddListingProvider : ListingsProviderInfo, IReturn { + public bool ValidateLogin { get; set; } + public bool ValidateListings { get; set; } } [Route("/LiveTv/ListingProviders", "DELETE", Summary = "Deletes a listing provider")] @@ -402,9 +404,9 @@ namespace MediaBrowser.Api.LiveTv } } - public object Post(AddListingProvider request) + public async Task Post(AddListingProvider request) { - var result = _liveTvManager.SaveListingProvider(request).Result; + var result = await _liveTvManager.SaveListingProvider(request, request.ValidateLogin, request.ValidateListings).ConfigureAwait(false); return ToOptimizedResult(result); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 8505b5d3a9..3cc04333a1 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -819,11 +819,11 @@ namespace MediaBrowser.Api.Playback /// /// Gets the audio encoder. /// - /// The request. + /// The state. /// System.String. - protected string GetAudioEncoder(StreamRequest request) + protected string GetAudioEncoder(StreamState state) { - var codec = request.AudioCodec; + var codec = state.OutputAudioCodec; if (string.Equals(codec, "aac", StringComparison.OrdinalIgnoreCase)) { @@ -848,11 +848,11 @@ namespace MediaBrowser.Api.Playback /// /// Gets the name of the output video codec /// - /// The request. + /// The state. /// System.String. - protected string GetVideoEncoder(VideoStreamRequest request) + protected string GetVideoEncoder(StreamState state) { - var codec = request.VideoCodec; + var codec = state.OutputVideoCodec; if (!string.IsNullOrEmpty(codec)) { diff --git a/MediaBrowser.Api/Playback/Dash/MpegDashService.cs b/MediaBrowser.Api/Playback/Dash/MpegDashService.cs index 47eb38b2d5..c201ffd587 100644 --- a/MediaBrowser.Api/Playback/Dash/MpegDashService.cs +++ b/MediaBrowser.Api/Playback/Dash/MpegDashService.cs @@ -378,7 +378,7 @@ namespace MediaBrowser.Api.Playback.Dash protected override string GetAudioArguments(StreamState state) { - var codec = GetAudioEncoder(state.Request); + var codec = GetAudioEncoder(state); if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) { @@ -408,7 +408,7 @@ namespace MediaBrowser.Api.Playback.Dash protected override string GetVideoArguments(StreamState state) { - var codec = GetVideoEncoder(state.VideoRequest); + var codec = GetVideoEncoder(state); var args = "-codec:v:0 " + codec; diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 0a432a5802..305547e418 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -791,7 +791,7 @@ namespace MediaBrowser.Api.Playback.Hls protected override string GetAudioArguments(StreamState state) { - var codec = GetAudioEncoder(state.Request); + var codec = GetAudioEncoder(state); if (!state.IsOutputVideo) { @@ -856,7 +856,7 @@ namespace MediaBrowser.Api.Playback.Hls return string.Empty; } - var codec = GetVideoEncoder(state.VideoRequest); + var codec = GetVideoEncoder(state); var args = "-codec:v:0 " + codec; diff --git a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs index d8e3423fcf..dcfafee78c 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Api.Playback.Hls /// System.String. protected override string GetAudioArguments(StreamState state) { - var codec = GetAudioEncoder(state.Request); + var codec = GetAudioEncoder(state); if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase)) { @@ -83,7 +83,7 @@ namespace MediaBrowser.Api.Playback.Hls /// System.String. protected override string GetVideoArguments(StreamState state) { - var codec = GetVideoEncoder(state.VideoRequest); + var codec = GetVideoEncoder(state); var args = "-codec:v:0 " + codec; diff --git a/MediaBrowser.Api/Playback/Progressive/VideoService.cs b/MediaBrowser.Api/Playback/Progressive/VideoService.cs index ebd72b2ce1..84ae26248f 100644 --- a/MediaBrowser.Api/Playback/Progressive/VideoService.cs +++ b/MediaBrowser.Api/Playback/Progressive/VideoService.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Api.Playback.Progressive protected override string GetCommandLineArguments(string outputPath, StreamState state, bool isEncoding) { // Get the output codec name - var videoCodec = GetVideoEncoder(state.VideoRequest); + var videoCodec = GetVideoEncoder(state); var format = string.Empty; var keyFrame = string.Empty; @@ -183,7 +183,7 @@ namespace MediaBrowser.Api.Playback.Progressive } // Get the output codec name - var codec = GetAudioEncoder(state.Request); + var codec = GetAudioEncoder(state); var args = "-codec:a:0 " + codec; diff --git a/MediaBrowser.Controller/LiveTv/IListingsProvider.cs b/MediaBrowser.Controller/LiveTv/IListingsProvider.cs index 5e43f1d27a..e60183bd93 100644 --- a/MediaBrowser.Controller/LiveTv/IListingsProvider.cs +++ b/MediaBrowser.Controller/LiveTv/IListingsProvider.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.LiveTv string Type { get; } Task> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken); Task AddMetadata(ListingsProviderInfo info, List channels, CancellationToken cancellationToken); - Task Validate(ListingsProviderInfo info); + Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings); Task> GetLineups(ListingsProviderInfo info, string country, string location); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index a0deb34f0b..259f6925b2 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -349,8 +349,10 @@ namespace MediaBrowser.Controller.LiveTv /// Saves the listing provider. /// /// The information. + /// if set to true [validate login]. + /// if set to true [validate listings]. /// Task. - Task SaveListingProvider(ListingsProviderInfo info); + Task SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings); /// /// Gets the lineups. /// diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.cs index 50a6f3ba61..0e4cf73924 100644 --- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs +++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs @@ -120,7 +120,7 @@ namespace MediaBrowser.Dlna.Didl } } - AddCover(item, null, element); + AddCover(item, context, null, element); return element; } @@ -481,7 +481,7 @@ namespace MediaBrowser.Dlna.Didl AddCommonFields(folder, stubType, null, container, filter); - AddCover(folder, stubType, container); + AddCover(folder, context, stubType, container); return container; } @@ -764,7 +764,7 @@ namespace MediaBrowser.Dlna.Didl } } - private void AddCover(BaseItem item, StubType? stubType, XmlElement element) + private void AddCover(BaseItem item, BaseItem context, StubType? stubType, XmlElement element) { if (stubType.HasValue && stubType.Value == StubType.People) { @@ -772,7 +772,26 @@ namespace MediaBrowser.Dlna.Didl return; } - var imageInfo = GetImageInfo(item); + ImageDownloadInfo imageInfo = null; + + if (context is UserView) + { + var episode = item as Episode; + if (episode != null) + { + var parent = (BaseItem)episode.Series ?? episode.Season; + if (parent != null) + { + imageInfo = GetImageInfo(parent); + } + } + } + + // Finally, just use the image from the item + if (imageInfo == null) + { + imageInfo = GetImageInfo(item); + } if (imageInfo == null) { @@ -850,7 +869,7 @@ namespace MediaBrowser.Dlna.Didl private void AddEmbeddedImageAsCover(string name, XmlElement element) { var result = element.OwnerDocument; - + var icon = result.CreateElement("upnp", "albumArtURI", NS_UPNP); var profile = result.CreateAttribute("dlna", "profileID", NS_DLNA); profile.InnerText = _profile.AlbumArtPn; @@ -925,14 +944,11 @@ namespace MediaBrowser.Dlna.Didl } } - if (item is Audio || item is Episode) - { - item = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Primary)); + item = item.Parents.FirstOrDefault(i => i.HasImage(ImageType.Primary)); - if (item != null) - { - return GetImageInfo(item, ImageType.Primary); - } + if (item != null) + { + return GetImageInfo(item, ImageType.Primary); } return null; diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 65d24ee806..5fd9745a1a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -400,13 +400,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings _logger.Info("Headends on account "); - var countryParam = string.Equals("ca", country, StringComparison.OrdinalIgnoreCase) - ? "can" - : "USA"; - var options = new HttpRequestOptions() { - Url = ApiUrl + "/headends?country=" + countryParam + "&postalcode=" + location, + Url = ApiUrl + "/headends?country=" + country + "&postalcode=" + location, UserAgent = UserAgent, CancellationToken = cancellationToken }; @@ -595,18 +591,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings } } - public async Task Validate(ListingsProviderInfo info) + public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) { - if (string.IsNullOrWhiteSpace(info.ListingsId)) + if (validateLogin) { - throw new ArgumentException("Listings Id required"); + if (string.IsNullOrWhiteSpace(info.Username)) + { + throw new ArgumentException("Username is required"); + } + if (string.IsNullOrWhiteSpace(info.Password)) + { + throw new ArgumentException("Password is required"); + } } + if (validateListings) + { + if (string.IsNullOrWhiteSpace(info.ListingsId)) + { + throw new ArgumentException("Listings Id required"); + } - var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false); + var hasLineup = await HasLineup(info, CancellationToken.None).ConfigureAwait(false); - if (!hasLineup) - { - await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); + if (!hasLineup) + { + await AddLineupToAccount(info, CancellationToken.None).ConfigureAwait(false); + } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs index 2e6fc8277d..de107ced80 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTv.cs @@ -30,7 +30,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings // Might not be needed } - public Task Validate(ListingsProviderInfo info) + public async Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings) { // Check that the path or url is valid. If not, throw a file not found exception } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 3ca60ec513..d539562b8f 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2204,7 +2204,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv _taskManager.CancelIfRunningAndQueue(); } - public async Task SaveListingProvider(ListingsProviderInfo info) + public async Task SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings) { info = (ListingsProviderInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(ListingsProviderInfo)); @@ -2215,7 +2215,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv throw new ResourceNotFoundException(); } - await provider.Validate(info).ConfigureAwait(false); + await provider.Validate(info, validateLogin, validateListings).ConfigureAwait(false); var config = GetConfiguration(); -- cgit v1.2.3 From b19451284351d5b753067522e9ef82b873c08770 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 25 Jul 2015 14:11:46 -0400 Subject: update tuners --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 8 ++++---- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 2 +- MediaBrowser.Model/LiveTv/LiveTvOptions.cs | 1 + MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 4 +++- .../LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs | 2 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 9 ++++++++- .../Localization/Server/server.json | 6 ++++-- MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj | 12 ++++++++++++ 8 files changed, 34 insertions(+), 10 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 6c61ef66ff..b0359194c7 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -334,7 +334,7 @@ namespace MediaBrowser.Api.LiveTv [Route("/LiveTv/TunerHosts", "POST", Summary = "Adds a tuner host")] [Authenticated] - public class AddTunerHost : TunerHostInfo, IReturnVoid + public class AddTunerHost : TunerHostInfo, IReturn { } @@ -419,10 +419,10 @@ namespace MediaBrowser.Api.LiveTv _config.SaveConfiguration("livetv", config); } - public void Post(AddTunerHost request) + public async Task Post(AddTunerHost request) { - var task = _liveTvManager.SaveTunerHost(request); - Task.WaitAll(task); + var result = await _liveTvManager.SaveTunerHost(request).ConfigureAwait(false); + return ToOptimizedResult(result); } public void Delete(DeleteTunerHost request) diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 259f6925b2..53ad6dbdc7 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -344,7 +344,7 @@ namespace MediaBrowser.Controller.LiveTv /// /// The information. /// Task. - Task SaveTunerHost(TunerHostInfo info); + Task SaveTunerHost(TunerHostInfo info); /// /// Saves the listing provider. /// diff --git a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs index 3fc8416455..004ee2ce6a 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvOptions.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvOptions.cs @@ -24,6 +24,7 @@ namespace MediaBrowser.Model.LiveTv public string Id { get; set; } public string Url { get; set; } public string Type { get; set; } + public bool ImportFavoritesOnly { get; set; } } public class ListingsProviderInfo diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index d539562b8f..b7091ee097 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2172,7 +2172,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv return await _libraryManager.GetNamedView(user, name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false); } - public async Task SaveTunerHost(TunerHostInfo info) + public async Task SaveTunerHost(TunerHostInfo info) { info = (TunerHostInfo)_jsonSerializer.DeserializeFromString(_jsonSerializer.SerializeToString(info), typeof(TunerHostInfo)); @@ -2202,6 +2202,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv _config.SaveConfiguration("livetv", config); _taskManager.CancelIfRunningAndQueue(); + + return info; } public async Task SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs index cc2bb2d521..10baffea61 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunDiscovery.cs @@ -73,7 +73,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun } // Strip off the port - url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped); + url = new Uri(url).GetComponents(UriComponents.AbsoluteUri & ~UriComponents.Port, UriFormat.UriEscaped).TrimEnd('/'); await _liveTvManager.SaveTunerHost(new TunerHostInfo { diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 1e30a4fd8d..682abd20f4 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -60,7 +60,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun if (root != null) { - return root.Select(i => new ChannelInfo + var result = root.Select(i => new ChannelInfo { Name = i.GuideName, Number = i.GuideNumber.ToString(CultureInfo.InvariantCulture), @@ -68,6 +68,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun IsFavorite = i.Favorite }); + + if (info.ImportFavoritesOnly) + { + result = result.Where(i => (i.IsFavorite ?? true)).ToList(); + } + + return result; } return new List(); } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 2c2fd76a73..e5a36b12ff 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -1480,7 +1480,7 @@ "ButtonAddDevice": "Add Device", "HeaderAddDevice": "Add Device", "HeaderExternalServices": "External Services", - "LabelIpAddressPath": "IP Address / Path:", + "LabelTunerIpAddress": "Tuner IP Address:", "TabExternalServices": "External Services", "TabTuners": "Tuners", "HeaderGuideProviders": "Guide Providers", @@ -1489,5 +1489,7 @@ "GuideProviderListingsStep": "Step 2: Select Listings", "GuideProviderLoginStep": "Step 1: Login", "LabelLineup": "Lineup:", - "MessageTunerDeviceNotListed": "Is your tuner device not listed? Try installing an external service provider for more Live TV options." + "MessageTunerDeviceNotListed": "Is your tuner device not listed? Try installing an external service provider for more Live TV options.", + "LabelImportOnlyFavoriteChannels": "Restrict to channels marked as favorite", + "ImportFavoriteChannelsHelp": "If enabled, only channels that are marked as favorite on the tuner device will be imported." } diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index bc2b8eb7a1..982d68461e 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -195,6 +195,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -210,6 +216,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest -- 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.Controller/LiveTv/ILiveTvManager.cs') diff --git a/Emby.Drawing/ImageProcessor.cs b/Emby.Drawing/ImageProcessor.cs index 2ba4f5aab7..1e4537baef 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 6814ad751b..3ff4c4828e 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 53ad6dbdc7..8898753837 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 0e4cf73924..25514f1dca 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 3c6e43fde8..b63d797f43 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 c19ba54bd1..3f652ea6f5 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 4a8ae2365b..09d45066b1 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 daa137db64..0cf9976025 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 31f1b17dd1..2ff9a2813c 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 87e71e3278..2263b3e1f8 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 72fea2c799..9ffd8a500e 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 d8954724aa..f73e648fae 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 1e9292c4543381338df3d0135f326801f0daf2b4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 10 Aug 2015 15:09:10 -0400 Subject: update tv --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 5 +++- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 3 ++- .../LiveTv/Listings/Emby/EmbyListings.cs | 2 +- .../Listings/Emby/EmbyListingsNorthAmerica.cs | 2 +- .../LiveTv/Listings/Emby/IEmbyListingProvider.cs | 2 +- .../LiveTv/LiveTvManager.cs | 28 ++++++++++++++++------ 6 files changed, 30 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index bdec555611..e55103230c 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -440,6 +440,9 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "Id", Description = "Provider id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string Id { get; set; } + [ApiMember(Name = "Type", Description = "Provider Type", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string Type { get; set; } + [ApiMember(Name = "Location", Description = "Location", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string Location { get; set; } @@ -535,7 +538,7 @@ namespace MediaBrowser.Api.LiveTv public async Task Get(GetLineups request) { - var info = await _liveTvManager.GetLineups(request.Id, request.Country, request.Location).ConfigureAwait(false); + var info = await _liveTvManager.GetLineups(request.Type, request.Id, request.Country, request.Location).ConfigureAwait(false); return ToOptimizedSerializedResultUsingCache(info); } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 8898753837..e568b2eae3 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -357,10 +357,11 @@ namespace MediaBrowser.Controller.LiveTv /// /// Gets the lineups. /// + /// Type of the provider. /// The provider identifier. /// The country. /// The location. /// Task<List<NameIdPair>>. - Task> GetLineups(string providerId, string country, string location); + Task> GetLineups(string providerType, string providerId, string country, string location); } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListings.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListings.cs index 5edebb3937..e446ff469f 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListings.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListings.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby public Task> GetLineups(ListingsProviderInfo info, string country, string location) { - return GetListingsProvider(country).GetLineups(info, country, location); + return GetListingsProvider(country).GetLineups(country, location); } private IEmbyListingProvider GetListingsProvider(string country) diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListingsNorthAmerica.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListingsNorthAmerica.cs index 4713e3074d..6fc6975a84 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListingsNorthAmerica.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/EmbyListingsNorthAmerica.cs @@ -43,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby return Task.FromResult(true); } - public async Task> GetLineups(ListingsProviderInfo info, string country, string location) + public async Task> GetLineups(string country, string location) { // location = postal code var path = await GetResponse("https://data.emby.media/service/lineups?postalCode=" + location).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/IEmbyListingProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/IEmbyListingProvider.cs index 83477acfcf..95c22b9869 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/IEmbyListingProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/Listings/Emby/IEmbyListingProvider.cs @@ -13,6 +13,6 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings.Emby Task> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken); Task AddMetadata(ListingsProviderInfo info, List channels, CancellationToken cancellationToken); Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings); - Task> GetLineups(ListingsProviderInfo info, string country, string location); + Task> GetLineups(string country, string location); } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index aa883ce758..02ca7f0f6d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2272,20 +2272,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv return info; } - public Task> GetLineups(string providerId, string country, string location) + public Task> GetLineups(string providerType, string providerId, string country, string location) { var config = GetConfiguration(); - var info = config.ListingProviders.FirstOrDefault(i => string.Equals(i.Id, providerId, StringComparison.OrdinalIgnoreCase)); + if (string.IsNullOrWhiteSpace(providerId)) + { + var provider = _listingProviders.FirstOrDefault(i => string.Equals(providerType, i.Type, StringComparison.OrdinalIgnoreCase)); - var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); + if (provider == null) + { + throw new ResourceNotFoundException(); + } - if (provider == null) - { - throw new ResourceNotFoundException(); + return provider.GetLineups(null, country, location); } + else + { + var info = config.ListingProviders.FirstOrDefault(i => string.Equals(i.Id, providerId, StringComparison.OrdinalIgnoreCase)); - return provider.GetLineups(info, country, location); + var provider = _listingProviders.FirstOrDefault(i => string.Equals(info.Type, i.Type, StringComparison.OrdinalIgnoreCase)); + + if (provider == null) + { + throw new ResourceNotFoundException(); + } + + return provider.GetLineups(info, country, location); + } } } } -- cgit v1.2.3 From 9c879eefc33df13b7dac555e159d5c4ccf09213e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 14 Aug 2015 15:14:54 -0400 Subject: update channel settings --- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 3 +-- MediaBrowser.Model/Configuration/UserConfiguration.cs | 1 + MediaBrowser.Server.Implementations/Library/LibraryManager.cs | 2 +- MediaBrowser.Server.Implementations/Library/UserViewManager.cs | 5 ++--- MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs | 6 +++--- 5 files changed, 8 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index e568b2eae3..df09d39b26 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -273,10 +273,9 @@ namespace MediaBrowser.Controller.LiveTv /// /// Gets the live tv folder. /// - /// The user identifier. /// The cancellation token. /// BaseItemDto. - Task GetInternalLiveTvFolder(string userId, CancellationToken cancellationToken); + Task GetInternalLiveTvFolder(CancellationToken cancellationToken); /// /// Gets the live tv folder. diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index 9dd84bc7dd..3497809584 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -50,6 +50,7 @@ namespace MediaBrowser.Model.Configuration public string[] PlainFolderViews { get; set; } public bool HidePlayedInLatest { get; set; } + public bool DisplayChannelsInline { get; set; } /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index c316aab25e..0cfd38479a 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1824,7 +1824,7 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentNullException("name"); } - var idValues = "37_namedview_" + name + (parentId ?? string.Empty); + var idValues = "37_namedview_" + name + (parentId ?? string.Empty) + (viewType ?? string.Empty); if (!string.IsNullOrWhiteSpace(uniqueId)) { idValues += uniqueId; diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index 5d753826a2..a609c53ab6 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -156,7 +156,7 @@ namespace MediaBrowser.Server.Implementations.Library var channels = channelResult.Items; var embeddedChannels = channels - .Where(i => user.Configuration.DisplayChannelsWithinViews.Contains(i.Id.ToString("N"))) + .Where(i => user.Configuration.DisplayChannelsInline || user.Configuration.DisplayChannelsWithinViews.Contains(i.Id.ToString("N"))) .ToList(); list.AddRange(embeddedChannels); @@ -168,8 +168,7 @@ namespace MediaBrowser.Server.Implementations.Library if (_liveTvManager.GetEnabledUsers().Select(i => i.Id.ToString("N")).Contains(query.UserId)) { - var name = _localizationManager.GetLocalizedString("ViewType" + CollectionType.LiveTv); - list.Add(await _libraryManager.GetNamedView(name, CollectionType.LiveTv, string.Empty, cancellationToken).ConfigureAwait(false)); + list.Add(await _liveTvManager.GetInternalLiveTvFolder(CancellationToken.None).ConfigureAwait(false)); } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index cc3c06dd4f..782473bea6 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2196,15 +2196,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv { var user = string.IsNullOrEmpty(userId) ? null : _userManager.GetUserById(userId); - var folder = await GetInternalLiveTvFolder(userId, cancellationToken).ConfigureAwait(false); + var folder = await GetInternalLiveTvFolder(cancellationToken).ConfigureAwait(false); return _dtoService.GetBaseItemDto(folder, new DtoOptions(), user); } - public async Task GetInternalLiveTvFolder(string userId, CancellationToken cancellationToken) + public async Task GetInternalLiveTvFolder(CancellationToken cancellationToken) { var name = _localization.GetLocalizedString("ViewTypeLiveTV"); - return await _libraryManager.GetNamedView(name, "livetv", "zz_" + name, cancellationToken).ConfigureAwait(false); + return await _libraryManager.GetNamedView(name, "livetv", name, cancellationToken).ConfigureAwait(false); } public async Task SaveTunerHost(TunerHostInfo info) -- cgit v1.2.3 From 4307c67b5e518ef2514740b0a874f5832f31e537 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 21 Aug 2015 15:25:35 -0400 Subject: update setup wizard --- MediaBrowser.Api/LiveTv/LiveTvService.cs | 21 +++++++++++++++ .../LiveTv/IHasRegistrationInfo.cs | 15 +++++++++++ MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 10 +++++++ .../MediaBrowser.Controller.csproj | 1 + .../LiveTv/EmbyTV/EmbyTV.cs | 31 +++++++++++++++++++--- .../LiveTv/LiveTvManager.cs | 29 ++++++++++++++++++++ 6 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index e55103230c..c1f8ac3ea1 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -456,6 +456,20 @@ namespace MediaBrowser.Api.LiveTv { } + [Route("/LiveTv/Registration", "GET")] + [Authenticated] + public class GetLiveTvRegistrationInfo : IReturn + { + [ApiMember(Name = "ChannelId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ChannelId { get; set; } + + [ApiMember(Name = "ProgramId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string ProgramId { get; set; } + + [ApiMember(Name = "Feature", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string Feature { get; set; } + } + public class LiveTvService : BaseApiService { private readonly ILiveTvManager _liveTvManager; @@ -471,6 +485,13 @@ namespace MediaBrowser.Api.LiveTv _httpClient = httpClient; } + public async Task Get(GetLiveTvRegistrationInfo request) + { + var result = await _liveTvManager.GetRegistrationInfo(request.ChannelId, request.ProgramId, request.Feature).ConfigureAwait(false); + + return ToOptimizedResult(result); + } + public async Task Get(GetSchedulesDirectCountries request) { // https://json.schedulesdirect.org/20141201/available/countries diff --git a/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs b/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs new file mode 100644 index 0000000000..3626c18e54 --- /dev/null +++ b/MediaBrowser.Controller/LiveTv/IHasRegistrationInfo.cs @@ -0,0 +1,15 @@ +using MediaBrowser.Model.Entities; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.LiveTv +{ + public interface IHasRegistrationInfo + { + /// + /// Gets the registration information. + /// + /// The feature. + /// Task<MBRegistrationRecord>. + Task GetRegistrationInfo(string feature); + } +} diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index df09d39b26..2b121eeeb5 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -2,6 +2,7 @@ using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; using System.Collections.Generic; @@ -362,5 +363,14 @@ namespace MediaBrowser.Controller.LiveTv /// The location. /// Task<List<NameIdPair>>. Task> GetLineups(string providerType, string providerId, string country, string location); + + /// + /// Gets the registration information. + /// + /// The channel identifier. + /// The program identifier. + /// The feature. + /// Task<MBRegistrationRecord>. + Task GetRegistrationInfo(string channelId, string programId, string feature); } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index b84fe3c712..24309734f8 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -199,6 +199,7 @@ + diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 200c6c9a6e..708828d479 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -2,9 +2,11 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Common.IO; using MediaBrowser.Common.Net; +using MediaBrowser.Common.Security; using MediaBrowser.Controller.Drawing; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.Events; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Logging; @@ -19,7 +21,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV { - public class EmbyTV : ILiveTvService, IDisposable + public class EmbyTV : ILiveTvService, IHasRegistrationInfo, IDisposable { private readonly IApplicationHost _appHpst; private readonly ILogger _logger; @@ -33,10 +35,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV private readonly LiveTvManager _liveTvManager; private readonly IFileSystem _fileSystem; + private readonly ISecurityManager _security; public static EmbyTV Current; - public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem) + public EmbyTV(IApplicationHost appHost, ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IConfigurationManager config, ILiveTvManager liveTvManager, IFileSystem fileSystem, ISecurityManager security) { Current = this; @@ -45,6 +48,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV _httpClient = httpClient; _config = config; _fileSystem = fileSystem; + _security = security; _liveTvManager = (LiveTvManager)liveTvManager; _jsonSerializer = jsonSerializer; @@ -629,9 +633,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV .Where(i => string.Equals(i.SeriesTimerId, seriesTimer.Id, StringComparison.OrdinalIgnoreCase)) .ToList(); - foreach (var timer in newTimers) + var registration = await GetRegistrationInfo("seriesrecordings").ConfigureAwait(false); + + if (registration.IsValid) { - _timerProvider.AddOrUpdate(timer); + foreach (var timer in newTimers) + { + _timerProvider.AddOrUpdate(timer); + } } var newTimerIds = newTimers.Select(i => i.Id).ToList(); @@ -728,5 +737,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV pair.Value.Cancel(); } } + + public Task GetRegistrationInfo(string feature) + { + if (string.Equals(feature, "seriesrecordings", StringComparison.OrdinalIgnoreCase)) + { + return _security.GetRegistrationStatus("embytvseriesrecordings"); + } + + return Task.FromResult(new MBRegistrationRecord + { + IsValid = true, + IsRegistered = true + }); + } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index cabe04f0fb..4109617dbb 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -2286,5 +2286,34 @@ namespace MediaBrowser.Server.Implementations.LiveTv return provider.GetLineups(info, country, location); } } + + public Task GetRegistrationInfo(string channelId, string programId, string feature) + { + ILiveTvService service; + + if (string.IsNullOrWhiteSpace(programId)) + { + var channel = GetInternalChannel(channelId); + service = GetService(channel); + } + else + { + var program = GetInternalProgram(programId); + service = GetService(program); + } + + var hasRegistration = service as IHasRegistrationInfo; + + if (hasRegistration != null) + { + return hasRegistration.GetRegistrationInfo(feature); + } + + return Task.FromResult(new MBRegistrationRecord + { + IsValid = true, + IsRegistered = true + }); + } } } -- cgit v1.2.3 From 8e8ce40de20c2d85e09a33c8345b7dbac0a6419d Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 31 Aug 2015 00:57:12 -0400 Subject: display current program in tv channel osd --- MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 9 +++++++ MediaBrowser.Model/Dto/BaseItemDto.cs | 6 ++++- .../Dto/DtoService.cs | 16 ++++++------- .../LiveTv/LiveTvManager.cs | 28 ++++++++++++++++++++++ 4 files changed, 50 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Controller/LiveTv/ILiveTvManager.cs') diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 2b121eeeb5..1458c1bc2e 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -372,5 +372,14 @@ namespace MediaBrowser.Controller.LiveTv /// The feature. /// Task<MBRegistrationRecord>. Task GetRegistrationInfo(string channelId, string programId, string feature); + + /// + /// Adds the channel information. + /// + /// The dto. + /// The channel. + /// The options. + /// The user. + void AddChannelInfo(BaseItemDto dto, LiveTvChannel channel, DtoOptions options, User user); } } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index ac8fa3370b..a1c0755634 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -1195,6 +1195,10 @@ namespace MediaBrowser.Model.Dto /// /// The timer identifier. public string TimerId { get; set; } - + /// + /// Gets or sets the current program. + /// + /// The current program. + public BaseItemDto CurrentProgram { get; set; } } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index aa6ab1d65e..edfef38fd0 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -98,7 +98,7 @@ namespace MediaBrowser.Server.Implementations.Dto var byName = item as IItemByName; - if (byName != null && !(item is LiveTvChannel)) + if (byName != null) { if (options.Fields.Contains(ItemFields.ItemCounts)) { @@ -140,7 +140,7 @@ namespace MediaBrowser.Server.Implementations.Dto var byName = item as IItemByName; - if (byName != null && !(item is LiveTvChannel)) + if (byName != null) { if (options.Fields.Contains(ItemFields.ItemCounts)) { @@ -351,6 +351,12 @@ namespace MediaBrowser.Server.Implementations.Dto AttachBasicFields(dto, item, owner, options); + var tvChannel = item as LiveTvChannel; + if (tvChannel != null) + { + _livetvManager().AddChannelInfo(dto, tvChannel, options, user); + } + var collectionFolder = item as ICollectionFolder; if (collectionFolder != null) { @@ -1520,12 +1526,6 @@ namespace MediaBrowser.Server.Implementations.Dto SetPhotoProperties(dto, photo); } - var tvChannel = item as LiveTvChannel; - if (tvChannel != null) - { - dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(tvChannel, true).ToList(); - } - dto.ChannelId = item.ChannelId; var channelItem = item as IChannelItem; diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 9cd4a2334e..ff7700124c 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1040,6 +1040,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv { cancellationToken.ThrowIfCancellationRequested(); + _logger.Debug("Refreshing guide from {0}", service.Name); + try { var innerProgress = new ActionableProgress(); @@ -1721,6 +1723,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv return dto; } + public void AddChannelInfo(BaseItemDto dto, LiveTvChannel channel, DtoOptions options, User user) + { + dto.MediaSources = channel.GetMediaSources(true).ToList(); + + var now = DateTime.UtcNow; + + var programs = _libraryManager.GetItems(new InternalItemsQuery + { + IncludeItemTypes = new[] { typeof(LiveTvProgram).Name }, + ChannelIds = new[] { channel.Id.ToString("N") }, + MaxStartDate = now, + MinEndDate = now, + Limit = 1 + + }).Items.Cast(); + + var currentProgram = programs + .OrderBy(i => i.StartDate) + .FirstOrDefault(); + + if (currentProgram != null) + { + dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user); + } + } + private async Task> GetNewTimerDefaultsInternal(CancellationToken cancellationToken, LiveTvProgram program = null) { var service = program != null && !string.IsNullOrWhiteSpace(program.ServiceName) ? -- cgit v1.2.3