From 43ab885530a9b24eb03b060cbe0e895caf086fd7 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 17 Jun 2014 12:03:14 -0400 Subject: [PATCH] update latest channel content display --- MediaBrowser.Api/ChannelService.cs | 8 ++++ .../LiveTv/LiveTvChannel.cs | 24 +++++++++++- .../Encoder/EncodingUtils.cs | 37 +------------------ MediaBrowser.Model/Channels/ChannelQuery.cs | 10 +++++ .../Channels/ChannelManager.cs | 7 ++++ .../Localization/JavaScript/javascript.json | 13 ++++++- 6 files changed, 60 insertions(+), 39 deletions(-) diff --git a/MediaBrowser.Api/ChannelService.cs b/MediaBrowser.Api/ChannelService.cs index 3cd032015b..a6407349d8 100644 --- a/MediaBrowser.Api/ChannelService.cs +++ b/MediaBrowser.Api/ChannelService.cs @@ -34,6 +34,9 @@ namespace MediaBrowser.Api /// The limit. [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? Limit { get; set; } + + [ApiMember(Name = "SupportsLatestItems", Description = "Optional. Filter by channels that support getting latest items.", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? SupportsLatestItems { get; set; } } [Route("/Channels/{Id}/Features", "GET", Summary = "Gets features for a channel")] @@ -137,6 +140,9 @@ namespace MediaBrowser.Api [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; } + [ApiMember(Name = "ChannelIds", Description = "Optional. Specify one or more channel id's, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] + public string ChannelIds { get; set; } + /// /// Gets the filters. /// @@ -196,6 +202,7 @@ namespace MediaBrowser.Api Limit = request.Limit, StartIndex = request.StartIndex, UserId = request.UserId, + SupportsLatestItems = request.SupportsLatestItems }, CancellationToken.None).Result; @@ -227,6 +234,7 @@ namespace MediaBrowser.Api { Limit = request.Limit, StartIndex = request.StartIndex, + ChannelIds = (request.ChannelIds ?? string.Empty).Split(',').Where(i => !string.IsNullOrWhiteSpace(i)).ToArray(), UserId = request.UserId, Filters = request.GetFilters().ToArray(), Fields = request.GetItemFields().ToList() diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 3c1c9f442a..01fed68c8a 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -1,8 +1,11 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System.Collections.Generic; using System.Linq; +using MediaBrowser.Model.MediaInfo; namespace MediaBrowser.Controller.LiveTv { @@ -115,9 +118,26 @@ namespace MediaBrowser.Controller.LiveTv return new List(); } - public IEnumerable GetMediaSources(bool enablePathSubstitution) + public IEnumerable GetMediaSources(bool enablePathSubstitution) { - throw new System.NotImplementedException(); + var list = new List(); + + var locationType = LocationType; + + var info = new MediaSourceInfo + { + Id = Id.ToString("N"), + Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, + MediaStreams = new List(), + Name = Name, + Path = Path, + RunTimeTicks = RunTimeTicks, + Type = MediaSourceType.Default + }; + + list.Add(info); + + return list; } } } diff --git a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs index bf4daf7867..56ff427adf 100644 --- a/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs +++ b/MediaBrowser.MediaEncoding/Encoder/EncodingUtils.cs @@ -1,7 +1,4 @@ -using MediaBrowser.Controller.MediaEncoding; -using MediaBrowser.Model.Entities; -using MediaBrowser.Model.MediaInfo; -using System; +using MediaBrowser.Model.MediaInfo; using System.Collections.Generic; using System.Linq; @@ -61,37 +58,5 @@ namespace MediaBrowser.MediaEncoding.Encoder { return isDvd ? "-probesize 1G -analyzeduration 200M" : string.Empty; } - - /// - /// Gets the number of audio channels to specify on the command line - /// - /// The request. - /// The audio stream. - /// System.Nullable{System.Int32}. - public static int? GetNumAudioChannelsParam(EncodingOptions request, MediaStream audioStream) - { - if (audioStream != null) - { - var codec = request.AudioCodec ?? string.Empty; - - if (audioStream.Channels > 2 && codec.IndexOf("wma", StringComparison.OrdinalIgnoreCase) != -1) - { - // wmav2 currently only supports two channel output - return 2; - } - } - - if (request.MaxAudioChannels.HasValue) - { - if (audioStream != null && audioStream.Channels.HasValue) - { - return Math.Min(request.MaxAudioChannels.Value, audioStream.Channels.Value); - } - - return request.MaxAudioChannels.Value; - } - - return request.AudioChannels; - } } } diff --git a/MediaBrowser.Model/Channels/ChannelQuery.cs b/MediaBrowser.Model/Channels/ChannelQuery.cs index 9d4e26fa65..62bb543f67 100644 --- a/MediaBrowser.Model/Channels/ChannelQuery.cs +++ b/MediaBrowser.Model/Channels/ChannelQuery.cs @@ -22,10 +22,20 @@ namespace MediaBrowser.Model.Channels /// /// The limit. public int? Limit { get; set; } + + /// + /// Gets or sets a value indicating whether [supports latest items]. + /// + /// true if [supports latest items]; otherwise, false. + public bool? SupportsLatestItems { get; set; } } public class AllChannelMediaQuery { + /// + /// Gets or sets the channel ids. + /// + /// The channel ids. public string[] ChannelIds { get; set; } /// diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index 59e4e695dc..aaebd1c34c 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -107,6 +107,13 @@ namespace MediaBrowser.Server.Implementations.Channels var channels = _channelEntities.OrderBy(i => i.SortName).ToList(); + if (query.SupportsLatestItems.HasValue) + { + var val = query.SupportsLatestItems.Value; + channels = channels.Where(i => (GetChannelProvider(i) is ISupportsLatestMedia) == val) + .ToList(); + } + if (user != null) { channels = channels.Where(i => GetChannelProvider(i).IsEnabledFor(user.Id.ToString("N")) && i.IsVisible(user)) diff --git a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json index 8e698095f7..230e5fddc7 100644 --- a/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json +++ b/MediaBrowser.Server.Implementations/Localization/JavaScript/javascript.json @@ -38,6 +38,7 @@ "LabelEpisode": "Episode", "LabelSeries": "Series", "LabelStopping": "Stopping", + "ButtonStop": "Stop", "LabelCancelled": "(cancelled)", "LabelFailed": "(failed)", "LabelAbortedByServerShutdown": "(Aborted by server shutdown)", @@ -170,5 +171,15 @@ "MessageConfirmShutdown": "Are you sure you wish to shutdown Media Browser Server?", "ButtonUpdateNow": "Update Now", "NewVersionOfSomethingAvailable": "A new version of {0} is available!", - "VersionXIsAvailableForDownload": "Version {0} is now available for download." + "VersionXIsAvailableForDownload": "Version {0} is now available for download.", + "LabelVersionNumber": "Version {0}", + "LabelPlayMethodTranscoding": "Transcoding", + "LabelPlayMethodDirectStream": "Direct Streaming", + "LabelPlayMethodDirectPlay": "Direct Playing", + "LabelAudioCodec": "Audio: {0}", + "LabelVideoCodec": "Video: {0}", + "LabelRemoteAccessUrl": "Remote access: {0}", + "LabelRunningOnPort": "Running on port {0}.", + "LabelRunningOnPorts": "Running on ports {0} and {1}.", + "HeaderLatestFromChannel": "Latest from {0}" } \ No newline at end of file