update dlna genre views
This commit is contained in:
parent
74ec6e5a06
commit
ac2c45dd6a
|
@ -465,6 +465,16 @@ namespace Emby.Dlna.ContentDirectory
|
|||
|
||||
private async Task<QueryResult<ServerItem>> GetUserItems(BaseItem item, StubType? stubType, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||
{
|
||||
if (item is MusicGenre)
|
||||
{
|
||||
return GetMusicGenreItems(item, null, user, sort, startIndex, limit);
|
||||
}
|
||||
|
||||
if (item is MusicArtist)
|
||||
{
|
||||
return GetMusicArtistItems(item, null, user, sort, startIndex, limit);
|
||||
}
|
||||
|
||||
if (stubType.HasValue)
|
||||
{
|
||||
if (stubType.Value == StubType.People)
|
||||
|
@ -477,7 +487,7 @@ namespace Emby.Dlna.ContentDirectory
|
|||
|
||||
var result = new QueryResult<ServerItem>
|
||||
{
|
||||
Items = items.Select(i => new ServerItem { Item = i, StubType = StubType.Folder }).ToArray(),
|
||||
Items = items.Select(i => new ServerItem(i)).ToArray(),
|
||||
TotalRecordCount = items.Length
|
||||
};
|
||||
|
||||
|
@ -493,11 +503,6 @@ namespace Emby.Dlna.ContentDirectory
|
|||
return ApplyPaging(new QueryResult<ServerItem>(), startIndex, limit);
|
||||
}
|
||||
|
||||
if (item is MusicGenre)
|
||||
{
|
||||
return GetMusicGenreItems(item, null, user, sort, startIndex, limit);
|
||||
}
|
||||
|
||||
var folder = (Folder)item;
|
||||
|
||||
var query = new InternalItemsQuery
|
||||
|
@ -518,6 +523,25 @@ namespace Emby.Dlna.ContentDirectory
|
|||
return ToResult(queryResult);
|
||||
}
|
||||
|
||||
private QueryResult<ServerItem> GetMusicArtistItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||
{
|
||||
var query = new InternalItemsQuery(user)
|
||||
{
|
||||
Recursive = true,
|
||||
ParentId = parentId,
|
||||
ArtistIds = new[] { item.Id.ToString("N") },
|
||||
IncludeItemTypes = new[] { typeof(MusicAlbum).Name },
|
||||
Limit = limit,
|
||||
StartIndex = startIndex
|
||||
};
|
||||
|
||||
SetSorting(query, sort, false);
|
||||
|
||||
var result = _libraryManager.GetItemsResult(query);
|
||||
|
||||
return ToResult(result);
|
||||
}
|
||||
|
||||
private QueryResult<ServerItem> GetMusicGenreItems(BaseItem item, Guid? parentId, User user, SortCriteria sort, int? startIndex, int? limit)
|
||||
{
|
||||
var query = new InternalItemsQuery(user)
|
||||
|
@ -541,10 +565,7 @@ namespace Emby.Dlna.ContentDirectory
|
|||
{
|
||||
var serverItems = result
|
||||
.Items
|
||||
.Select(i => new ServerItem
|
||||
{
|
||||
Item = i
|
||||
})
|
||||
.Select(i => new ServerItem(i))
|
||||
.ToArray();
|
||||
|
||||
return new QueryResult<ServerItem>
|
||||
|
@ -578,11 +599,7 @@ namespace Emby.Dlna.ContentDirectory
|
|||
|
||||
});
|
||||
|
||||
var serverItems = itemsResult.Items.Select(i => new ServerItem
|
||||
{
|
||||
Item = i,
|
||||
StubType = null
|
||||
})
|
||||
var serverItems = itemsResult.Items.Select(i => new ServerItem(i))
|
||||
.ToArray();
|
||||
|
||||
return new QueryResult<ServerItem>
|
||||
|
@ -603,7 +620,7 @@ namespace Emby.Dlna.ContentDirectory
|
|||
{
|
||||
return DidlBuilder.IsIdRoot(id)
|
||||
|
||||
? new ServerItem { Item = user.RootFolder }
|
||||
? new ServerItem(user.RootFolder)
|
||||
: ParseItemId(id, user);
|
||||
}
|
||||
|
||||
|
@ -638,16 +655,15 @@ namespace Emby.Dlna.ContentDirectory
|
|||
{
|
||||
var item = _libraryManager.GetItemById(itemId);
|
||||
|
||||
return new ServerItem
|
||||
return new ServerItem(item)
|
||||
{
|
||||
Item = item,
|
||||
StubType = stubType
|
||||
};
|
||||
}
|
||||
|
||||
Logger.Error("Error parsing item Id: {0}. Returning user root folder.", id);
|
||||
|
||||
return new ServerItem { Item = user.RootFolder };
|
||||
return new ServerItem(user.RootFolder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -655,6 +671,16 @@ namespace Emby.Dlna.ContentDirectory
|
|||
{
|
||||
public BaseItem Item { get; set; }
|
||||
public StubType? StubType { get; set; }
|
||||
|
||||
public ServerItem(BaseItem item)
|
||||
{
|
||||
Item = item;
|
||||
|
||||
if (item is IItemByName && !(item is Folder))
|
||||
{
|
||||
StubType = Dlna.ContentDirectory.StubType.Folder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum StubType
|
||||
|
|
|
@ -3855,16 +3855,18 @@ namespace Emby.Server.Implementations.Data
|
|||
}
|
||||
}
|
||||
|
||||
if (query.ArtistNames.Length > 0)
|
||||
if (query.ArtistIds.Length > 0)
|
||||
{
|
||||
var clauses = new List<string>();
|
||||
var index = 0;
|
||||
foreach (var artist in query.ArtistNames)
|
||||
foreach (var artistId in query.ArtistIds)
|
||||
{
|
||||
clauses.Add("@ArtistName" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
|
||||
var paramName = "@ArtistIds" + index;
|
||||
|
||||
clauses.Add("(select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from itemvalues where ItemId=Guid and Type<=1)");
|
||||
if (statement != null)
|
||||
{
|
||||
statement.TryBind("@ArtistName" + index, GetCleanValue(artist));
|
||||
statement.TryBind(paramName, artistId.ToGuidParamValue());
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
@ -3963,23 +3965,6 @@ namespace Emby.Server.Implementations.Data
|
|||
whereClauses.Add(clause);
|
||||
}
|
||||
|
||||
if (query.Studios.Length > 0)
|
||||
{
|
||||
var clauses = new List<string>();
|
||||
var index = 0;
|
||||
foreach (var item in query.Studios)
|
||||
{
|
||||
clauses.Add("@Studio" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=3)");
|
||||
if (statement != null)
|
||||
{
|
||||
statement.TryBind("@Studio" + index, GetCleanValue(item));
|
||||
}
|
||||
index++;
|
||||
}
|
||||
var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
|
||||
whereClauses.Add(clause);
|
||||
}
|
||||
|
||||
if (query.Keywords.Length > 0)
|
||||
{
|
||||
var clauses = new List<string>();
|
||||
|
|
|
@ -209,7 +209,6 @@ namespace MediaBrowser.Api.Reports
|
|||
OfficialRatings = request.GetOfficialRatings(),
|
||||
Genres = request.GetGenres(),
|
||||
GenreIds = request.GetGenreIds(),
|
||||
Studios = request.GetStudios(),
|
||||
StudioIds = request.GetStudioIds(),
|
||||
Person = request.Person,
|
||||
PersonIds = request.GetPersonIds(),
|
||||
|
@ -314,21 +313,6 @@ namespace MediaBrowser.Api.Reports
|
|||
query.MaxParentalRating = _localization.GetRatingLevel(request.MaxOfficialRating);
|
||||
}
|
||||
|
||||
// Artists
|
||||
if (!string.IsNullOrEmpty(request.ArtistIds))
|
||||
{
|
||||
var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
|
||||
|
||||
var artistItems = artistIds.Select(_libraryManager.GetItemById).Where(i => i != null).ToList();
|
||||
query.ArtistNames = artistItems.Select(i => i.Name).ToArray();
|
||||
}
|
||||
|
||||
// Artists
|
||||
if (!string.IsNullOrEmpty(request.Artists))
|
||||
{
|
||||
query.ArtistNames = request.Artists.Split('|');
|
||||
}
|
||||
|
||||
// Albums
|
||||
if (!string.IsNullOrEmpty(request.Albums))
|
||||
{
|
||||
|
|
|
@ -124,7 +124,6 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
OfficialRatings = request.GetOfficialRatings(),
|
||||
Genres = request.GetGenres(),
|
||||
GenreIds = request.GetGenreIds(),
|
||||
Studios = request.GetStudios(),
|
||||
StudioIds = request.GetStudioIds(),
|
||||
Person = request.Person,
|
||||
PersonIds = request.GetPersonIds(),
|
||||
|
@ -145,6 +144,22 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
}
|
||||
}
|
||||
|
||||
// Studios
|
||||
if (!string.IsNullOrEmpty(request.Studios))
|
||||
{
|
||||
query.StudioIds = request.Studios.Split('|').Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return LibraryManager.GetStudio(i);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray();
|
||||
}
|
||||
|
||||
foreach (var filter in request.GetFilters())
|
||||
{
|
||||
switch (filter)
|
||||
|
|
|
@ -394,6 +394,11 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetArtistIds()
|
||||
{
|
||||
return (ArtistIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetStudioIds()
|
||||
{
|
||||
return (StudioIds ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
|
|
@ -230,8 +230,8 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
Tags = request.GetTags(),
|
||||
OfficialRatings = request.GetOfficialRatings(),
|
||||
Genres = request.GetGenres(),
|
||||
ArtistIds = request.GetArtistIds(),
|
||||
GenreIds = request.GetGenreIds(),
|
||||
Studios = request.GetStudios(),
|
||||
StudioIds = request.GetStudioIds(),
|
||||
Person = request.Person,
|
||||
PersonIds = request.GetPersonIds(),
|
||||
|
@ -338,19 +338,20 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
query.MaxParentalRating = _localization.GetRatingLevel(request.MaxOfficialRating);
|
||||
}
|
||||
|
||||
// Artists
|
||||
if (!string.IsNullOrEmpty(request.ArtistIds))
|
||||
{
|
||||
var artistIds = request.ArtistIds.Split(new[] { '|', ',' });
|
||||
|
||||
var artistItems = artistIds.Select(_libraryManager.GetItemById).Where(i => i != null).ToList();
|
||||
query.ArtistNames = artistItems.Select(i => i.Name).ToArray();
|
||||
}
|
||||
|
||||
// Artists
|
||||
if (!string.IsNullOrEmpty(request.Artists))
|
||||
{
|
||||
query.ArtistNames = request.Artists.Split('|');
|
||||
query.ArtistIds = request.Artists.Split('|').Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return _libraryManager.GetArtist(i);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray();
|
||||
}
|
||||
|
||||
// ExcludeArtistIds
|
||||
|
@ -365,6 +366,22 @@ namespace MediaBrowser.Api.UserLibrary
|
|||
query.AlbumNames = request.Albums.Split('|');
|
||||
}
|
||||
|
||||
// Studios
|
||||
if (!string.IsNullOrEmpty(request.Studios))
|
||||
{
|
||||
query.StudioIds = request.Studios.Split('|').Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return _libraryManager.GetStudio(i);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).Where(i => i != null).Select(i => i.Id.ToString("N")).ToArray();
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace MediaBrowser.Controller.Entities.Audio
|
|||
if (query.IncludeItemTypes.Length == 0)
|
||||
{
|
||||
query.IncludeItemTypes = new[] { typeof(Audio).Name, typeof(MusicVideo).Name, typeof(MusicAlbum).Name };
|
||||
query.ArtistNames = new[] { Name };
|
||||
query.ArtistIds = new[] { Id.ToString("N") };
|
||||
}
|
||||
|
||||
return LibraryManager.GetItemList(query);
|
||||
|
|
|
@ -83,7 +83,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
public bool? HasTrailer { get; set; }
|
||||
public bool? HasParentalRating { get; set; }
|
||||
|
||||
public string[] Studios { get; set; }
|
||||
public string[] StudioIds { get; set; }
|
||||
public string[] GenreIds { get; set; }
|
||||
public ImageType[] ImageTypes { get; set; }
|
||||
|
@ -144,7 +143,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
public string ExternalId { get; set; }
|
||||
|
||||
public string[] AlbumNames { get; set; }
|
||||
public string[] ArtistNames { get; set; }
|
||||
public string[] ArtistIds { get; set; }
|
||||
public string[] ExcludeArtistIds { get; set; }
|
||||
public string AncestorWithPresentationUniqueKey { get; set; }
|
||||
public string SeriesPresentationUniqueKey { get; set; }
|
||||
|
@ -203,7 +202,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
DtoOptions = new DtoOptions();
|
||||
AlbumNames = new string[] { };
|
||||
ArtistNames = new string[] { };
|
||||
ArtistIds = new string[] { };
|
||||
ExcludeArtistIds = new string[] { };
|
||||
ExcludeProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
@ -216,7 +215,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
IncludeItemTypes = new string[] { };
|
||||
ExcludeItemTypes = new string[] { };
|
||||
Genres = new string[] { };
|
||||
Studios = new string[] { };
|
||||
StudioIds = new string[] { };
|
||||
GenreIds = new string[] { };
|
||||
ImageTypes = new ImageType[] { };
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
|
||||
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
|
||||
{
|
||||
query.Studios = new[] { Name };
|
||||
query.StudioIds = new[] { Id.ToString("N") };
|
||||
|
||||
return LibraryManager.GetItemList(query);
|
||||
}
|
||||
|
|
|
@ -248,19 +248,25 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
}
|
||||
|
||||
public IEnumerable<Season> GetSeasons(User user)
|
||||
{
|
||||
var query = new InternalItemsQuery(user);
|
||||
|
||||
SetSeasonQueryOptions(query, user);
|
||||
|
||||
return LibraryManager.GetItemList(query).Cast<Season>();
|
||||
}
|
||||
|
||||
private void SetSeasonQueryOptions(InternalItemsQuery query, User user)
|
||||
{
|
||||
var config = user.Configuration;
|
||||
|
||||
var enableSeriesPresentationKey = ConfigurationManager.Configuration.EnableSeriesPresentationUniqueKey;
|
||||
var seriesKey = GetUniqueSeriesKey(this);
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
{
|
||||
AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey,
|
||||
SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null,
|
||||
IncludeItemTypes = new[] { typeof(Season).Name },
|
||||
SortBy = new[] { ItemSortBy.SortName }
|
||||
};
|
||||
query.AncestorWithPresentationUniqueKey = enableSeriesPresentationKey ? null : seriesKey;
|
||||
query.SeriesPresentationUniqueKey = enableSeriesPresentationKey ? seriesKey : null;
|
||||
query.IncludeItemTypes = new[] { typeof(Season).Name };
|
||||
query.SortBy = new[] {ItemSortBy.SortName};
|
||||
|
||||
if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
|
||||
{
|
||||
|
@ -274,8 +280,6 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
{
|
||||
query.IsVirtualUnaired = false;
|
||||
}
|
||||
|
||||
return LibraryManager.GetItemList(query).Cast<Season>();
|
||||
}
|
||||
|
||||
protected override Task<QueryResult<BaseItem>> GetItemsInternal(InternalItemsQuery query)
|
||||
|
@ -306,11 +310,9 @@ namespace MediaBrowser.Controller.Entities.TV
|
|||
return Task.FromResult(LibraryManager.GetItemsResult(query));
|
||||
}
|
||||
|
||||
Func<BaseItem, bool> filter = i => UserViewBuilder.Filter(i, user, query, UserDataManager, LibraryManager);
|
||||
SetSeasonQueryOptions(query, user);
|
||||
|
||||
var items = GetSeasons(user).Where(filter);
|
||||
var result = PostFilterAndSort(items, query, false, true);
|
||||
return Task.FromResult(result);
|
||||
return Task.FromResult(LibraryManager.GetItemsResult(query));
|
||||
}
|
||||
|
||||
public IEnumerable<Episode> GetEpisodes(User user)
|
||||
|
|
|
@ -1005,11 +1005,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
return false;
|
||||
}
|
||||
|
||||
if (request.Studios.Length > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (request.StudioIds.Length > 0)
|
||||
{
|
||||
return false;
|
||||
|
@ -1514,12 +1509,6 @@ namespace MediaBrowser.Controller.Entities
|
|||
return false;
|
||||
}
|
||||
|
||||
// Apply studio filter
|
||||
if (query.Studios.Length > 0 && !query.Studios.Any(v => item.Studios.Contains(v, StringComparer.OrdinalIgnoreCase)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Apply studio filter
|
||||
if (query.StudioIds.Length > 0 && !query.StudioIds.Any(id =>
|
||||
{
|
||||
|
@ -1733,14 +1722,14 @@ namespace MediaBrowser.Controller.Entities
|
|||
}
|
||||
|
||||
// Artists
|
||||
if (query.ArtistNames.Length > 0)
|
||||
if (query.ArtistIds.Length > 0)
|
||||
{
|
||||
var audio = item as IHasArtist;
|
||||
|
||||
if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist)))
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
|
||||
// Albums
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace MediaBrowser.Controller.Playlists
|
|||
: user.RootFolder.GetRecursiveChildren(user, new InternalItemsQuery(user)
|
||||
{
|
||||
IncludeItemTypes = new[] { typeof(Audio).Name },
|
||||
ArtistNames = new[] { musicArtist.Name }
|
||||
ArtistIds = new[] { musicArtist.Id.ToString("N") }
|
||||
});
|
||||
|
||||
return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending);
|
||||
|
|
Loading…
Reference in New Issue
Block a user