diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-11-13 14:35:00 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-11-13 14:35:00 -0500 |
| commit | 9bb1bf69a5fb1722d69503d8ed2dc263c959aaac (patch) | |
| tree | cdec458a1ade48a8446c8e72c5aec5eeb0772d4d /MediaBrowser.Api/LibraryService.cs | |
| parent | d60fca112b0b120936b3cbbd72bfed273a4eb319 (diff) | |
fixes #624 - Allow soundtracks to inherit theme video/songs from linked movies, series & games
Diffstat (limited to 'MediaBrowser.Api/LibraryService.cs')
| -rw-r--r-- | MediaBrowser.Api/LibraryService.cs | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index f03d79795..2e9ea6ceb 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -595,6 +595,8 @@ namespace MediaBrowser.Api : (Folder)_libraryManager.RootFolder) : _dtoService.GetItemByDtoId(request.Id, request.UserId); + var originalItem = item; + while (item.ThemeSongIds.Count == 0 && request.InheritFromParent && item.Parent != null) { item = item.Parent; @@ -605,7 +607,21 @@ namespace MediaBrowser.Api .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) .ToList(); - var dtos = item.ThemeSongIds.Select(_libraryManager.GetItemById) + var themeSongIds = item.ThemeSongIds; + + if (themeSongIds.Count == 0 && request.InheritFromParent) + { + var album = originalItem as MusicAlbum; + + if (album != null) + { + themeSongIds = album.SoundtrackIds + .SelectMany(i => _libraryManager.GetItemById(i).ThemeSongIds) + .ToList(); + } + } + + var dtos = themeSongIds.Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); @@ -641,6 +657,8 @@ namespace MediaBrowser.Api : (Folder)_libraryManager.RootFolder) : _dtoService.GetItemByDtoId(request.Id, request.UserId); + var originalItem = item; + while (item.ThemeVideoIds.Count == 0 && request.InheritFromParent && item.Parent != null) { item = item.Parent; @@ -651,7 +669,21 @@ namespace MediaBrowser.Api .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) .ToList(); - var dtos = item.ThemeVideoIds.Select(_libraryManager.GetItemById) + var themeVideoIds = item.ThemeVideoIds; + + if (themeVideoIds.Count == 0 && request.InheritFromParent) + { + var album = originalItem as MusicAlbum; + + if (album != null) + { + themeVideoIds = album.SoundtrackIds + .SelectMany(i => _libraryManager.GetItemById(i).ThemeVideoIds) + .ToList(); + } + } + + var dtos = themeVideoIds.Select(_libraryManager.GetItemById) .OrderBy(i => i.SortName) .Select(i => _dtoService.GetBaseItemDto(i, fields, user, item)); |
