aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-01-05 01:08:22 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-01-05 01:08:22 -0500
commit1ed03b0bb328e4d5c48c560c06aab55b4c75cd46 (patch)
tree80e1f979c71f49e9c5bc9f6a155cc5319c58c1b0
parentd957c0da048ed55814a3a1c397bcbc13799acd86 (diff)
added more images to search output
-rw-r--r--MediaBrowser.Api/SearchService.cs52
-rw-r--r--MediaBrowser.Api/SessionsService.cs2
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs5
-rw-r--r--MediaBrowser.Model/Search/SearchHint.cs24
4 files changed, 78 insertions, 5 deletions
diff --git a/MediaBrowser.Api/SearchService.cs b/MediaBrowser.Api/SearchService.cs
index a497ba001..f83c0a771 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.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));
+ }
}
}
diff --git a/MediaBrowser.Api/SessionsService.cs b/MediaBrowser.Api/SessionsService.cs
index 5433ecc2e..79de8cc65 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.cs
index dbda4a243..dcee4bae7 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.cs
index bebe23734..002200c0f 100644
--- a/MediaBrowser.Model/Search/SearchHint.cs
+++ b/MediaBrowser.Model/Search/SearchHint.cs
@@ -50,6 +50,30 @@ namespace MediaBrowser.Model.Search
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>
/// <value>The type.</value>