Merge pull request #2133 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-09-01 16:22:51 -04:00 committed by GitHub
commit e617e218bd
7 changed files with 74 additions and 45 deletions

View File

@ -25,6 +25,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using CommonIO; using CommonIO;
using MediaBrowser.Controller.Configuration;
namespace MediaBrowser.Api.Library namespace MediaBrowser.Api.Library
{ {
@ -288,12 +289,13 @@ namespace MediaBrowser.Api.Library
private readonly ITVSeriesManager _tvManager; private readonly ITVSeriesManager _tvManager;
private readonly ILibraryMonitor _libraryMonitor; private readonly ILibraryMonitor _libraryMonitor;
private readonly IFileSystem _fileSystem; private readonly IFileSystem _fileSystem;
private readonly IServerConfigurationManager _config;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LibraryService" /> class. /// Initializes a new instance of the <see cref="LibraryService" /> class.
/// </summary> /// </summary>
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, 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; _itemRepo = itemRepo;
_libraryManager = libraryManager; _libraryManager = libraryManager;
@ -307,6 +309,7 @@ namespace MediaBrowser.Api.Library
_tvManager = tvManager; _tvManager = tvManager;
_libraryMonitor = libraryMonitor; _libraryMonitor = libraryMonitor;
_fileSystem = fileSystem; _fileSystem = fileSystem;
_config = config;
} }
public object Get(GetSimilarItems request) public object Get(GetSimilarItems request)
@ -377,7 +380,7 @@ namespace MediaBrowser.Api.Library
if (item is Movie || (program != null && program.IsMovie) || item is Trailer) 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, AuthorizationContext = AuthorizationContext,
Logger = Logger, Logger = Logger,

View File

