mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 09:04:42 +01:00
Added IDtoService
This commit is contained in:
@@ -612,7 +612,7 @@ namespace MediaBrowser.Controller.Drawing
|
||||
/// <param name="supportedEnhancers">The supported enhancers.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">originalImagePath</exception>
|
||||
public async Task<string> GetEnhancedImage(string originalImagePath, DateTime dateModified, BaseItem item, ImageType imageType, int imageIndex, IEnumerable<IImageEnhancer> supportedEnhancers)
|
||||
public async Task<string> GetEnhancedImage(string originalImagePath, DateTime dateModified, BaseItem item, ImageType imageType, int imageIndex, List<IImageEnhancer> supportedEnhancers)
|
||||
{
|
||||
if (string.IsNullOrEmpty(originalImagePath))
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
71
MediaBrowser.Controller/Dto/IDtoService.cs
Normal file
71
MediaBrowser.Controller/Dto/IDtoService.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Session;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IDtoService
|
||||
/// </summary>
|
||||
public interface IDtoService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the user dto.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>Task{UserDto}.</returns>
|
||||
Task<UserDto> GetUserDto(User user);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the session info dto.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <returns>SessionInfoDto.</returns>
|
||||
SessionInfoDto GetSessionInfoDto(SessionInfo session);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base item info.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>BaseItemInfo.</returns>
|
||||
BaseItemInfo GetBaseItemInfo(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the dto id.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
string GetDtoId(BaseItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user item data dto.
|
||||
/// </summary>
|
||||
/// <param name="data">The data.</param>
|
||||
/// <returns>UserItemDataDto.</returns>
|
||||
UserItemDataDto GetUserItemDataDto(UserItemData data);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item by dto id.
|
||||
/// </summary>
|
||||
/// <param name="id">The id.</param>
|
||||
/// <param name="userId">The user id.</param>
|
||||
/// <returns>BaseItem.</returns>
|
||||
BaseItem GetItemByDtoId(string id, Guid? userId = null);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base item dto.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="fields">The fields.</param>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <param name="owner">The owner.</param>
|
||||
/// <returns>Task{BaseItemDto}.</returns>
|
||||
Task<BaseItemDto> GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null);
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Session;
|
||||
|
||||
namespace MediaBrowser.Controller.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SessionInfoDtoBuilder
|
||||
/// </summary>
|
||||
public static class SessionInfoDtoBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the session info dto.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <returns>SessionInfoDto.</returns>
|
||||
public static SessionInfoDto GetSessionInfoDto(SessionInfo session)
|
||||
{
|
||||
var dto = new SessionInfoDto
|
||||
{
|
||||
Client = session.Client,
|
||||
DeviceId = session.DeviceId,
|
||||
DeviceName = session.DeviceName,
|
||||
Id = session.Id.ToString("N"),
|
||||
LastActivityDate = session.LastActivityDate,
|
||||
NowPlayingPositionTicks = session.NowPlayingPositionTicks,
|
||||
SupportsRemoteControl = session.SupportsRemoteControl,
|
||||
IsPaused = session.IsPaused,
|
||||
IsMuted = session.IsMuted,
|
||||
NowViewingContext = session.NowViewingContext,
|
||||
NowViewingItemId = session.NowViewingItemId,
|
||||
NowViewingItemName = session.NowViewingItemName,
|
||||
NowViewingItemType = session.NowViewingItemType,
|
||||
ApplicationVersion = session.ApplicationVersion
|
||||
};
|
||||
|
||||
if (session.NowPlayingItem != null)
|
||||
{
|
||||
dto.NowPlayingItem = DtoBuilder.GetBaseItemInfo(session.NowPlayingItem);
|
||||
}
|
||||
|
||||
if (session.User != null)
|
||||
{
|
||||
dto.UserId = session.User.Id.ToString("N");
|
||||
dto.UserName = session.User.Name;
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UserDtoBuilder
|
||||
/// </summary>
|
||||
public class UserDtoBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// The _logger
|
||||
/// </summary>
|
||||
private readonly ILogger _logger;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UserDtoBuilder"/> class.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
public UserDtoBuilder(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a User to a DTOUser
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>DtoUser.</returns>
|
||||
/// <exception cref="System.ArgumentNullException">user</exception>
|
||||
public async Task<UserDto> GetUserDto(User user)
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new ArgumentNullException("user");
|
||||
}
|
||||
|
||||
var dto = new UserDto
|
||||
{
|
||||
Id = user.Id.ToString("N"),
|
||||
Name = user.Name,
|
||||
HasPassword = !String.IsNullOrEmpty(user.Password),
|
||||
LastActivityDate = user.LastActivityDate,
|
||||
LastLoginDate = user.LastLoginDate,
|
||||
Configuration = user.Configuration
|
||||
};
|
||||
|
||||
var image = user.PrimaryImagePath;
|
||||
|
||||
if (!string.IsNullOrEmpty(image))
|
||||
{
|
||||
dto.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(user, ImageType.Primary, image);
|
||||
|
||||
try
|
||||
{
|
||||
await DtoBuilder.AttachPrimaryImageAspectRatio(dto, user, _logger).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Have to use a catch-all unfortunately because some .net image methods throw plain Exceptions
|
||||
_logger.ErrorException("Error generating PrimaryImageAspectRatio for {0}", ex, user.Name);
|
||||
}
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,10 +71,10 @@
|
||||
<Compile Include="..\SharedVersion.cs">
|
||||
<Link>Properties\SharedVersion.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="Dto\IDtoService.cs" />
|
||||
<Compile Include="Entities\AdultVideo.cs" />
|
||||
<Compile Include="Entities\Book.cs" />
|
||||
<Compile Include="Notifications\Configuration\IServerConfigurationManager.cs" />
|
||||
<Compile Include="Dto\SessionInfoDtoBuilder.cs" />
|
||||
<Compile Include="Entities\Audio\MusicGenre.cs" />
|
||||
<Compile Include="Entities\Game.cs" />
|
||||
<Compile Include="Entities\GameGenre.cs" />
|
||||
@@ -93,7 +93,6 @@
|
||||
<Compile Include="Drawing\ImageExtensions.cs" />
|
||||
<Compile Include="Drawing\ImageHeader.cs" />
|
||||
<Compile Include="Drawing\ImageManager.cs" />
|
||||
<Compile Include="Dto\UserDtoBuilder.cs" />
|
||||
<Compile Include="Entities\AggregateFolder.cs" />
|
||||
<Compile Include="Entities\Audio\Artist.cs" />
|
||||
<Compile Include="Entities\Audio\Audio.cs" />
|
||||
@@ -128,7 +127,6 @@
|
||||
<Compile Include="IO\NativeMethods.cs" />
|
||||
<Compile Include="IServerApplicationHost.cs" />
|
||||
<Compile Include="IServerApplicationPaths.cs" />
|
||||
<Compile Include="Dto\DtoBuilder.cs" />
|
||||
<Compile Include="Library\SearchHintInfo.cs" />
|
||||
<Compile Include="Providers\IProviderManager.cs" />
|
||||
<Compile Include="MediaInfo\MediaEncoderHelpers.cs" />
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.IO;
|
||||
using MediaBrowser.Common.MediaInfo;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@@ -31,8 +30,6 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
/// <value>The subtitle cache.</value>
|
||||
internal FileSystemRepository SubtitleCache { get; set; }
|
||||
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
|
||||
private readonly IServerApplicationPaths _appPaths;
|
||||
private readonly IMediaEncoder _encoder;
|
||||
private readonly ILogger _logger;
|
||||
@@ -43,15 +40,13 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||
/// </summary>
|
||||
/// <param name="appPaths">The app paths.</param>
|
||||
/// <param name="encoder">The encoder.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="logger">The logger.</param>
|
||||
/// <param name="itemRepo">The item repo.</param>
|
||||
/// <exception cref="System.ArgumentNullException">zipClient</exception>
|
||||
public FFMpegManager(IServerApplicationPaths appPaths, IMediaEncoder encoder, ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
|
||||
public FFMpegManager(IServerApplicationPaths appPaths, IMediaEncoder encoder, ILogger logger, IItemRepository itemRepo)
|
||||
{
|
||||
_appPaths = appPaths;
|
||||
_encoder = encoder;
|
||||
_libraryManager = libraryManager;
|
||||
_logger = logger;
|
||||
_itemRepo = itemRepo;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Persistence
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user