update db querying

This commit is contained in:
Luke Pulverenti
2016-03-21 12:50:50 -04:00
parent dfafa98da3
commit 23fe6dc4be
5 changed files with 89 additions and 102 deletions

View File

@@ -1175,6 +1175,18 @@ namespace MediaBrowser.Controller.Entities
return true;
}
if (query.AlbumNames.Length > 0)
{
Logger.Debug("Query requires post-filtering due to AlbumNames");
return true;
}
if (query.ArtistNames.Length > 0)
{
Logger.Debug("Query requires post-filtering due to ArtistNames");
return true;
}
return false;
}

View File

@@ -128,8 +128,14 @@ namespace MediaBrowser.Controller.Entities
public SeriesStatus[] SeriesStatuses { get; set; }
public string AlbumArtistStartsWithOrGreater { get; set; }
public string[] AlbumNames { get; set; }
public string[] ArtistNames { get; set; }
public InternalItemsQuery()
{
AlbumNames = new string[] { };
ArtistNames = new string[] { };
BlockUnratedItems = new UnratedItem[] { };
Tags = new string[] { };
OfficialRatings = new string[] { };

View File

@@ -1768,6 +1768,53 @@ namespace MediaBrowser.Controller.Entities
}
}
// Artists
if (query.ArtistNames.Length > 0)
{
var audio = item as IHasArtist;
if (!(audio != null && query.ArtistNames.Any(audio.HasAnyArtist)))
{
return false;
}
}
// Albums
if (query.AlbumNames.Length > 0)
{
var audio = item as Audio.Audio;
if (audio != null)
{
if (!query.AlbumNames.Any(a => string.Equals(a, audio.Album, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
}
var album = item as MusicAlbum;
if (album != null)
{
if (!query.AlbumNames.Any(a => string.Equals(a, album.Name, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
}
var musicVideo = item as MusicVideo;
if (musicVideo != null)
{
if (!query.AlbumNames.Any(a => string.Equals(a, musicVideo.Album, StringComparison.OrdinalIgnoreCase)))
{
return false;
}
}
return false;
}
return true;
}