From 3862207a7352feddfae6416ba2dff4e78620089a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 31 Aug 2016 16:46:09 -0400 Subject: [PATCH 1/4] move channel view setting to global --- MediaBrowser.Model/Configuration/ServerConfiguration.cs | 1 + MediaBrowser.Model/Configuration/UserConfiguration.cs | 1 - .../Library/UserViewManager.cs | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index abe572cc8..9022f64a1 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -204,6 +204,7 @@ namespace MediaBrowser.Model.Configuration public bool DisplayCollectionsView { get; set; } public string[] LocalNetworkAddresses { get; set; } public string[] CodecsUsed { get; set; } + public bool EnableChannelView { get; set; } /// /// Initializes a new instance of the class. diff --git a/MediaBrowser.Model/Configuration/UserConfiguration.cs b/MediaBrowser.Model/Configuration/UserConfiguration.cs index 313c5243c..a6785a06a 100644 --- a/MediaBrowser.Model/Configuration/UserConfiguration.cs +++ b/MediaBrowser.Model/Configuration/UserConfiguration.cs @@ -41,7 +41,6 @@ namespace MediaBrowser.Model.Configuration public string[] PlainFolderViews { get; set; } public bool HidePlayedInLatest { get; set; } - public bool EnableChannelView { get; set; } public bool RememberAudioSelections { get; set; } public bool RememberSubtitleSelections { get; set; } diff --git a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs index 5fffa3d1f..2cbee7c97 100644 --- a/MediaBrowser.Server.Implementations/Library/UserViewManager.cs +++ b/MediaBrowser.Server.Implementations/Library/UserViewManager.cs @@ -120,8 +120,8 @@ namespace MediaBrowser.Server.Implementations.Library }, cancellationToken).ConfigureAwait(false); var channels = channelResult.Items; - - if (user.Configuration.EnableChannelView && channels.Length > 0) + + if (_config.Configuration.EnableChannelView && channels.Length > 0) { list.Add(await _channelManager.GetInternalChannelFolder(cancellationToken).ConfigureAwait(false)); } From 699bdacebc94635f129d3e68cfaaa49ebc0ff6f6 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 31 Aug 2016 17:07:02 -0400 Subject: [PATCH 2/4] add setting to hide external content from suggestions --- MediaBrowser.Api/Library/LibraryService.cs | 7 +- MediaBrowser.Api/Movies/MoviesService.cs | 75 +++++++++++-------- .../Configuration/ServerConfiguration.cs | 2 + 3 files changed, 51 insertions(+), 33 deletions(-) diff --git a/MediaBrowser.Api/Library/LibraryService.cs b/MediaBrowser.Api/Library/LibraryService.cs index 14a771db0..c6b637f01 100644 --- a/MediaBrowser.Api/Library/LibraryService.cs +++ b/MediaBrowser.Api/Library/LibraryService.cs @@ -25,6 +25,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using CommonIO; +using MediaBrowser.Controller.Configuration; namespace MediaBrowser.Api.Library { @@ -288,12 +289,13 @@ namespace MediaBrowser.Api.Library private readonly ITVSeriesManager _tvManager; private readonly ILibraryMonitor _libraryMonitor; private readonly IFileSystem _fileSystem; + private readonly IServerConfigurationManager _config; /// /// Initializes a new instance of the class. /// public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, - IDtoService dtoService, IUserDataManager userDataManager, IAuthorizationContext authContext, IActivityManager activityManager, ILocalizationManager localization, ILiveTvManager liveTv, ITVSeriesManager tvManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem) + IDtoService dtoService, IUserDataManager userDataManager, IAuthorizationContext authContext, IActivityManager activityManager, ILocalizationManager localization, ILiveTvManager liveTv, ITVSeriesManager tvManager, ILibraryMonitor libraryMonitor, IFileSystem fileSystem, IServerConfigurationManager config) { _itemRepo = itemRepo; _libraryManager = libraryManager; @@ -307,6 +309,7 @@ namespace MediaBrowser.Api.Library _tvManager = tvManager; _libraryMonitor = libraryMonitor; _fileSystem = fileSystem; + _config = config; } public object Get(GetSimilarItems request) @@ -377,7 +380,7 @@ namespace MediaBrowser.Api.Library if (item is Movie || (program != null && program.IsMovie) || item is Trailer) { - return new MoviesService(_userManager, _userDataManager, _libraryManager, _itemRepo, _dtoService) + return new MoviesService(_userManager, _userDataManager, _libraryManager, _itemRepo, _dtoService, _config) { AuthorizationContext = AuthorizationContext, Logger = Logger, diff --git a/MediaBrowser.Api/Movies/MoviesService.cs b/MediaBrowser.Api/Movies/MoviesService.cs index 66f2fac81..f153a0475 100644 --- a/MediaBrowser.Api/Movies/MoviesService.cs +++ b/MediaBrowser.Api/Movies/MoviesService.cs @@ -14,6 +14,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.LiveTv; namespace MediaBrowser.Api.Movies @@ -88,6 +89,7 @@ namespace MediaBrowser.Api.Movies private readonly IItemRepository _itemRepo; private readonly IDtoService _dtoService; + private readonly IServerConfigurationManager _config; /// /// Initializes a new instance of the class. @@ -97,13 +99,14 @@ namespace MediaBrowser.Api.Movies /// The library manager. /// The item repo. /// The dto service. - public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService) + public MoviesService(IUserManager userManager, IUserDataManager userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService, IServerConfigurationManager config) { _userManager = userManager; _userDataRepository = userDataRepository; _libraryManager = libraryManager; _itemRepo = itemRepo; _dtoService = dtoService; + _config = config; } /// @@ -146,15 +149,17 @@ namespace MediaBrowser.Api.Movies (!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder : _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); + var itemTypes = new List { typeof(Movie).Name }; + if (_config.Configuration.EnableExternalContentInSuggestions) + { + itemTypes.Add(typeof(Trailer).Name); + itemTypes.Add(typeof(LiveTvProgram).Name); + } + var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user) { Limit = request.Limit, - IncludeItemTypes = new[] - { - typeof(Movie).Name, - typeof(Trailer).Name, - typeof(LiveTvProgram).Name - }, + IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, SimilarTo = item, EnableGroupByMetadataKey = true @@ -198,14 +203,16 @@ namespace MediaBrowser.Api.Movies var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList(); + var itemTypes = new List { typeof(Movie).Name }; + if (_config.Configuration.EnableExternalContentInSuggestions) + { + itemTypes.Add(typeof(Trailer).Name); + itemTypes.Add(typeof(LiveTvProgram).Name); + } + var likedMovies = _libraryManager.GetItemList(new InternalItemsQuery(user) { - IncludeItemTypes = new[] - { - typeof(Movie).Name, - typeof(Trailer).Name, - typeof(LiveTvProgram).Name - }, + IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, SortBy = new[] { ItemSortBy.Random }, SortOrder = SortOrder.Descending, @@ -278,6 +285,13 @@ namespace MediaBrowser.Api.Movies private IEnumerable GetWithDirector(User user, IEnumerable names, int itemLimit, DtoOptions dtoOptions, RecommendationType type) { + var itemTypes = new List { typeof(Movie).Name }; + if (_config.Configuration.EnableExternalContentInSuggestions) + { + itemTypes.Add(typeof(Trailer).Name); + itemTypes.Add(typeof(LiveTvProgram).Name); + } + foreach (var name in names) { var items = _libraryManager.GetItemList(new InternalItemsQuery(user) @@ -286,12 +300,7 @@ namespace MediaBrowser.Api.Movies // Account for duplicates by imdb id, since the database doesn't support this yet Limit = itemLimit + 2, PersonTypes = new[] { PersonType.Director }, - IncludeItemTypes = new[] - { - typeof(Movie).Name, - typeof(Trailer).Name, - typeof(LiveTvProgram).Name - }, + IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, EnableGroupByMetadataKey = true @@ -314,6 +323,13 @@ namespace MediaBrowser.Api.Movies private IEnumerable GetWithActor(User user, IEnumerable names, int itemLimit, DtoOptions dtoOptions, RecommendationType type) { + var itemTypes = new List { typeof(Movie).Name }; + if (_config.Configuration.EnableExternalContentInSuggestions) + { + itemTypes.Add(typeof(Trailer).Name); + itemTypes.Add(typeof(LiveTvProgram).Name); + } + foreach (var name in names) { var items = _libraryManager.GetItemList(new InternalItemsQuery(user) @@ -321,12 +337,7 @@ namespace MediaBrowser.Api.Movies Person = name, // Account for duplicates by imdb id, since the database doesn't support this yet Limit = itemLimit + 2, - IncludeItemTypes = new[] - { - typeof(Movie).Name, - typeof(Trailer).Name, - typeof(LiveTvProgram).Name - }, + IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, EnableGroupByMetadataKey = true @@ -349,17 +360,19 @@ namespace MediaBrowser.Api.Movies private IEnumerable GetSimilarTo(User user, List baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type) { + var itemTypes = new List { typeof(Movie).Name }; + if (_config.Configuration.EnableExternalContentInSuggestions) + { + itemTypes.Add(typeof(Trailer).Name); + itemTypes.Add(typeof(LiveTvProgram).Name); + } + foreach (var item in baselineItems) { var similar = _libraryManager.GetItemList(new InternalItemsQuery(user) { Limit = itemLimit, - IncludeItemTypes = new[] - { - typeof(Movie).Name, - typeof(Trailer).Name, - typeof(LiveTvProgram).Name - }, + IncludeItemTypes = itemTypes.ToArray(), IsMovie = true, SimilarTo = item, EnableGroupByMetadataKey = true diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 9022f64a1..b0595b558 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -205,6 +205,7 @@ namespace MediaBrowser.Model.Configuration public string[] LocalNetworkAddresses { get; set; } public string[] CodecsUsed { get; set; } public bool EnableChannelView { get; set; } + public bool EnableExternalContentInSuggestions { get; set; } /// /// Initializes a new instance of the class. @@ -218,6 +219,7 @@ namespace MediaBrowser.Model.Configuration EnableLocalizedGuids = true; DisplaySpecialsWithinSeasons = true; + EnableExternalContentInSuggestions = true; ImageSavingConvention = ImageSavingConvention.Compatible; PublicPort = 8096; From 37dfbbe4776ef8cb005907cbc2ae96e64d641295 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 1 Sep 2016 12:36:11 -0400 Subject: [PATCH 3/4] update tabs --- .../HttpServer/HttpListenerHost.cs | 27 +++++++++++++------ .../Api/PackageCreator.cs | 2 +- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 28b7824c8..8e46f8f03 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -102,14 +102,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer // new SessionAuthProvider(_containerAdapter.Resolve()), //})); - PreRequestFilters.Add((httpReq, httpRes) => - { - //Handles Request and closes Responses after emitting global HTTP Headers - if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase)) - { - httpRes.EndRequest(); //add a 'using ServiceStack;' - } - }); + //PreRequestFilters.Add((httpReq, httpRes) => + //{ + // //Handles Request and closes Responses after emitting global HTTP Headers + // if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase)) + // { + // httpRes.EndRequest(); //add a 'using ServiceStack;' + // } + //}); HostContext.GlobalResponseFilters.Add(new ResponseFilter(_logger).FilterResponse); } @@ -403,6 +403,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer return; } + if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase)) + { + httpRes.StatusCode = 200; + httpRes.AddHeader("Access-Control-Allow-Origin", "*"); + httpRes.AddHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS"); + httpRes.AddHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Range, X-MediaBrowser-Token, X-Emby-Authorization"); + httpRes.ContentType = "text/html"; + + httpRes.Close(); + } + var operationName = httpReq.OperationName; var localPath = url.LocalPath; diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index 65e7fa5d3..adf36e4bf 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -346,7 +346,7 @@ namespace MediaBrowser.WebDashboard.Api if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) { - sb.Append(""); + sb.Append(""); } sb.Append(""); From 2f67a007cd30596fa1559852de23134d2194a23a Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 1 Sep 2016 16:21:55 -0400 Subject: [PATCH 4/4] update tabs --- MediaBrowser.WebDashboard/Api/PackageCreator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MediaBrowser.WebDashboard/Api/PackageCreator.cs b/MediaBrowser.WebDashboard/Api/PackageCreator.cs index adf36e4bf..019434c61 100644 --- a/MediaBrowser.WebDashboard/Api/PackageCreator.cs +++ b/MediaBrowser.WebDashboard/Api/PackageCreator.cs @@ -346,7 +346,7 @@ namespace MediaBrowser.WebDashboard.Api if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) { - sb.Append(""); + sb.Append(""); } sb.Append("");