stub out tv movies in suggestions

This commit is contained in:
Luke Pulverenti 2016-05-30 14:16:44 -04:00
parent ca100ff2d1
commit f091e6f55f
2 changed files with 51 additions and 12 deletions

View File

@ -14,6 +14,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Controller.LiveTv;
namespace MediaBrowser.Api.Movies
{
@ -132,13 +133,15 @@ namespace MediaBrowser.Api.Movies
var query = new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(Movie).Name }
IncludeItemTypes = new[]
{
typeof(Movie).Name,
typeof(Trailer).Name,
//typeof(LiveTvProgram).Name
},
// IsMovie = true
};
var includeList = query.IncludeItemTypes.ToList();
includeList.Add(typeof(Trailer).Name);
query.IncludeItemTypes = includeList.ToArray();
var parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
var movies = _libraryManager.GetItemList(query, parentIds)
.OrderBy(i => (int)i.SourceType);
@ -179,16 +182,18 @@ namespace MediaBrowser.Api.Movies
var item = string.IsNullOrEmpty(request.Id) ?
(!string.IsNullOrWhiteSpace(request.UserId) ? user.RootFolder :
_libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id);
var query = new InternalItemsQuery(user)
{
IncludeItemTypes = new[] { typeof(Movie).Name }
IncludeItemTypes = new[]
{
typeof(Movie).Name,
typeof(Trailer).Name,
//typeof(LiveTvProgram).Name
},
//IsMovie = true
};
var includeList = query.IncludeItemTypes.ToList();
includeList.Add(typeof(Trailer).Name);
query.IncludeItemTypes = includeList.ToArray();
var list = _libraryManager.GetItemList(query)
.OrderBy(i => (int)i.SourceType)
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))

View File

@ -2132,7 +2132,41 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
if (query.IsMovie.HasValue)
{
whereClauses.Add("IsMovie=@IsMovie");
var alternateTypes = new List<string>();
if (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(typeof(Movie).Name))
{
alternateTypes.Add(typeof(Movie).FullName);
}
if (query.IncludeItemTypes.Length == 0 || query.IncludeItemTypes.Contains(typeof(Trailer).Name))
{
alternateTypes.Add(typeof(Trailer).FullName);
}
if (alternateTypes.Count == 0)
{
whereClauses.Add("IsMovie=@IsMovie");
}
else
{
if (query.IsMovie.Value)
{
var typeClauses = new List<string>();
var typeIndex = 0;
foreach (var type in alternateTypes)
{
var paramName = "@AlternateType" + typeIndex.ToString(CultureInfo.InvariantCulture);
typeClauses.Add("Type=" + paramName);
cmd.Parameters.Add(cmd, paramName, DbType.String).Value = type;
typeIndex++;
}
whereClauses.Add("(IsMovie=@IsMovie OR " + string.Join(" OR ", typeClauses.ToArray()) + ")");
}
else
{
whereClauses.Add("(IsMovie is null OR IsMovie=@IsMovie)");
}
}
cmd.Parameters.Add(cmd, "@IsMovie", DbType.Boolean).Value = query.IsMovie;
}
if (query.IsKids.HasValue)