support image types on general images

This commit is contained in:
Luke Pulverenti 2013-05-03 14:33:47 -04:00
parent d590220257
commit 29dbc2f631

View File

@ -8,9 +8,9 @@ namespace MediaBrowser.Api.Images
/// <summary> /// <summary>
/// Class GetGeneralImage /// Class GetGeneralImage
/// </summary> /// </summary>
[Route("/Images/General/{Name}", "GET")] [Route("/Images/General/{Name}/{Type}", "GET")]
[Api(Description = "Gets a general image by name")] [Api(Description = "Gets a general image by name")]
public class GetGeneralImage : ImageRequest public class GetGeneralImage
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -18,6 +18,9 @@ namespace MediaBrowser.Api.Images
/// <value>The name.</value> /// <value>The name.</value>
[ApiMember(Name = "Name", Description = "The name of the image", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")] [ApiMember(Name = "Name", Description = "The name of the image", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Name { get; set; } public string Name { get; set; }
[ApiMember(Name = "Type", Description = "Image Type (primary, backdrop, logo, etc).", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Type { get; set; }
} }
/// <summary> /// <summary>
@ -25,7 +28,7 @@ namespace MediaBrowser.Api.Images
/// </summary> /// </summary>
[Route("/Images/Ratings/{Theme}/{Name}", "GET")] [Route("/Images/Ratings/{Theme}/{Name}", "GET")]
[Api(Description = "Gets a rating image by name")] [Api(Description = "Gets a rating image by name")]
public class GetRatingImage : ImageRequest public class GetRatingImage
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -47,7 +50,7 @@ namespace MediaBrowser.Api.Images
/// </summary> /// </summary>
[Route("/Images/MediaInfo/{Theme}/{Name}", "GET")] [Route("/Images/MediaInfo/{Theme}/{Name}", "GET")]
[Api(Description = "Gets a media info image by name")] [Api(Description = "Gets a media info image by name")]
public class GetMediaInfoImage : ImageRequest public class GetMediaInfoImage
{ {
/// <summary> /// <summary>
/// Gets or sets the name. /// Gets or sets the name.
@ -90,7 +93,11 @@ namespace MediaBrowser.Api.Images
/// <returns>System.Object.</returns> /// <returns>System.Object.</returns>
public object Get(GetGeneralImage request) public object Get(GetGeneralImage request)
{ {
var file = Path.Combine(_appPaths.GeneralPath, request.Name, "folder.jpg"); var filename = string.Equals(request.Type, "primary", System.StringComparison.OrdinalIgnoreCase)
? "folder"
: request.Type;
var file = Path.Combine(_appPaths.GeneralPath, request.Name, filename + ".jpg");
return ToStaticFileResult(File.Exists(file) ? file : Path.ChangeExtension(file, ".png")); return ToStaticFileResult(File.Exists(file) ? file : Path.ChangeExtension(file, ".png"));
} }
@ -168,12 +175,12 @@ namespace MediaBrowser.Api.Images
return ToStaticFileResult(file); return ToStaticFileResult(file);
} }
} }
var allFolder = Path.Combine(_appPaths.MediaInfoImagesPath, "all"); var allFolder = Path.Combine(_appPaths.MediaInfoImagesPath, "all");
if (Directory.Exists(allFolder)) if (Directory.Exists(allFolder))
{ {
var file = Path.Combine(allFolder, request.Name + ".png"); var file = Path.Combine(allFolder, request.Name + ".png");
if (File.Exists(file)) if (File.Exists(file))
{ {