@ -14,6 +14,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.LiveTv;
namespace MediaBrowser.Api.Movies namespace MediaBrowser.Api.Movies
@ -88,6 +89,7 @@ namespace MediaBrowser.Api.Movies
private readonly IItemRepository _itemRepo; private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService; private readonly IDtoService _dtoService;
private readonly IServerConfigurationManager _config;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="MoviesService" /> class. /// Initializes a new instance of the <see cref="MoviesService" /> class.
@ -97,13 +99,14 @@ namespace MediaBrowser.Api.Movies
/// <param name="libraryManager">The library manager.</param> /// <param name="libraryManager">The library manager.</param>
/// <param name="itemRepo">The item repo.</param> /// <param name="itemRepo">The item repo.</param>
/// <param name="dtoService">The dto service.</param> /// <param name="dtoService">The dto service.</param>
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; _userManager = userManager;
_userDataRepository = userDataRepository; _userDataRepository = userDataRepository;
_libraryManager = libraryManager; _libraryManager = libraryManager;
_itemRepo = itemRepo; _itemRepo = itemRepo;
_dtoService = dtoService; _dtoService = dtoService;
_config = config;
} }
/// <summary> /// <summary>
@ -146,15 +149,17 @@ namespace MediaBrowser.Api.Movies
(!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder : (!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder :
_libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id); _libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id);
var itemTypes = new List<string> { typeof(Movie).Name };
if (_config.Configuration.EnableExternalContentInSuggestions)
{
itemTypes.Add(typeof(Trailer).Name);
itemTypes.Add(typeof(LiveTvProgram).Name);
}
var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user) var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
Limit = request.Limit, Limit = request.Limit,
IncludeItemTypes = new[] IncludeItemTypes = itemTypes.ToArray(),
{
typeof(Movie).Name,
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
IsMovie = true, IsMovie = true,
SimilarTo = item, SimilarTo = item,
EnableGroupByMetadataKey = true EnableGroupByMetadataKey = true
@ -198,14 +203,16 @@ namespace MediaBrowser.Api.Movies
var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList(); var recentlyPlayedMovies = _libraryManager.GetItemList(query).ToList();
var itemTypes = new List<string> { typeof(Movie).Name };
if (_config.Configuration.EnableExternalContentInSuggestions)
{
itemTypes.Add(typeof(Trailer).Name);
itemTypes.Add(typeof(LiveTvProgram).Name);
}
var likedMovies = _libraryManager.GetItemList(new InternalItemsQuery(user) var likedMovies = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
IncludeItemTypes = new[] IncludeItemTypes = itemTypes.ToArray(),
{
typeof(Movie).Name,
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
IsMovie = true, IsMovie = true,
SortBy = new[] { ItemSortBy.Random }, SortBy = new[] { ItemSortBy.Random },
SortOrder = SortOrder.Descending, SortOrder = SortOrder.Descending,
@ -278,6 +285,13 @@ namespace MediaBrowser.Api.Movies
private IEnumerable<RecommendationDto> GetWithDirector(User user, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type) private IEnumerable<RecommendationDto> GetWithDirector(User user, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{ {
var itemTypes = new List<string> { typeof(Movie).Name };
if (_config.Configuration.EnableExternalContentInSuggestions)
{
itemTypes.Add(typeof(Trailer).Name);
itemTypes.Add(typeof(LiveTvProgram).Name);
}
foreach (var name in names) foreach (var name in names)
{ {
var items = _libraryManager.GetItemList(new InternalItemsQuery(user) 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 // Account for duplicates by imdb id, since the database doesn't support this yet
Limit = itemLimit + 2, Limit = itemLimit + 2,
PersonTypes = new[] { PersonType.Director }, PersonTypes = new[] { PersonType.Director },
IncludeItemTypes = new[] IncludeItemTypes = itemTypes.ToArray(),
{
typeof(Movie).Name,
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
IsMovie = true, IsMovie = true,
EnableGroupByMetadataKey = true EnableGroupByMetadataKey = true
@ -314,6 +323,13 @@ namespace MediaBrowser.Api.Movies
private IEnumerable<RecommendationDto> GetWithActor(User user, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type) private IEnumerable<RecommendationDto> GetWithActor(User user, IEnumerable<string> names, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{ {
var itemTypes = new List<string> { typeof(Movie).Name };
if (_config.Configuration.EnableExternalContentInSuggestions)
{
itemTypes.Add(typeof(Trailer).Name);
itemTypes.Add(typeof(LiveTvProgram).Name);
}
foreach (var name in names) foreach (var name in names)
{ {
var items = _libraryManager.GetItemList(new InternalItemsQuery(user) var items = _libraryManager.GetItemList(new InternalItemsQuery(user)
@ -321,12 +337,7 @@ namespace MediaBrowser.Api.Movies
Person = name, Person = name,
// Account for duplicates by imdb id, since the database doesn't support this yet // Account for duplicates by imdb id, since the database doesn't support this yet
Limit = itemLimit + 2, Limit = itemLimit + 2,
IncludeItemTypes = new[] IncludeItemTypes = itemTypes.ToArray(),
{
typeof(Movie).Name,
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
IsMovie = true, IsMovie = true,
EnableGroupByMetadataKey = true EnableGroupByMetadataKey = true
@ -349,17 +360,19 @@ namespace MediaBrowser.Api.Movies
private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type) private IEnumerable<RecommendationDto> GetSimilarTo(User user, List<BaseItem> baselineItems, int itemLimit, DtoOptions dtoOptions, RecommendationType type)
{ {
var itemTypes = new List<string> { typeof(Movie).Name };
if (_config.Configuration.EnableExternalContentInSuggestions)
{
itemTypes.Add(typeof(Trailer).Name);
itemTypes.Add(typeof(LiveTvProgram).Name);
}
foreach (var item in baselineItems) foreach (var item in baselineItems)
{ {
var similar = _libraryManager.GetItemList(new InternalItemsQuery(user) var similar = _libraryManager.GetItemList(new InternalItemsQuery(user)
{ {
Limit = itemLimit, Limit = itemLimit,
IncludeItemTypes = new[] IncludeItemTypes = itemTypes.ToArray(),
{
typeof(Movie).Name,
typeof(Trailer).Name,
typeof(LiveTvProgram).Name
},
IsMovie = true, IsMovie = true,
SimilarTo = item, SimilarTo = item,
EnableGroupByMetadataKey = true EnableGroupByMetadataKey = true

View File

@ -204,6 +204,8 @@ namespace MediaBrowser.Model.Configuration
public bool DisplayCollectionsView { get; set; } public bool DisplayCollectionsView { get; set; }
public string[] LocalNetworkAddresses { get; set; } public string[] LocalNetworkAddresses { get; set; }
public string[] CodecsUsed { get; set; } public string[] CodecsUsed { get; set; }
public bool EnableChannelView { get; set; }
public bool EnableExternalContentInSuggestions { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ServerConfiguration" /> class. /// Initializes a new instance of the <see cref="ServerConfiguration" /> class.
@ -217,6 +219,7 @@ namespace MediaBrowser.Model.Configuration
EnableLocalizedGuids = true; EnableLocalizedGuids = true;
DisplaySpecialsWithinSeasons = true; DisplaySpecialsWithinSeasons = true;
EnableExternalContentInSuggestions = true;
ImageSavingConvention = ImageSavingConvention.Compatible; ImageSavingConvention = ImageSavingConvention.Compatible;
PublicPort = 8096; PublicPort = 8096;

View File

@ -41,7 +41,6 @@ namespace MediaBrowser.Model.Configuration
public string[] PlainFolderViews { get; set; } public string[] PlainFolderViews { get; set; }
public bool HidePlayedInLatest { get; set; } public bool HidePlayedInLatest { get; set; }
public bool EnableChannelView { get; set; }
public bool RememberAudioSelections { get; set; } public bool RememberAudioSelections { get; set; }
public bool RememberSubtitleSelections { get; set; } public bool RememberSubtitleSelections { get; set; }

View File

@ -102,14 +102,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
// new SessionAuthProvider(_containerAdapter.Resolve<ISessionContext>()), // new SessionAuthProvider(_containerAdapter.Resolve<ISessionContext>()),
//})); //}));
PreRequestFilters.Add((httpReq, httpRes) => //PreRequestFilters.Add((httpReq, httpRes) =>
{ //{
//Handles Request and closes Responses after emitting global HTTP Headers // //Handles Request and closes Responses after emitting global HTTP Headers
if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase)) // if (string.Equals(httpReq.Verb, "OPTIONS", StringComparison.OrdinalIgnoreCase))
{ // {
httpRes.EndRequest(); //add a 'using ServiceStack;' // httpRes.EndRequest(); //add a 'using ServiceStack;'
} // }
}); //});
HostContext.GlobalResponseFilters.Add(new ResponseFilter(_logger).FilterResponse); HostContext.GlobalResponseFilters.Add(new ResponseFilter(_logger).FilterResponse);
} }
@ -403,6 +403,17 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return; 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 operationName = httpReq.OperationName;
var localPath = url.LocalPath; var localPath = url.LocalPath;

View File

@ -121,7 +121,7 @@ namespace MediaBrowser.Server.Implementations.Library
var channels = channelResult.Items; 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)); list.Add(await _channelManager.GetInternalChannelFolder(cancellationToken).ConfigureAwait(false));
} }

View File

@ -346,7 +346,7 @@ namespace MediaBrowser.WebDashboard.Api
if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase)) if (string.Equals(mode, "cordova", StringComparison.OrdinalIgnoreCase))
{ {
sb.Append("<meta http-equiv=\"Content-Security-Policy\" content=\"default-src * 'unsafe-inline' 'unsafe-eval' data: filesystem:;\">"); sb.Append("<meta http-equiv=\"Content-Security-Policy\" content=\"default-src * 'unsafe-inline' 'unsafe-eval' data: gap://ready file: filesystem:;\">");
} }
sb.Append("<link rel=\"manifest\" href=\"manifest.json\">"); sb.Append("<link rel=\"manifest\" href=\"manifest.json\">");