diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-07-25 13:21:10 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2015-07-25 13:21:10 -0400 |
| commit | 14f97d61765c07b406127fec5937aea1e9e81e0f (patch) | |
| tree | 82d8dac63bfd6048fc8a6889ef2d49236f525a5f | |
| parent | 6a6145294ad19a0d88ad3928b48c7877bbf1b473 (diff) | |
update schedules direct
12 files changed, 77 insertions, 47 deletions
diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index d05e0951a..6c61ef66f 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<ListingsProviderInfo> { + 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<object> 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 8505b5d3a..3cc04333a 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -819,11 +819,11 @@ namespace MediaBrowser.Api.Playback /// <summary> /// Gets the audio encoder. /// </summary> - /// <param name="request">The request.</param> + /// <param name="state">The state.</param> /// <returns>System.String.</returns> - 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 /// <summary> /// Gets the name of the output video codec /// </summary> - /// <param name="request">The request.</param> + /// <param name="state">The state.</param> /// <returns>System.String.</returns> - 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 47eb38b2d..c201ffd58 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 0a432a580..305547e41 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 d8e3423fc..dcfafee78 100644 --- a/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/VideoHlsService.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Api.Playback.Hls /// <returns>System.String.</returns> 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 /// <returns>System.String.</returns> 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 ebd72b2ce..84ae26248 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 5e43f1d27..e60183bd9 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<IEnumerable<ProgramInfo>> GetProgramsAsync(ListingsProviderInfo info, string channelNumber, DateTime startDateUtc, DateTime endDateUtc, CancellationToken cancellationToken); Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken); - Task Validate(ListingsProviderInfo info); + Task Validate(ListingsProviderInfo info, bool validateLogin, bool validateListings); Task<List<NameIdPair>> GetLineups(ListingsProviderInfo info, string country, string location); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index a0deb34f0..259f6925b 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. /// </summary> /// <param name="info">The information.</param> + /// <param name="validateLogin">if set to <c>true</c> [validate login].</param> + /// <param name="validateListings">if set to <c>true</c> [validate listings].</param> /// <returns>Task.</returns> - Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info); + Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info, bool validateLogin, bool validateListings); /// <summary> /// Gets the lineups. /// </summary> diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.cs index 50a6f3ba6..0e4cf7392 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 65d24ee80..5fd9745a1 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 2e6fc8277..de107ced8 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 3ca60ec51..d539562b8 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<RefreshChannelsScheduledTask>(); } - public async Task<ListingsProviderInfo> SaveListingProvider(ListingsProviderInfo info) + public async Task<ListingsProviderInfo> 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(); |
