diff options
| author | Luis Miguel Almánzar <ruisu15@gmail.com> | 2013-08-30 22:05:43 -0400 |
|---|---|---|
| committer | Luis Miguel Almánzar <ruisu15@gmail.com> | 2013-08-30 22:05:43 -0400 |
| commit | 744867d1c6e0f352276d8fdd8af241ff88c03494 (patch) | |
| tree | 085ac433d16fa859f97d7c0c6ae4f42c52f9b0d6 /MediaBrowser.Controller | |
| parent | 3f4dd4231d2225ab0d474840038a4de01b5f7391 (diff) | |
| parent | ae53683d08bc279040b7945c0ea269ff4b9a60e0 (diff) | |
Merge branch 'master' of github.com:MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Dto/DtoBuilder.cs | 174 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Book.cs | 35 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Series.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 1 |
5 files changed, 68 insertions, 154 deletions
diff --git a/MediaBrowser.Controller/Dto/DtoBuilder.cs b/MediaBrowser.Controller/Dto/DtoBuilder.cs index b2b858b6d..f762c7cc6 100644 --- a/MediaBrowser.Controller/Dto/DtoBuilder.cs +++ b/MediaBrowser.Controller/Dto/DtoBuilder.cs @@ -104,35 +104,11 @@ namespace MediaBrowser.Controller.Dto if (fields.Contains(ItemFields.SoundtrackIds)) { - var series = item as Series; - - if (series != null) - { - AttachSoundtrackIds(dto, series, user); - } - - var movie = item as Movie; - - if (movie != null) - { - AttachSoundtrackIds(dto, movie, user); - } - - var album = item as MusicAlbum; - - if (album != null) - { - AttachSoundtrackIds(dto, album, user); - } - - var game = item as Game; - - if (game != null) - { - AttachSoundtrackIds(dto, game, user); - } + dto.SoundtrackIds = item.SoundtrackIds + .Select(i => i.ToString("N")) + .ToArray(); } - + // Make sure all the tasks we kicked off have completed. if (tasks.Count > 0) { @@ -142,132 +118,6 @@ namespace MediaBrowser.Controller.Dto return dto; } - private void AttachSoundtrackIds(BaseItemDto dto, Movie item, User user) - { - var tmdb = item.GetProviderId(MetadataProviders.Tmdb); - - if (string.IsNullOrEmpty(tmdb)) - { - return; - } - - var recursiveChildren = user == null - ? _libraryManager.RootFolder.RecursiveChildren - : user.RootFolder.GetRecursiveChildren(user); - - dto.SoundtrackIds = recursiveChildren - .Where(i => - { - if (!string.IsNullOrEmpty(tmdb) && - string.Equals(tmdb, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase) && - i is MusicAlbum) - { - return true; - } - return false; - }) - .Select(GetClientItemId) - .ToArray(); - } - - private void AttachSoundtrackIds(BaseItemDto dto, Series item, User user) - { - var tvdb = item.GetProviderId(MetadataProviders.Tvdb); - - if (string.IsNullOrEmpty(tvdb)) - { - return; - } - - var recursiveChildren = user == null - ? _libraryManager.RootFolder.RecursiveChildren - : user.RootFolder.GetRecursiveChildren(user); - - dto.SoundtrackIds = recursiveChildren - .Where(i => - { - if (!string.IsNullOrEmpty(tvdb) && - string.Equals(tvdb, i.GetProviderId(MetadataProviders.Tvdb), StringComparison.OrdinalIgnoreCase) && - i is MusicAlbum) - { - return true; - } - return false; - }) - .Select(GetClientItemId) - .ToArray(); - } - - private void AttachSoundtrackIds(BaseItemDto dto, Game item, User user) - { - var gamesdb = item.GetProviderId(MetadataProviders.Gamesdb); - - if (string.IsNullOrEmpty(gamesdb)) - { - return; - } - - var recursiveChildren = user == null - ? _libraryManager.RootFolder.RecursiveChildren - : user.RootFolder.GetRecursiveChildren(user); - - dto.SoundtrackIds = recursiveChildren - .Where(i => - { - if (!string.IsNullOrEmpty(gamesdb) && - string.Equals(gamesdb, i.GetProviderId(MetadataProviders.Gamesdb), StringComparison.OrdinalIgnoreCase) && - i is MusicAlbum) - { - return true; - } - return false; - }) - .Select(GetClientItemId) - .ToArray(); - } - - private void AttachSoundtrackIds(BaseItemDto dto, MusicAlbum item, User user) - { - var tmdb = item.GetProviderId(MetadataProviders.Tmdb); - var tvdb = item.GetProviderId(MetadataProviders.Tvdb); - var gamesdb = item.GetProviderId(MetadataProviders.Gamesdb); - - if (string.IsNullOrEmpty(tmdb) && string.IsNullOrEmpty(tvdb) && string.IsNullOrEmpty(gamesdb)) - { - return; - } - - var recursiveChildren = user == null - ? _libraryManager.RootFolder.RecursiveChildren - : user.RootFolder.GetRecursiveChildren(user); - - dto.SoundtrackIds = recursiveChildren - .Where(i => - { - if (!string.IsNullOrEmpty(tmdb) && - string.Equals(tmdb, i.GetProviderId(MetadataProviders.Tmdb), StringComparison.OrdinalIgnoreCase) && - i is Movie) - { - return true; - } - if (!string.IsNullOrEmpty(tvdb) && - string.Equals(tvdb, i.GetProviderId(MetadataProviders.Tvdb), StringComparison.OrdinalIgnoreCase) && - i is Series) - { - return true; - } - if (!string.IsNullOrEmpty(gamesdb) && - string.Equals(gamesdb, i.GetProviderId(MetadataProviders.Gamesdb), StringComparison.OrdinalIgnoreCase) && - i is Game) - { - return true; - } - return false; - }) - .Select(GetClientItemId) - .ToArray(); - } - /// <summary> /// Attaches the user specific info. /// </summary> @@ -682,6 +532,10 @@ namespace MediaBrowser.Controller.Dto dto.AirDays = series.AirDays; dto.AirTime = series.AirTime; dto.Status = series.Status; + + dto.SpecialFeatureCount = series.SpecialFeatureIds.Count; + + dto.SeasonCount = series.SeasonCount; } if (episode != null) @@ -716,6 +570,18 @@ namespace MediaBrowser.Controller.Dto { SetMusicVideoProperties(dto, musicVideo); } + + var book = item as Book; + + if (book != null) + { + SetBookProperties(dto, book); + } + } + + private void SetBookProperties(BaseItemDto dto, Book item) + { + dto.SeriesName = item.SeriesName; } private void SetMusicVideoProperties(BaseItemDto dto, MusicVideo item) diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 3c8c2411e..e756d2211 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -23,6 +23,11 @@ namespace MediaBrowser.Controller.Entities /// </summary> public abstract class BaseItem : IHasProviderIds { + /// <summary> + /// MusicAlbums in the library that are the soundtrack for this item + /// </summary> + public List<Guid> SoundtrackIds { get; set; } + protected BaseItem() { Genres = new List<string>(); @@ -38,6 +43,7 @@ namespace MediaBrowser.Controller.Entities Tags = new List<string>(); ThemeSongIds = new List<Guid>(); ThemeVideoIds = new List<Guid>(); + SoundtrackIds = new List<Guid>(); LocalTrailerIds = new List<Guid>(); LockedFields = new List<MetadataFields>(); } diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs new file mode 100644 index 000000000..20df731a7 --- /dev/null +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -0,0 +1,35 @@ + +namespace MediaBrowser.Controller.Entities +{ + public class Book : BaseItem + { + public override string MediaType + { + get + { + return Model.Entities.MediaType.Book; + } + } + + public string SeriesName { get; set; } + + /// <summary> + /// + /// </summary> + public override string MetaLocation + { + get + { + return System.IO.Path.GetDirectoryName(Path); + } + } + + protected override bool UseParentPathToCreateResolveArgs + { + get + { + return !IsInMixedFolder; + } + } + } +} diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 2458e5619..1e4d56e1a 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -13,9 +13,15 @@ namespace MediaBrowser.Controller.Entities.TV /// </summary> public class Series : Folder { + public List<Guid> SpecialFeatureIds { get; set; } + + public int SeasonCount { get; set; } + public Series() { AirDays = new List<DayOfWeek>(); + + SpecialFeatureIds = new List<Guid>(); } /// <summary> diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index bbc73d0ad..e0e8b78e1 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -72,6 +72,7 @@ <Link>Properties\SharedVersion.cs</Link> </Compile> <Compile Include="Entities\AdultVideo.cs" /> + <Compile Include="Entities\Book.cs" /> <Compile Include="Notifications\Configuration\IServerConfigurationManager.cs" /> <Compile Include="Dto\SessionInfoDtoBuilder.cs" /> <Compile Include="Entities\Audio\MusicAlbumDisc.cs" /> |
