aboutsummaryrefslogtreecommitdiff
path: root/Emby.Server.Implementations/Dto
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2017-08-13 16:21:10 -0400
committerGitHub <noreply@github.com>2017-08-13 16:21:10 -0400
commitdc578f3742b474bd85d556299a6b2763f4d9acda (patch)
treecc4a8d1de140ece77160349e51a64857656ab373 /Emby.Server.Implementations/Dto
parentf6ed934a7e32bf10c3a141773d713bf3b19e784f (diff)
parent7f200f057d33e3ef52b1b1b1bf1767577295317e (diff)
Merge pull request #2815 from MediaBrowser/beta
Beta
Diffstat (limited to 'Emby.Server.Implementations/Dto')
-rw-r--r--Emby.Server.Implementations/Dto/DtoService.cs95
1 files changed, 27 insertions, 68 deletions
diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs
index 2933a9f22e..e1d0a1858f 100644
--- a/Emby.Server.Implementations/Dto/DtoService.cs
+++ b/Emby.Server.Implementations/Dto/DtoService.cs
@@ -359,11 +359,11 @@ namespace Emby.Server.Implementations.Dto
{
if (user == null)
{
- dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true).ToList();
+ dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true);
}
else
{
- dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user).ToList();
+ dto.MediaSources = _mediaSourceManager().GetStaticMediaSources(hasMediaSources, true, user);
}
}
}
@@ -517,7 +517,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- if (!(item is LiveTvProgram) || fields.Contains(ItemFields.PlayAccess))
+ if (/*!(item is LiveTvProgram) ||*/ fields.Contains(ItemFields.PlayAccess))
{
dto.PlayAccess = item.GetPlayAccess(user);
}
@@ -639,7 +639,6 @@ namespace Emby.Server.Implementations.Dto
private void SetGameProperties(BaseItemDto dto, Game item)
{
- dto.Players = item.PlayersSupported;
dto.GameSystem = item.GameSystem;
dto.MultiPartGameFiles = item.MultiPartGameFiles;
}
@@ -649,12 +648,12 @@ namespace Emby.Server.Implementations.Dto
dto.GameSystem = item.GameSystemName;
}
- private List<string> GetImageTags(BaseItem item, List<ItemImageInfo> images)
+ private string[] GetImageTags(BaseItem item, List<ItemImageInfo> images)
{
return images
.Select(p => GetImageCacheTag(item, p))
.Where(i => i != null)
- .ToList();
+ .ToArray();
}
private string GetImageCacheTag(BaseItem item, ImageType type)
@@ -766,7 +765,7 @@ namespace Emby.Server.Implementations.Dto
}
}
- dto.People = list.ToArray();
+ dto.People = list.ToArray(list.Count);
}
/// <summary>
@@ -864,11 +863,6 @@ namespace Emby.Server.Implementations.Dto
dto.DateCreated = item.DateCreated;
}
- if (fields.Contains(ItemFields.DisplayMediaType))
- {
- dto.DisplayMediaType = item.DisplayMediaType;
- }
-
if (fields.Contains(ItemFields.Settings))
{
dto.LockedFields = item.LockedFields;
@@ -894,11 +888,6 @@ namespace Emby.Server.Implementations.Dto
dto.Tags = item.Tags;
}
- if (fields.Contains(ItemFields.Keywords))
- {
- dto.Keywords = item.Keywords;
- }
-
var hasAspectRatio = item as IHasAspectRatio;
if (hasAspectRatio != null)
{
@@ -1003,7 +992,7 @@ namespace Emby.Server.Implementations.Dto
{
dto.RemoteTrailers = hasTrailers != null ?
hasTrailers.RemoteTrailers :
- new List<MediaUrl>();
+ new MediaUrl[] {};
}
dto.Name = item.Name;
@@ -1059,12 +1048,12 @@ namespace Emby.Server.Implementations.Dto
{
if (!string.IsNullOrWhiteSpace(item.Tagline))
{
- dto.Taglines = new List<string> { item.Tagline };
+ dto.Taglines = new string[] { item.Tagline };
}
if (dto.Taglines == null)
{
- dto.Taglines = new List<string>();
+ dto.Taglines = new string[]{};
}
}
@@ -1130,8 +1119,7 @@ namespace Emby.Server.Implementations.Dto
// Include artists that are not in the database yet, e.g., just added via metadata editor
//var foundArtists = artistItems.Items.Select(i => i.Item1.Name).ToList();
- dto.ArtistItems = new List<NameIdPair>();
- dto.ArtistItems.AddRange(hasArtist.Artists
+ dto.ArtistItems = hasArtist.Artists
//.Except(foundArtists, new DistinctNameComparer())
.Select(i =>
{
@@ -1156,7 +1144,7 @@ namespace Emby.Server.Implementations.Dto
return null;
- }).Where(i => i != null));
+ }).Where(i => i != null).ToArray();
}
var hasAlbumArtist = item as IHasAlbumArtist;
@@ -1182,8 +1170,7 @@ namespace Emby.Server.Implementations.Dto
// })
// .ToList();
- dto.AlbumArtists = new List<NameIdPair>();
- dto.AlbumArtists.AddRange(hasAlbumArtist.AlbumArtists
+ dto.AlbumArtists = hasAlbumArtist.AlbumArtists
//.Except(foundArtists, new DistinctNameComparer())
.Select(i =>
{
@@ -1208,7 +1195,7 @@ namespace Emby.Server.Implementations.Dto
return null;
- }).Where(i => i != null));
+ }).Where(i => i != null).ToArray();
}
// Add video info
@@ -1224,9 +1211,9 @@ namespace Emby.Server.Implementations.Dto
dto.HasSubtitles = video.HasSubtitles;
}
- if (video.AdditionalParts.Count != 0)
+ if (video.AdditionalParts.Length != 0)
{
- dto.PartCount = video.AdditionalParts.Count + 1;
+ dto.PartCount = video.AdditionalParts.Length + 1;
}
if (fields.Contains(ItemFields.MediaSourceCount))
@@ -1276,7 +1263,7 @@ namespace Emby.Server.Implementations.Dto
var hasSpecialFeatures = item as IHasSpecialFeatures;
if (hasSpecialFeatures != null)
{
- var specialFeatureCount = hasSpecialFeatures.SpecialFeatureIds.Count;
+ var specialFeatureCount = hasSpecialFeatures.SpecialFeatureIds.Length;
if (specialFeatureCount > 0)
{
@@ -1321,15 +1308,6 @@ namespace Emby.Server.Implementations.Dto
Series episodeSeries = null;
- if (fields.Contains(ItemFields.SeriesGenres))
- {
- episodeSeries = episodeSeries ?? episode.Series;
- if (episodeSeries != null)
- {
- dto.SeriesGenres = episodeSeries.Genres.ToList();
- }
- }
-
//if (fields.Contains(ItemFields.SeriesPrimaryImage))
{
episodeSeries = episodeSeries ?? episode.Series;
@@ -1345,27 +1323,6 @@ namespace Emby.Server.Implementations.Dto
if (episodeSeries != null)
{
dto.SeriesStudio = episodeSeries.Studios.FirstOrDefault();
- if (!string.IsNullOrWhiteSpace(dto.SeriesStudio))
- {
- try
- {
- var studio = _libraryManager.GetStudio(dto.SeriesStudio);
-
- if (studio != null)
- {
- dto.SeriesStudioInfo = new StudioDto
- {
- Name = dto.SeriesStudio,
- Id = studio.Id.ToString("N"),
- PrimaryImageTag = GetImageCacheTag(studio, ImageType.Primary)
- };
- }
- }
- catch (Exception ex)
- {
-
- }
- }
}
}
}
@@ -1440,9 +1397,9 @@ namespace Emby.Server.Implementations.Dto
if (fields.Contains(ItemFields.ProductionLocations))
{
- if (item.ProductionLocations.Count > 0 || item is Movie)
+ if (item.ProductionLocations.Length > 0 || item is Movie)
{
- dto.ProductionLocations = item.ProductionLocations.ToArray();
+ dto.ProductionLocations = item.ProductionLocations;
}
}
@@ -1509,7 +1466,9 @@ namespace Emby.Server.Implementations.Dto
BaseItem parent = null;
var isFirst = true;
- while (((!dto.HasLogo && logoLimit > 0) || (!dto.HasArtImage && artLimit > 0) || (!dto.HasThumb && thumbLimit > 0) || parent is Series) &&
+ var imageTags = dto.ImageTags;
+
+ while (((!(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && logoLimit > 0) || (!(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && artLimit > 0) || (!(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && thumbLimit > 0) || parent is Series) &&
(parent = parent ?? (isFirst ? GetImageDisplayParent(item, item) ?? owner : parent)) != null)
{
if (parent == null)
@@ -1519,7 +1478,7 @@ namespace Emby.Server.Implementations.Dto
var allImages = parent.ImageInfos;
- if (logoLimit > 0 && !dto.HasLogo && dto.ParentLogoItemId == null)
+ if (logoLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Logo)) && dto.ParentLogoItemId == null)
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Logo);
@@ -1529,7 +1488,7 @@ namespace Emby.Server.Implementations.Dto
dto.ParentLogoImageTag = GetImageCacheTag(parent, image);
}
}
- if (artLimit > 0 && !dto.HasArtImage && dto.ParentArtItemId == null)
+ if (artLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Art)) && dto.ParentArtItemId == null)
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Art);
@@ -1539,7 +1498,7 @@ namespace Emby.Server.Implementations.Dto
dto.ParentArtImageTag = GetImageCacheTag(parent, image);
}
}
- if (thumbLimit > 0 && !dto.HasThumb && (dto.ParentThumbItemId == null || parent is Series) && !(parent is ICollectionFolder) && !(parent is UserView))
+ if (thumbLimit > 0 && !(imageTags != null && imageTags.ContainsKey(ImageType.Thumb)) && (dto.ParentThumbItemId == null || parent is Series) && !(parent is ICollectionFolder) && !(parent is UserView))
{
var image = allImages.FirstOrDefault(i => i.Type == ImageType.Thumb);
@@ -1549,7 +1508,7 @@ namespace Emby.Server.Implementations.Dto
dto.ParentThumbImageTag = GetImageCacheTag(parent, image);
}
}
- if (backdropLimit > 0 && !dto.HasBackdrop)
+ if (backdropLimit > 0 && !((dto.BackdropImageTags != null && dto.BackdropImageTags.Length > 0) || (dto.ParentBackdropImageTags != null && dto.ParentBackdropImageTags.Length > 0)))
{
var images = allImages.Where(i => i.Type == ImageType.Backdrop).Take(backdropLimit).ToList();
@@ -1591,12 +1550,12 @@ namespace Emby.Server.Implementations.Dto
/// <param name="dto">The dto.</param>
/// <param name="item">The item.</param>
/// <returns>Task.</returns>
- public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item)
+ public void AttachPrimaryImageAspectRatio(IItemDto dto, IHasMetadata item)
{
dto.PrimaryImageAspectRatio = GetPrimaryImageAspectRatio(item);
}
- public double? GetPrimaryImageAspectRatio(IHasImages item)
+ public double? GetPrimaryImageAspectRatio(IHasMetadata item)
{
var imageInfo = item.GetImageInfo(ImageType.Primary, 0);