aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Dto/DtoService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Emby.Server.Implementations/Dto/DtoService.cs')
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs63
1 files changed, 30 insertions, 33 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 0b66a8e1f..ec4f552a6 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -751,45 +751,41 @@ namespace Emby.Server.Implementations.Dto
/// <returns>Task.</returns>
private void AttachStudios(BaseItemDto dto, BaseItem item)
{
- var studios = item.Studios.ToList();
-
- dto.Studios = new StudioDto[studios.Count];
-
- var dictionary = studios.Distinct(StringComparer.OrdinalIgnoreCase).Select(name =>
- {
- try
- {
- return _libraryManager.GetStudio(name);
- }
- catch (IOException ex)
+ dto.Studios = item.Studios
+ .Where(i => !string.IsNullOrWhiteSpace(i))
+ .Select(i => new NameIdPair
{
- _logger.ErrorException("Error getting studio {0}", ex, name);
- return null;
- }
- })
- .Where(i => i != null)
- .DistinctBy(i => i.Name, StringComparer.OrdinalIgnoreCase)
- .ToDictionary(i => i.Name, StringComparer.OrdinalIgnoreCase);
-
- for (var i = 0; i < studios.Count; i++)
- {
- var studio = studios[i];
+ Name = i,
+ Id = _libraryManager.GetStudioId(i).ToString("N")
+ })
+ .ToArray();
+ }
- var studioDto = new StudioDto
+ private void AttachGenreItems(BaseItemDto dto, BaseItem item)
+ {
+ dto.GenreItems = item.Genres
+ .Where(i => !string.IsNullOrWhiteSpace(i))
+ .Select(i => new NameIdPair
{
- Name = studio
- };
-
- Studio entity;
+ Name = i,
+ Id = GetStudioId(i, item)
+ })
+ .ToArray();
+ }
- if (dictionary.TryGetValue(studio, out entity))
- {
- studioDto.Id = entity.Id.ToString("N");
- studioDto.PrimaryImageTag = GetImageCacheTag(entity, ImageType.Primary);
- }
+ private string GetStudioId(string name, BaseItem owner)
+ {
+ if (owner is IHasMusicGenres)
+ {
+ return _libraryManager.GetGameGenreId(name).ToString("N");
+ }
- dto.Studios[i] = studioDto;
+ if (owner is Game || owner is GameSystem)
+ {
+ return _libraryManager.GetGameGenreId(name).ToString("N");
}
+
+ return _libraryManager.GetGenreId(name).ToString("N");
}
/// <summary>
@@ -901,6 +897,7 @@ namespace Emby.Server.Implementations.Dto
if (fields.Contains(ItemFields.Genres))
{
dto.Genres = item.Genres;
+ AttachGenreItems(dto, item);
}
if (options.EnableImages)