mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-08 04:18:06 +02:00
stub out tv movies in suggestions
This commit is contained in:
parent
ca100ff2d1
commit
f091e6f55f
2 changed files with 51 additions and 12 deletions
|
@ -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);
|
||||||
|
@ -182,13 +185,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 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 a new issue