added more images to search output

This commit is contained in:
Luke Pulverenti 2014-01-05 01:08:22 -05:00
parent d957c0da04
commit 1ed03b0bb3
4 changed files with 78 additions and 5 deletions

View File

@ -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.Api
result.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.Api
return 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));
}
}
}

View File

@ -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; }
}

View File

@ -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));

View File

@ -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>