stub out tv movies in suggestions
This commit is contained in:
parent
ca100ff2d1
commit
f091e6f55f
|
@ -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.LiveTv;
|
||||||
|
|
||||||
namespace MediaBrowser.Api.Movies
|
namespace MediaBrowser.Api.Movies
|
||||||
{
|
{
|
||||||
|
@ -132,13 +133,15 @@ namespace MediaBrowser.Api.Movies
|
||||||
|
|
||||||
var query = new InternalItemsQuery(user)
|
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 parentIds = string.IsNullOrWhiteSpace(request.ParentId) ? new string[] { } : new[] { request.ParentId };
|
||||||
var movies = _libraryManager.GetItemList(query, parentIds)
|
var movies = _libraryManager.GetItemList(query, parentIds)
|
||||||
.OrderBy(i => (int)i.SourceType);
|
.OrderBy(i => (int)i.SourceType);
|
||||||
|
@ -179,16 +182,18 @@ namespace MediaBrowser.Api.Movies
|
||||||
var item = string.IsNullOrEmpty(request.Id) ?
|
var item = string.IsNullOrEmpty(request.Id) ?
|
||||||
(!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 query = new InternalItemsQuery(user)
|
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)
|
var list = _libraryManager.GetItemList(query)
|
||||||
.OrderBy(i => (int)i.SourceType)
|
.OrderBy(i => (int)i.SourceType)
|
||||||
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
|
.DistinctBy(i => i.GetProviderId(MetadataProviders.Imdb) ?? Guid.NewGuid().ToString("N"))
|
||||||
|
|
|
@ -2132,7 +2132,41 @@ namespace MediaBrowser.Server.Implementations.Persistence
|
||||||
}
|
}
|
||||||
if (query.IsMovie.HasValue)
|
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;
|
cmd.Parameters.Add(cmd, "@IsMovie", DbType.Boolean).Value = query.IsMovie;
|
||||||
}
|
}
|
||||||
if (query.IsKids.HasValue)
|
if (query.IsKids.HasValue)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user