From c273f5fd9c33415a1fa985222e43c9c02f3d36e5 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 30 Jun 2014 15:24:35 -0400 Subject: [PATCH] fixes #860 - Add options to display channels directly within user views --- MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs | 5 +++-- MediaBrowser.Controller/Channels/Channel.cs | 2 +- MediaBrowser.Model/Configuration/UserConfiguration.cs | 3 +++ .../Library/UserViewManager.cs | 11 +++++++++-- .../Localization/Server/server.json | 4 +++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index b5b6849ce..bde2c5694 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -335,8 +335,9 @@ namespace MediaBrowser.Api.Playback.Hls var newBitrate = totalBitrate - variation; AppendPlaylist(builder, playlistUrl.Replace(requestedVideoBitrate.ToString(UsCulture), (requestedVideoBitrate - variation).ToString(UsCulture)), newBitrate); - newBitrate = totalBitrate - (2 * variation); - AppendPlaylist(builder, playlistUrl.Replace(requestedVideoBitrate.ToString(UsCulture), (requestedVideoBitrate - (2 * variation)).ToString(UsCulture)), newBitrate); + variation *= 2; + newBitrate = totalBitrate - variation; + AppendPlaylist(builder, playlistUrl.Replace(requestedVideoBitrate.ToString(UsCulture), (requestedVideoBitrate - variation).ToString(UsCulture)), newBitrate); } return builder.ToString(); diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index 3d9d0d381..df38259b4 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -4,7 +4,7 @@ using System.Linq; namespace MediaBrowser.Controller.Channels { - public class Channel : BaseItem + public class Channel : Folder { public string OriginalChannelName { get; set; } diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index 94a41bdda..84ce2747a 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -65,6 +65,8 @@ namespace MediaBrowser.Model.Configuration public string[] BlockedMediaFolders { get; set; } public string[] BlockedChannels { get; set; } + public string[] DisplayChannelsWithinViews { get; set; } + public string[] ExcludeFoldersFromGrouping { get; set; } public UnratedItem[] BlockUnratedItems { get; set; } @@ -85,6 +87,7 @@ namespace MediaBrowser.Model.Configuration EnableLiveTvAccess = true; BlockedMediaFolders = new string[] { }; + DisplayChannelsWithinViews = new string[] { }; BlockedChannels = new string[] { }; BlockUnratedItems = new UnratedItem[] { }; diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index fc4b9eb4c..9ac82690b 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -90,12 +90,19 @@ namespace MediaBrowser.Server.Implementations.Library { var channelResult = await _channelManager.GetChannels(new ChannelQuery { - Limit = 0, UserId = query.UserId }, cancellationToken).ConfigureAwait(false); - if (channelResult.TotalRecordCount > 0) + var channels = channelResult.Items; + + var embeddedChannels = channels + .Where(i => user.Configuration.DisplayChannelsWithinViews.Contains(i.Id)) + .ToList(); + + list.AddRange(embeddedChannels.Select(i => _channelManager.GetChannel(i.Id))); + + if (channels.Length > embeddedChannels.Count) { list.Add(await _channelManager.GetInternalChannelFolder(query.UserId, cancellationToken).ConfigureAwait(false)); } diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 9063ebc4b..4a3d93d1e 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -846,5 +846,7 @@ "LabelXbmcMetadataSaveImagePathsHelp": "This is recommended if you have image file names that don't conform to Xbmc guidelines.", "LabelXbmcMetadataEnablePathSubstitution": "Enable path substitution", "LabelXbmcMetadataEnablePathSubstitutionHelp": "Enables path substitution of image paths using the server's path substitution settings.", - "LabelXbmcMetadataEnablePathSubstitutionHelp2": "See path substitution." + "LabelXbmcMetadataEnablePathSubstitutionHelp2": "See path substitution.", + "LabelGroupChannelsIntoViews": "Display the following channels within my views:", + "LabelGroupChannelsIntoViewsHelp": "If enabled, these channels will be displayed directly alongside other views. If disabled, they'll be displayed within a separate Channels view." } \ No newline at end of file