diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 2cca63217..6f6f124db 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -17,7 +17,12 @@ namespace MediaBrowser.Controller.Entities.Audio /// public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasProductionLocations, IHasLookupInfo { - public bool IsAccessedByName { get; set; } + [IgnoreDataMember] + public bool IsAccessedByName + { + get { return ParentId == Guid.Empty; } + } + public List ProductionLocations { get; set; } [IgnoreDataMember] @@ -40,6 +45,20 @@ namespace MediaBrowser.Controller.Entities.Audio return !IsAccessedByName; } + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + var itemByNameFilter = GetItemFilter(); + + if (query.User != null) + { + return query.User.RootFolder + .GetRecursiveChildren(query.User, i => !i.IsFolder && itemByNameFilter(i)); + } + + return LibraryManager.RootFolder + .GetRecursiveChildren(i => !i.IsFolder && itemByNameFilter(i)); + } + protected override IEnumerable ActualChildren { get diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 4d041264c..05870176e 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -79,5 +79,13 @@ namespace MediaBrowser.Controller.Entities.Audio return false; } } + + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + query.Genres = new[] { Name }; + query.ExcludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name }; + + return LibraryManager.GetItemList(query); + } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 71028d4cf..7c1e88cb1 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -62,6 +62,14 @@ namespace MediaBrowser.Controller.Entities return i => i is Game && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + query.Genres = new[] { Name }; + query.IncludeItemTypes = new[] { typeof(Game).Name }; + + return LibraryManager.GetItemList(query); + } + [IgnoreDataMember] public override bool SupportsPeople { diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index fa890ad9e..c87d4daaf 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -66,6 +66,14 @@ namespace MediaBrowser.Controller.Entities return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); } + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + query.Genres = new[] { Name }; + query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name }; + + return LibraryManager.GetItemList(query); + } + [IgnoreDataMember] public override bool SupportsPeople { diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index e6667290c..7747e738c 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -20,6 +20,8 @@ namespace MediaBrowser.Controller.Entities /// /// Func<BaseItem, System.Boolean>. Func GetItemFilter(); + + IEnumerable GetTaggedItems(InternalItemsQuery query); } public interface IHasDualAccess : IItemByName diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 2615f351a..385ee81e9 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -134,6 +134,7 @@ namespace MediaBrowser.Controller.Entities public string[] AlbumNames { get; set; } public string[] ArtistNames { get; set; } + public string AncestorWithPresentationUniqueKey { get; set; } public bool GroupByPresentationUniqueKey { get; set; } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 89581e967..2b099e3d5 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -31,6 +31,13 @@ namespace MediaBrowser.Controller.Entities return GetItemLookupInfo(); } + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + query.Person = Name; + + return LibraryManager.GetItemList(query); + } + /// /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself diff --git a/MediaBrowser.Controller/Entities/PhotoAlbum.cs b/MediaBrowser.Controller/Entities/PhotoAlbum.cs index c8ab67a69..b0ddcfb8c 100644 --- a/MediaBrowser.Controller/Entities/PhotoAlbum.cs +++ b/MediaBrowser.Controller/Entities/PhotoAlbum.cs @@ -7,15 +7,6 @@ namespace MediaBrowser.Controller.Entities { public class PhotoAlbum : Folder { - [IgnoreDataMember] - public override bool SupportsLocalMetadata - { - get - { - return false; - } - } - [IgnoreDataMember] public override bool AlwaysScanInternalMetadataPath { diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 7ceefbc6e..48ca7bbcc 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -65,6 +65,13 @@ namespace MediaBrowser.Controller.Entities return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase); } + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + query.Studios = new[] { Name }; + + return LibraryManager.GetItemList(query); + } + [IgnoreDataMember] public override bool SupportsPeople { diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index abca6a643..a70bac6db 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -9,6 +9,7 @@ using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; +using MoreLinq; namespace MediaBrowser.Controller.Entities.TV { @@ -180,7 +181,7 @@ namespace MediaBrowser.Controller.Entities.TV else { items = query.Recursive - ? GetRecursiveChildren(user, filter) + ? GetSeasons(user).Cast().Concat(GetEpisodes(user)).Where(filter) : GetSeasons(user).Where(filter); } @@ -211,7 +212,7 @@ namespace MediaBrowser.Controller.Entities.TV } else { - seasons = base.GetChildren(user, true).OfType(); + seasons = LibraryManager.Sort(base.GetChildren(user, true), user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).OfType(); } if (!includeMissingSeasons && !includeVirtualUnaired) @@ -250,17 +251,8 @@ namespace MediaBrowser.Controller.Entities.TV // Specials could appear twice based on above - once in season 0, once in the aired season // This depends on settings for that series // When this happens, remove the duplicate from season 0 - var returnList = new List(); - foreach (var episode in allEpisodes) - { - if (!returnList.Contains(episode)) - { - returnList.Insert(0, episode); - } - } - - return returnList; + return allEpisodes.DistinctBy(i => i.Id).Reverse(); } public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress progress, CancellationToken cancellationToken) diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index f27ce79dd..db896f1fc 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -70,6 +70,22 @@ namespace MediaBrowser.Controller.Entities return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year); } + public IEnumerable GetTaggedItems(InternalItemsQuery query) + { + int year; + + var usCulture = new CultureInfo("en-US"); + + if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year)) + { + return new List(); + } + + query.Years = new[] { year }; + + return LibraryManager.GetItemList(query); + } + public int? GetYearValue() { int i; diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 750dea361..cd0c5dc1c 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -99,11 +99,12 @@ namespace MediaBrowser.Controller.Playlists var musicGenre = item as MusicGenre; if (musicGenre != null) { - Func filter = i => i is Audio && i.Genres.Contains(musicGenre.Name, StringComparer.OrdinalIgnoreCase); - - var items = user == null - ? LibraryManager.RootFolder.GetRecursiveChildren(filter) - : user.RootFolder.GetRecursiveChildren(user, filter); + var items = LibraryManager.GetItemList(new InternalItemsQuery(user) + { + Recursive = true, + IncludeItemTypes = new[] { typeof(Audio).Name }, + Genres = new[] { musicGenre.Name } + }); return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); } diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 54fdc6400..ba4d1b59e 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -662,9 +662,6 @@ FileOrganization\TvFileOrganizationOptions.cs - - Games\GameSystem.cs - Globalization\CountryInfo.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 473186a46..f5d538cc4 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -636,9 +636,6 @@ FileOrganization\TvFileOrganizationOptions.cs - - Games\GameSystem.cs - Globalization\CountryInfo.cs diff --git a/MediaBrowser.Model/Games/GameSystem.cs b/MediaBrowser.Model/Games/GameSystem.cs deleted file mode 100644 index ab8f1efa7..000000000 --- a/MediaBrowser.Model/Games/GameSystem.cs +++ /dev/null @@ -1,48 +0,0 @@ - -namespace MediaBrowser.Model.Games -{ - public class GameSystem - { - public const string Nintendo = "Nintendo"; - public const string SuperNintendo = "Super Nintendo"; - public const string Panasonic3DO = "3DO"; - public const string Amiga = "Amiga"; - public const string Arcade = "Arcade"; - public const string Atari2600 = "Atari 2600"; - public const string Atari5200 = "Atari 5200"; - public const string Atari7800 = "Atari 7800"; - public const string AtariXE = "Atari XE"; - public const string AtariJaguar = "Atari Jaguar"; - public const string AtariJaguarCD = "Atari Jaguar CD"; - public const string Colecovision = "Colecovision"; - public const string Commodore64 = "Commodore 64"; - public const string CommodoreVic20 = "Commodore Vic-20"; - public const string Intellivision = "Intellivision"; - public const string MicrosoftXBox = "Xbox"; - public const string NeoGeo = "Neo Geo"; - public const string Nintendo64 = "Nintendo 64"; - public const string NintendoDS = "Nintendo DS"; - public const string NintendoGameBoy = "Game Boy"; - public const string NintendoGameBoyAdvance = "Game Boy Advance"; - public const string NintendoGameBoyColor = "Game Boy Color"; - public const string NintendoGameCube = "Gamecube"; - public const string VirtualBoy = "Virtual Boy"; - public const string Wii = "Nintendo Wii"; - public const string DOS = "DOS"; - public const string Windows = "Windows"; - public const string Sega32X = "Sega 32X"; - public const string SegaCD = "Sega CD"; - public const string SegaDreamcast = "Dreamcast"; - public const string SegaGameGear = "Game Gear"; - public const string SegaGenesis = "Sega Genesis"; - public const string SegaMasterSystem = "Sega Master System"; - public const string SegaMegaDrive = "Sega Mega Drive"; - public const string SegaSaturn = "Sega Saturn"; - public const string SonyPlaystation = "Sony Playstation"; - public const string SonyPlaystation2 = "PS2"; - public const string SonyPSP = "PSP"; - public const string TurboGrafx16 = "TurboGrafx 16"; - public const string TurboGrafxCD = "TurboGrafx CD"; - public const string ZxSpectrum = "ZX Spectrum"; - } -} diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 41952963c..7c469b9fb 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -287,7 +287,6 @@ - diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index 95d47b380..b6a33afe4 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -961,7 +961,7 @@ namespace MediaBrowser.Server.Implementations.Library Name = name }).Cast() - .Where(i => !i.IsAccessedByName) + .OrderBy(i => i.IsAccessedByName ? 1 : 0) .Cast() .FirstOrDefault(); @@ -984,11 +984,6 @@ namespace MediaBrowser.Server.Implementations.Library Path = path }; - if (isArtist) - { - (item as MusicArtist).IsAccessedByName = true; - } - var task = CreateItem(item, CancellationToken.None); Task.WaitAll(task); } @@ -2574,8 +2569,8 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentNullException("name"); } - name = _fileSystem.GetValidFilename(name); - + name = _fileSystem.GetValidFilename(name); + var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; var virtualFolderPath = Path.Combine(rootFolderPath, name); diff --git a/MediaBrowser.Server.Implementations/Library/MusicManager.cs b/MediaBrowser.Server.Implementations/Library/MusicManager.cs index aad7c112b..c82c4cdf7 100644 --- a/MediaBrowser.Server.Implementations/Library/MusicManager.cs +++ b/MediaBrowser.Server.Implementations/Library/MusicManager.cs @@ -55,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.Library public IEnumerable