mirror of https://github.com/jellyfin/jellyfin.git
Reworked CategoryInfo and added ImageType enum
This commit is contained in:
parent
45cde97a58
commit
7d48e20aea
|
@ -136,6 +136,21 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ImageType ImageType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string imageType = QueryString["type"];
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(imageType))
|
||||||
|
{
|
||||||
|
return Model.Entities.ImageType.Primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ImageType)Enum.Parse(typeof(ImageType), imageType, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void WriteResponseToOutputStream(Stream stream)
|
protected override void WriteResponseToOutputStream(Stream stream)
|
||||||
{
|
{
|
||||||
ImageProcessor.ProcessImage(ImagePath, stream, Width, Height, MaxWidth, MaxHeight, Quality);
|
ImageProcessor.ProcessImage(ImagePath, stream, Width, Height, MaxWidth, MaxHeight, Quality);
|
||||||
|
@ -152,7 +167,6 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
|
|
||||||
string id = QueryString["id"];
|
string id = QueryString["id"];
|
||||||
string personName = QueryString["personname"];
|
string personName = QueryString["personname"];
|
||||||
string imageType = QueryString["type"] ?? string.Empty;
|
|
||||||
string imageIndex = QueryString["index"];
|
string imageIndex = QueryString["index"];
|
||||||
|
|
||||||
BaseItem item;
|
BaseItem item;
|
||||||
|
@ -168,28 +182,28 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
|
|
||||||
int index = string.IsNullOrEmpty(imageIndex) ? 0 : int.Parse(imageIndex);
|
int index = string.IsNullOrEmpty(imageIndex) ? 0 : int.Parse(imageIndex);
|
||||||
|
|
||||||
return GetImagePathFromTypes(item, imageType, index);
|
return GetImagePathFromTypes(item, ImageType, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetImagePathFromTypes(BaseItem item, string imageType, int imageIndex)
|
private string GetImagePathFromTypes(BaseItem item, ImageType imageType, int imageIndex)
|
||||||
{
|
{
|
||||||
if (imageType.Equals("logo", StringComparison.OrdinalIgnoreCase))
|
if (imageType == ImageType.Logo)
|
||||||
{
|
{
|
||||||
return item.LogoImagePath;
|
return item.LogoImagePath;
|
||||||
}
|
}
|
||||||
else if (imageType.Equals("backdrop", StringComparison.OrdinalIgnoreCase))
|
else if (imageType == ImageType.Backdrop)
|
||||||
{
|
{
|
||||||
return item.BackdropImagePaths.ElementAt(imageIndex);
|
return item.BackdropImagePaths.ElementAt(imageIndex);
|
||||||
}
|
}
|
||||||
else if (imageType.Equals("banner", StringComparison.OrdinalIgnoreCase))
|
else if (imageType == ImageType.Banner)
|
||||||
{
|
{
|
||||||
return item.BannerImagePath;
|
return item.BannerImagePath;
|
||||||
}
|
}
|
||||||
else if (imageType.Equals("art", StringComparison.OrdinalIgnoreCase))
|
else if (imageType == ImageType.Art)
|
||||||
{
|
{
|
||||||
return item.ArtImagePath;
|
return item.ArtImagePath;
|
||||||
}
|
}
|
||||||
else if (imageType.Equals("thumbnail", StringComparison.OrdinalIgnoreCase))
|
else if (imageType == ImageType.Thumbnail)
|
||||||
{
|
{
|
||||||
return item.ThumbnailImagePath;
|
return item.ThumbnailImagePath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace MediaBrowser.Api.HttpHandlers
|
||||||
{
|
{
|
||||||
public class StudiosHandler : JsonHandler
|
public class StudiosHandler : JsonHandler
|
||||||
{
|
{
|
||||||
protected sealed override object ObjectToSerialize
|
protected override object ObjectToSerialize
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,12 +6,12 @@ using System.Configuration;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using MediaBrowser.Model.Configuration;
|
|
||||||
using MediaBrowser.Common.Json;
|
using MediaBrowser.Common.Json;
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Model.Progress;
|
|
||||||
using MediaBrowser.Logging;
|
using MediaBrowser.Logging;
|
||||||
|
using MediaBrowser.Model.Configuration;
|
||||||
|
using MediaBrowser.Model.Progress;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Kernel
|
namespace MediaBrowser.Common.Kernel
|
||||||
{
|
{
|
||||||
|
@ -267,12 +267,18 @@ namespace MediaBrowser.Common.Kernel
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes all resources currently in use.
|
||||||
|
/// </summary>
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
DisposeHttpServer();
|
DisposeHttpServer();
|
||||||
DisposeLogger();
|
DisposeLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes the current HttpServer
|
||||||
|
/// </summary>
|
||||||
private void DisposeHttpServer()
|
private void DisposeHttpServer()
|
||||||
{
|
{
|
||||||
if (HttpServer != null)
|
if (HttpServer != null)
|
||||||
|
@ -281,6 +287,9 @@ namespace MediaBrowser.Common.Kernel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Disposes the current Logger instance
|
||||||
|
/// </summary>
|
||||||
private void DisposeLogger()
|
private void DisposeLogger()
|
||||||
{
|
{
|
||||||
if (Logger.LoggerInstance != null)
|
if (Logger.LoggerInstance != null)
|
||||||
|
|
|
@ -318,7 +318,7 @@ namespace MediaBrowser.Controller
|
||||||
/// Gets all studios from all recursive children of a folder
|
/// Gets all studios from all recursive children of a folder
|
||||||
/// The CategoryInfo class is used to keep track of the number of times each studio appears
|
/// The CategoryInfo class is used to keep track of the number of times each studio appears
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<CategoryInfo> GetAllStudios(Folder parent, Guid userId)
|
public IEnumerable<CategoryInfo<Studio>> GetAllStudios(Folder parent, Guid userId)
|
||||||
{
|
{
|
||||||
Dictionary<string, int> data = new Dictionary<string, int>();
|
Dictionary<string, int> data = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
@ -348,7 +348,7 @@ namespace MediaBrowser.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now go through the dictionary and create a Category for each studio
|
// Now go through the dictionary and create a Category for each studio
|
||||||
List<CategoryInfo> list = new List<CategoryInfo>();
|
List<CategoryInfo<Studio>> list = new List<CategoryInfo<Studio>>();
|
||||||
|
|
||||||
foreach (string key in data.Keys)
|
foreach (string key in data.Keys)
|
||||||
{
|
{
|
||||||
|
@ -357,11 +357,10 @@ namespace MediaBrowser.Controller
|
||||||
|
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
list.Add(new CategoryInfo()
|
list.Add(new CategoryInfo<Studio>()
|
||||||
{
|
{
|
||||||
Name = entity.Name,
|
Item = entity,
|
||||||
ItemCount = data[key],
|
ItemCount = data[key]
|
||||||
PrimaryImagePath = entity.PrimaryImagePath
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,7 +372,7 @@ namespace MediaBrowser.Controller
|
||||||
/// Gets all genres from all recursive children of a folder
|
/// Gets all genres from all recursive children of a folder
|
||||||
/// The CategoryInfo class is used to keep track of the number of times each genres appears
|
/// The CategoryInfo class is used to keep track of the number of times each genres appears
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<CategoryInfo> GetAllGenres(Folder parent, Guid userId)
|
public IEnumerable<CategoryInfo<Genre>> GetAllGenres(Folder parent, Guid userId)
|
||||||
{
|
{
|
||||||
Dictionary<string, int> data = new Dictionary<string, int>();
|
Dictionary<string, int> data = new Dictionary<string, int>();
|
||||||
|
|
||||||
|
@ -403,7 +402,7 @@ namespace MediaBrowser.Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now go through the dictionary and create a Category for each genre
|
// Now go through the dictionary and create a Category for each genre
|
||||||
List<CategoryInfo> list = new List<CategoryInfo>();
|
List<CategoryInfo<Genre>> list = new List<CategoryInfo<Genre>>();
|
||||||
|
|
||||||
foreach (string key in data.Keys)
|
foreach (string key in data.Keys)
|
||||||
{
|
{
|
||||||
|
@ -412,11 +411,10 @@ namespace MediaBrowser.Controller
|
||||||
|
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
list.Add(new CategoryInfo()
|
list.Add(new CategoryInfo<Genre>()
|
||||||
{
|
{
|
||||||
Name = entity.Name,
|
Item = entity,
|
||||||
ItemCount = data[key],
|
ItemCount = data[key]
|
||||||
PrimaryImagePath = entity.PrimaryImagePath
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,9 @@ using System.Text;
|
||||||
|
|
||||||
namespace MediaBrowser.Logging
|
namespace MediaBrowser.Logging
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a Logger that can write to any Stream
|
||||||
|
/// </summary>
|
||||||
public class StreamLogger : BaseLogger
|
public class StreamLogger : BaseLogger
|
||||||
{
|
{
|
||||||
private Stream Stream { get; set; }
|
private Stream Stream { get; set; }
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using MediaBrowser.Model.Users;
|
using MediaBrowser.Model.Users;
|
||||||
|
|
||||||
namespace MediaBrowser.Model.Entities
|
namespace MediaBrowser.Model.Entities
|
||||||
|
@ -26,5 +27,15 @@ namespace MediaBrowser.Model.Entities
|
||||||
public bool IsFolder { get; set; }
|
public bool IsFolder { get; set; }
|
||||||
|
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
public bool IsType(Type type)
|
||||||
|
{
|
||||||
|
return IsType(type.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsType(string type)
|
||||||
|
{
|
||||||
|
return Type.Equals(type, StringComparison.OrdinalIgnoreCase);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,16 +2,14 @@
|
||||||
namespace MediaBrowser.Model.Entities
|
namespace MediaBrowser.Model.Entities
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is a stub class used by the api to get IBN types in a compact format
|
/// This is a stub class used by the api to get IBN types along with their item counts
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CategoryInfo
|
public class CategoryInfo<T>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The name of the genre, year, studio, etc
|
/// The actual genre, year, studio, etc
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public T Item { get; set; }
|
||||||
|
|
||||||
public string PrimaryImagePath { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of items that have the genre, year, studio, etc
|
/// The number of items that have the genre, year, studio, etc
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
namespace MediaBrowser.Model.Entities
|
||||||
|
{
|
||||||
|
public enum ImageType
|
||||||
|
{
|
||||||
|
Primary,
|
||||||
|
Art,
|
||||||
|
Backdrop,
|
||||||
|
Banner,
|
||||||
|
Logo,
|
||||||
|
Thumbnail
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,6 +47,7 @@
|
||||||
<Compile Include="Entities\CategoryInfo.cs" />
|
<Compile Include="Entities\CategoryInfo.cs" />
|
||||||
<Compile Include="Entities\Folder.cs" />
|
<Compile Include="Entities\Folder.cs" />
|
||||||
<Compile Include="Entities\Genre.cs" />
|
<Compile Include="Entities\Genre.cs" />
|
||||||
|
<Compile Include="Entities\ImageType.cs" />
|
||||||
<Compile Include="Entities\Person.cs" />
|
<Compile Include="Entities\Person.cs" />
|
||||||
<Compile Include="Entities\Studio.cs" />
|
<Compile Include="Entities\Studio.cs" />
|
||||||
<Compile Include="Entities\Video.cs" />
|
<Compile Include="Entities\Video.cs" />
|
||||||
|
|
Loading…
Reference in New Issue