The Free Software Media System - Server Backend & API
added more images to search output
Luke Pulverenti1ed03b0bb328
diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.csindex a497ba001d..f83c0a771e 100644--- a/MediaBrowser.Api/SearchService.cs+++ b/MediaBrowser.Api/SearchService.cs@@ -1,5 +1,4 @@-using MediaBrowser.Controller;-using MediaBrowser.Controller.Drawing;+using MediaBrowser.Controller.Drawing;using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Entities;using MediaBrowser.Controller.Entities.Audio;@@ -157,6 +156,9 @@ namespace MediaBrowser.Apiresult.PrimaryImageTag = _imageProcessor.GetImageCacheTag(item, ImageType.Primary, item.GetImagePath(ImageType.Primary));}+ SetThumbImageInfo(result, item);+ SetBackdropImageInfo(result, item);+var episode = item as Episode;if (episode != null)@@ -205,5 +207,51 @@ namespace MediaBrowser.Apireturn result;}++ private void SetThumbImageInfo(SearchHint hint, BaseItem item)+ {+ var itemWithImage = item.HasImage(ImageType.Thumb) ? item : null;++ if (itemWithImage == null)+ {+ if (item is Episode)+ {+ itemWithImage = GetParentWithImage<Series>(item, ImageType.Thumb);+ }+ }++ if (itemWithImage == null)+ {+ itemWithImage = GetParentWithImage<BaseItem>(item, ImageType.Thumb);+ }++ if (itemWithImage != null)+ {+ hint.ThumbImageTag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Thumb, itemWithImage.GetImagePath(ImageType.Thumb));+ hint.ThumbImageItemId = itemWithImage.Id.ToString("N");+ }+ }++ private void SetBackdropImageInfo(SearchHint hint, BaseItem item)+ {+ var itemWithImage = item.HasImage(ImageType.Backdrop) ? item : null;++ if (itemWithImage == null)+ {+ itemWithImage = GetParentWithImage<BaseItem>(item, ImageType.Backdrop);+ }++ if (itemWithImage != null)+ {+ hint.BackdropImageTag = _imageProcessor.GetImageCacheTag(itemWithImage, ImageType.Backdrop, itemWithImage.GetImagePath(ImageType.Backdrop, 0));+ hint.BackdropImageItemId = itemWithImage.Id.ToString("N");+ }+ }++ private T GetParentWithImage<T>(BaseItem item, ImageType type)+ where T : BaseItem+ {+ return item.Parents.OfType<T>().FirstOrDefault(i => i.HasImage(type));+ }}}diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.csindex 5433ecc2e3..79de8cc657 100644--- a/MediaBrowser.Api/SessionsService.cs+++ b/MediaBrowser.Api/SessionsService.cs@@ -205,7 +205,7 @@ namespace MediaBrowser.Api[ApiMember(Name = "Id", Description = "Session Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]public Guid Id { get; set; }- [ApiMember(Name = "PlayableMediaTypes", Description = "A list of playable media types, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]+ [ApiMember(Name = "PlayableMediaTypes", Description = "A list of playable media types, comma delimited. Audio, Video, Book, Game, Photo.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]public string PlayableMediaTypes { get; set; }}diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.csindex dbda4a243b..dcee4bae76 100644--- a/MediaBrowser.Controller/Entities/BaseItem.cs+++ b/MediaBrowser.Controller/Entities/BaseItem.cs@@ -1394,11 +1394,12 @@ namespace MediaBrowser.Controller.Entities{if (type == ImageType.Backdrop){- throw new ArgumentException("Backdrops should be accessed using Item.Backdrops");+ return BackdropImagePaths.Count > imageIndex;}if (type == ImageType.Screenshot){- throw new ArgumentException("Screenshots should be accessed using Item.Screenshots");+ var hasScreenshots = this as IHasScreenshots;+ return hasScreenshots != null && hasScreenshots.ScreenshotImagePaths.Count > imageIndex;}return !string.IsNullOrEmpty(this.GetImagePath(type));diff --git a/MediaBrowser.Model/Search/SearchHint.cs b/MediaBrowser.Model/Search/SearchHint.csindex bebe237348..002200c0fd 100644--- a/MediaBrowser.Model/Search/SearchHint.cs+++ b/MediaBrowser.Model/Search/SearchHint.cs@@ -49,6 +49,30 @@ namespace MediaBrowser.Model.Search/// <value>The image tag.</value>public Guid? PrimaryImageTag { get; set; }+ /// <summary>+ /// Gets or sets the thumb image tag.+ /// </summary>+ /// <value>The thumb image tag.</value>+ public Guid? ThumbImageTag { get; set; }++ /// <summary>+ /// Gets or sets the thumb image item identifier.+ /// </summary>+ /// <value>The thumb image item identifier.</value>+ public string ThumbImageItemId { get; set; }++ /// <summary>+ /// Gets or sets the backdrop image tag.+ /// </summary>+ /// <value>The backdrop image tag.</value>+ public Guid? BackdropImageTag { get; set; }++ /// <summary>+ /// Gets or sets the backdrop image item identifier.+ /// </summary>+ /// <value>The backdrop image item identifier.</value>+ public string BackdropImageItemId { get; set; }+/// <summary>/// Gets or sets the type./// </summary>