Merge branch 'beta' of https://github.com/MediaBrowser/Emby into beta

This commit is contained in:
Luke Pulverenti 2016-02-14 13:02:41 -05:00
commit 86c68d7e2a
5 changed files with 31 additions and 8 deletions

View File

@ -27,6 +27,7 @@ namespace MediaBrowser.Controller.Entities
public bool? IsLiked { get; set; } public bool? IsLiked { get; set; }
public bool? IsPlayed { get; set; } public bool? IsPlayed { get; set; }
public bool? IsResumable { get; set; } public bool? IsResumable { get; set; }
public bool? IncludeItemsByName { get; set; }
public string[] MediaTypes { get; set; } public string[] MediaTypes { get; set; }
public string[] IncludeItemTypes { get; set; } public string[] IncludeItemTypes { get; set; }

View File

@ -1324,7 +1324,7 @@ namespace MediaBrowser.Server.Implementations.Library
SetTopParentIdsOrAncestors(query, parents); SetTopParentIdsOrAncestors(query, parents);
return GetItemIds(query).Select(GetItemById); return GetItemIds(query).Select(GetItemById).Where(i => i != null);
} }
public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query, IEnumerable<string> parentIds) public QueryResult<BaseItem> GetItemsResult(InternalItemsQuery query, IEnumerable<string> parentIds)

View File

@ -163,6 +163,7 @@ namespace MediaBrowser.Server.Implementations.Library
ExcludeItemTypes = excludeItemTypes.ToArray(), ExcludeItemTypes = excludeItemTypes.ToArray(),
IncludeItemTypes = includeItemTypes.ToArray(), IncludeItemTypes = includeItemTypes.ToArray(),
Limit = query.Limit, Limit = query.Limit,
IncludeItemsByName = true
}, new string[] { }); }, new string[] { });

View File

@ -300,6 +300,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
public async Task<ILiveTvRecording> GetInternalRecording(string id, CancellationToken cancellationToken) public async Task<ILiveTvRecording> GetInternalRecording(string id, CancellationToken cancellationToken)
{ {
if (string.IsNullOrWhiteSpace(id))
{
throw new ArgumentNullException("id");
}
var result = await GetInternalRecordings(new RecordingQuery var result = await GetInternalRecordings(new RecordingQuery
{ {
Id = id Id = id
@ -1410,7 +1415,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var queryResult = _libraryManager.GetItems(internalQuery, new string[] { }); var queryResult = _libraryManager.GetItems(internalQuery, new string[] { });
IEnumerable<ILiveTvRecording> recordings = queryResult.Cast<ILiveTvRecording>(); IEnumerable<ILiveTvRecording> recordings = queryResult.Cast<ILiveTvRecording>();
if (!string.IsNullOrEmpty(query.Id)) if (!string.IsNullOrWhiteSpace(query.Id))
{ {
var guid = new Guid(query.Id); var guid = new Guid(query.Id);
@ -1418,7 +1423,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
.Where(i => i.Id == guid); .Where(i => i.Id == guid);
} }
if (!string.IsNullOrEmpty(query.GroupId)) if (!string.IsNullOrWhiteSpace(query.GroupId))
{ {
var guid = new Guid(query.GroupId); var guid = new Guid(query.GroupId);

View File

@ -1914,19 +1914,35 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add("LocationType not in (" + val + ")"); whereClauses.Add("LocationType not in (" + val + ")");
} }
var enableItemsByName = query.IncludeItemsByName ?? query.IncludeItemTypes.Length > 0;
if (query.TopParentIds.Length == 1) if (query.TopParentIds.Length == 1)
{
if (enableItemsByName)
{ {
whereClauses.Add("(TopParentId=@TopParentId or IsItemByName=@IsItemByName)"); whereClauses.Add("(TopParentId=@TopParentId or IsItemByName=@IsItemByName)");
cmd.Parameters.Add(cmd, "@TopParentId", DbType.String).Value = query.TopParentIds[0];
cmd.Parameters.Add(cmd, "@IsItemByName", DbType.Boolean).Value = true; cmd.Parameters.Add(cmd, "@IsItemByName", DbType.Boolean).Value = true;
} }
else
{
whereClauses.Add("(TopParentId=@TopParentId)");
}
cmd.Parameters.Add(cmd, "@TopParentId", DbType.String).Value = query.TopParentIds[0];
}
if (query.TopParentIds.Length > 1) if (query.TopParentIds.Length > 1)
{ {
var val = string.Join(",", query.TopParentIds.Select(i => "'" + i + "'").ToArray()); var val = string.Join(",", query.TopParentIds.Select(i => "'" + i + "'").ToArray());
if (enableItemsByName)
{
whereClauses.Add("(IsItemByName=@IsItemByName or TopParentId in (" + val + "))"); whereClauses.Add("(IsItemByName=@IsItemByName or TopParentId in (" + val + "))");
cmd.Parameters.Add(cmd, "@IsItemByName", DbType.Boolean).Value = true; cmd.Parameters.Add(cmd, "@IsItemByName", DbType.Boolean).Value = true;
} }
else
{
whereClauses.Add("(TopParentId in (" + val + "))");
}
}
if (query.AncestorIds.Length == 1) if (query.AncestorIds.Length == 1)
{ {