mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-09 15:20:34 +02:00
Remove exception handler
This commit is contained in:
parent
376619369d
commit
30609236ab
|
@ -48,14 +48,7 @@ namespace Jellyfin.Api.Controllers.Images
|
||||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetGeneralImages()
|
public IActionResult GetGeneralImages()
|
||||||
{
|
{
|
||||||
try
|
return Ok(GetImageList(_applicationPaths.GeneralPath, false));
|
||||||
{
|
|
||||||
return Ok(GetImageList(_applicationPaths.GeneralPath, false));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -70,28 +63,21 @@ namespace Jellyfin.Api.Controllers.Images
|
||||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetGeneralImage([FromRoute] string name, [FromRoute] string type)
|
public IActionResult GetGeneralImage([FromRoute] string name, [FromRoute] string type)
|
||||||
{
|
{
|
||||||
try
|
var filename = string.Equals(type, "primary", StringComparison.OrdinalIgnoreCase)
|
||||||
|
? "folder"
|
||||||
|
: type;
|
||||||
|
|
||||||
|
var paths = BaseItem.SupportedImageExtensions
|
||||||
|
.Select(i => Path.Combine(_applicationPaths.GeneralPath, name, filename + i)).ToList();
|
||||||
|
|
||||||
|
var path = paths.FirstOrDefault(System.IO.File.Exists) ?? paths.FirstOrDefault();
|
||||||
|
if (path == null || !System.IO.File.Exists(path))
|
||||||
{
|
{
|
||||||
var filename = string.Equals(type, "primary", StringComparison.OrdinalIgnoreCase)
|
return NotFound();
|
||||||
? "folder"
|
|
||||||
: type;
|
|
||||||
|
|
||||||
var paths = BaseItem.SupportedImageExtensions
|
|
||||||
.Select(i => Path.Combine(_applicationPaths.GeneralPath, name, filename + i)).ToList();
|
|
||||||
|
|
||||||
var path = paths.FirstOrDefault(System.IO.File.Exists) ?? paths.FirstOrDefault();
|
|
||||||
if (path == null || !System.IO.File.Exists(path))
|
|
||||||
{
|
|
||||||
return NotFound();
|
|
||||||
}
|
|
||||||
|
|
||||||
var contentType = MimeTypes.GetMimeType(path);
|
|
||||||
return new FileStreamResult(System.IO.File.OpenRead(path), contentType);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var contentType = MimeTypes.GetMimeType(path);
|
||||||
|
return new FileStreamResult(System.IO.File.OpenRead(path), contentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -103,14 +89,7 @@ namespace Jellyfin.Api.Controllers.Images
|
||||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetRatingImages()
|
public IActionResult GetRatingImages()
|
||||||
{
|
{
|
||||||
try
|
return Ok(GetImageList(_applicationPaths.RatingsPath, false));
|
||||||
{
|
|
||||||
return Ok(GetImageList(_applicationPaths.RatingsPath, false));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -127,14 +106,7 @@ namespace Jellyfin.Api.Controllers.Images
|
||||||
[FromRoute] string theme,
|
[FromRoute] string theme,
|
||||||
[FromRoute] string name)
|
[FromRoute] string name)
|
||||||
{
|
{
|
||||||
try
|
return GetImageFile(_applicationPaths.RatingsPath, theme, name);
|
||||||
{
|
|
||||||
return GetImageFile(_applicationPaths.RatingsPath, theme, name);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -146,14 +118,7 @@ namespace Jellyfin.Api.Controllers.Images
|
||||||
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(typeof(string), StatusCodes.Status500InternalServerError)]
|
||||||
public IActionResult GetMediaInfoImages()
|
public IActionResult GetMediaInfoImages()
|
||||||
{
|
{
|
||||||
try
|
return Ok(GetImageList(_applicationPaths.MediaInfoImagesPath, false));
|
||||||
{
|
|
||||||
return Ok(GetImageList(_applicationPaths.MediaInfoImagesPath, false));
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -170,14 +135,7 @@ namespace Jellyfin.Api.Controllers.Images
|
||||||
[FromRoute] string theme,
|
[FromRoute] string theme,
|
||||||
[FromRoute] string name)
|
[FromRoute] string name)
|
||||||
{
|
{
|
||||||
try
|
return GetImageFile(_applicationPaths.MediaInfoImagesPath, theme, name);
|
||||||
{
|
|
||||||
return GetImageFile(_applicationPaths.MediaInfoImagesPath, theme, name);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue