mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-30 20:38:27 +01:00
Merge branch 'api-migration' into api-syncplay
# Conflicts: # MediaBrowser.Api/SyncPlay/SyncPlayService.cs
This commit is contained in:
@@ -43,7 +43,7 @@ namespace MediaBrowser.Api
|
||||
private readonly IMediaSourceManager _mediaSourceManager;
|
||||
|
||||
/// <summary>
|
||||
/// The active transcoding jobs
|
||||
/// The active transcoding jobs.
|
||||
/// </summary>
|
||||
private readonly List<TranscodingJob> _activeTranscodingJobs = new List<TranscodingJob>();
|
||||
|
||||
@@ -293,7 +293,7 @@ namespace MediaBrowser.Api
|
||||
|
||||
/// <summary>
|
||||
/// <summary>
|
||||
/// The progressive
|
||||
/// The progressive.
|
||||
/// </summary>
|
||||
/// Called when [transcode failed to start].
|
||||
/// </summary>
|
||||
|
||||
@@ -17,7 +17,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseApiService
|
||||
/// Class BaseApiService.
|
||||
/// </summary>
|
||||
public abstract class BaseApiService : IService, IRequiresRequest
|
||||
{
|
||||
@@ -268,7 +268,6 @@ namespace MediaBrowser.Api
|
||||
Name = name.Replace(BaseItem.SlugChar, '&'),
|
||||
IncludeItemTypes = new[] { typeof(T).Name },
|
||||
DtoOptions = dtoOptions
|
||||
|
||||
}).OfType<T>().FirstOrDefault();
|
||||
|
||||
result ??= libraryManager.GetItemList(new InternalItemsQuery
|
||||
@@ -276,7 +275,6 @@ namespace MediaBrowser.Api
|
||||
Name = name.Replace(BaseItem.SlugChar, '/'),
|
||||
IncludeItemTypes = new[] { typeof(T).Name },
|
||||
DtoOptions = dtoOptions
|
||||
|
||||
}).OfType<T>().FirstOrDefault();
|
||||
|
||||
result ??= libraryManager.GetItemList(new InternalItemsQuery
|
||||
@@ -284,7 +282,6 @@ namespace MediaBrowser.Api
|
||||
Name = name.Replace(BaseItem.SlugChar, '?'),
|
||||
IncludeItemTypes = new[] { typeof(T).Name },
|
||||
DtoOptions = dtoOptions
|
||||
|
||||
}).OfType<T>().FirstOrDefault();
|
||||
|
||||
return result;
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Devices;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Controller.Security;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Devices;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Api.Devices
|
||||
{
|
||||
[Route("/Devices", "GET", Summary = "Gets all devices")]
|
||||
[Authenticated(Roles = "Admin")]
|
||||
public class GetDevices : DeviceQuery, IReturn<QueryResult<DeviceInfo>>
|
||||
{
|
||||
}
|
||||
|
||||
[Route("/Devices/Info", "GET", Summary = "Gets info for a device")]
|
||||
[Authenticated(Roles = "Admin")]
|
||||
public class GetDeviceInfo : IReturn<DeviceInfo>
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Device Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Devices/Options", "GET", Summary = "Gets options for a device")]
|
||||
[Authenticated(Roles = "Admin")]
|
||||
public class GetDeviceOptions : IReturn<DeviceOptions>
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Device Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Devices", "DELETE", Summary = "Deletes a device")]
|
||||
public class DeleteDevice
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Device Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "DELETE")]
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Devices/Options", "POST", Summary = "Updates device options")]
|
||||
[Authenticated(Roles = "Admin")]
|
||||
public class PostDeviceOptions : DeviceOptions, IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Id", Description = "Device Id", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "DELETE")]
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
public class DeviceService : BaseApiService
|
||||
{
|
||||
private readonly IDeviceManager _deviceManager;
|
||||
private readonly IAuthenticationRepository _authRepo;
|
||||
private readonly ISessionManager _sessionManager;
|
||||
|
||||
public DeviceService(
|
||||
ILogger<DeviceService> logger,
|
||||
IServerConfigurationManager serverConfigurationManager,
|
||||
IHttpResultFactory httpResultFactory,
|
||||
IDeviceManager deviceManager,
|
||||
IAuthenticationRepository authRepo,
|
||||
ISessionManager sessionManager)
|
||||
: base(logger, serverConfigurationManager, httpResultFactory)
|
||||
{
|
||||
_deviceManager = deviceManager;
|
||||
_authRepo = authRepo;
|
||||
_sessionManager = sessionManager;
|
||||
}
|
||||
|
||||
public void Post(PostDeviceOptions request)
|
||||
{
|
||||
_deviceManager.UpdateDeviceOptions(request.Id, request);
|
||||
}
|
||||
|
||||
public object Get(GetDevices request)
|
||||
{
|
||||
return ToOptimizedResult(_deviceManager.GetDevices(request));
|
||||
}
|
||||
|
||||
public object Get(GetDeviceInfo request)
|
||||
{
|
||||
return _deviceManager.GetDevice(request.Id);
|
||||
}
|
||||
|
||||
public object Get(GetDeviceOptions request)
|
||||
{
|
||||
return _deviceManager.GetDeviceOptions(request.Id);
|
||||
}
|
||||
|
||||
public void Delete(DeleteDevice request)
|
||||
{
|
||||
var sessions = _authRepo.Get(new AuthenticationInfoQuery
|
||||
{
|
||||
DeviceId = request.Id
|
||||
|
||||
}).Items;
|
||||
|
||||
foreach (var session in sessions)
|
||||
{
|
||||
_sessionManager.Logout(session);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ namespace MediaBrowser.Api
|
||||
public interface IHasDtoOptions : IHasItemFields
|
||||
{
|
||||
bool? EnableImages { get; set; }
|
||||
|
||||
bool? EnableUserData { get; set; }
|
||||
|
||||
int? ImageTypeLimit { get; set; }
|
||||
|
||||
@@ -5,7 +5,7 @@ using MediaBrowser.Model.Querying;
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IHasItemFields
|
||||
/// Interface IHasItemFields.
|
||||
/// </summary>
|
||||
public interface IHasItemFields
|
||||
{
|
||||
@@ -43,7 +43,6 @@ namespace MediaBrowser.Api
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}).Where(i => i.HasValue).Select(i => i.Value).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,30 +4,30 @@ using MediaBrowser.Model.Services;
|
||||
namespace MediaBrowser.Api.Images
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ImageRequest
|
||||
/// Class ImageRequest.
|
||||
/// </summary>
|
||||
public class ImageRequest : DeleteImageRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The max width
|
||||
/// The max width.
|
||||
/// </summary>
|
||||
[ApiMember(Name = "MaxWidth", Description = "The maximum image width to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? MaxWidth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The max height
|
||||
/// The max height.
|
||||
/// </summary>
|
||||
[ApiMember(Name = "MaxHeight", Description = "The maximum image height to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? MaxHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The width
|
||||
/// The width.
|
||||
/// </summary>
|
||||
[ApiMember(Name = "Width", Description = "The fixed image width to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The height
|
||||
/// The height.
|
||||
/// </summary>
|
||||
[ApiMember(Name = "Height", Description = "The fixed image height to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? Height { get; set; }
|
||||
@@ -79,7 +79,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class DeleteImageRequest
|
||||
/// Class DeleteImageRequest.
|
||||
/// </summary>
|
||||
public class DeleteImageRequest
|
||||
{
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class UpdateItemImageIndex
|
||||
/// Class UpdateItemImageIndex.
|
||||
/// </summary>
|
||||
[Route("/Items/{Id}/Images/{Type}/{Index}/Index", "POST", Summary = "Updates the index for an item image")]
|
||||
[Authenticated(Roles = "admin")]
|
||||
@@ -94,7 +94,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetPersonImage
|
||||
/// Class GetPersonImage.
|
||||
/// </summary>
|
||||
[Route("/Artists/{Name}/Images/{Type}", "GET")]
|
||||
[Route("/Artists/{Name}/Images/{Type}/{Index}", "GET")]
|
||||
@@ -131,7 +131,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetUserImage
|
||||
/// Class GetUserImage.
|
||||
/// </summary>
|
||||
[Route("/Users/{Id}/Images/{Type}", "GET")]
|
||||
[Route("/Users/{Id}/Images/{Type}/{Index}", "GET")]
|
||||
@@ -148,7 +148,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class DeleteItemImage
|
||||
/// Class DeleteItemImage.
|
||||
/// </summary>
|
||||
[Route("/Items/{Id}/Images/{Type}", "DELETE")]
|
||||
[Route("/Items/{Id}/Images/{Type}/{Index}", "DELETE")]
|
||||
@@ -164,7 +164,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class DeleteUserImage
|
||||
/// Class DeleteUserImage.
|
||||
/// </summary>
|
||||
[Route("/Users/{Id}/Images/{Type}", "DELETE")]
|
||||
[Route("/Users/{Id}/Images/{Type}/{Index}", "DELETE")]
|
||||
@@ -180,7 +180,7 @@ namespace MediaBrowser.Api.Images
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class PostUserImage
|
||||
/// Class PostUserImage.
|
||||
/// </summary>
|
||||
[Route("/Users/{Id}/Images/{Type}", "POST")]
|
||||
[Route("/Users/{Id}/Images/{Type}/{Index}", "POST")]
|
||||
@@ -195,14 +195,14 @@ namespace MediaBrowser.Api.Images
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The raw Http Request Input Stream
|
||||
/// The raw Http Request Input Stream.
|
||||
/// </summary>
|
||||
/// <value>The request stream.</value>
|
||||
public Stream RequestStream { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class PostItemImage
|
||||
/// Class PostItemImage.
|
||||
/// </summary>
|
||||
[Route("/Items/{Id}/Images/{Type}", "POST")]
|
||||
[Route("/Items/{Id}/Images/{Type}/{Index}", "POST")]
|
||||
@@ -217,14 +217,14 @@ namespace MediaBrowser.Api.Images
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The raw Http Request Input Stream
|
||||
/// The raw Http Request Input Stream.
|
||||
/// </summary>
|
||||
/// <value>The request stream.</value>
|
||||
public Stream RequestStream { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class ImageService
|
||||
/// Class ImageService.
|
||||
/// </summary>
|
||||
public class ImageService : BaseApiService
|
||||
{
|
||||
@@ -743,7 +743,6 @@ namespace MediaBrowser.Api.Images
|
||||
Path = imageResult.Item1,
|
||||
|
||||
FileShare = FileShare.Read
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
@@ -896,6 +895,11 @@ namespace MediaBrowser.Api.Images
|
||||
// Handle image/png; charset=utf-8
|
||||
mimeType = mimeType.Split(';').FirstOrDefault();
|
||||
var userDataPath = Path.Combine(ServerConfigurationManager.ApplicationPaths.UserConfigurationDirectoryPath, user.Username);
|
||||
if (user.ProfileImage != null)
|
||||
{
|
||||
_userManager.ClearProfileImage(user);
|
||||
}
|
||||
|
||||
user.ProfileImage = new Jellyfin.Data.Entities.ImageInfo(Path.Combine(userDataPath, "profile" + MimeTypes.ToExtension(mimeType)));
|
||||
|
||||
await _providerManager
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
<Compile Include="..\SharedVersion.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Library" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Jellyfin.Data.Entities;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MetadataProvider = MediaBrowser.Model.Entities.MetadataProvider;
|
||||
using Movie = MediaBrowser.Controller.Entities.Movies.Movie;
|
||||
|
||||
namespace MediaBrowser.Api.Movies
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MoviesService
|
||||
/// </summary>
|
||||
[Authenticated]
|
||||
public class MoviesService : BaseApiService
|
||||
{
|
||||
/// <summary>
|
||||
/// The _user manager
|
||||
/// </summary>
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly ILibraryManager _libraryManager;
|
||||
private readonly IDtoService _dtoService;
|
||||
private readonly IAuthorizationContext _authContext;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="MoviesService" /> class.
|
||||
/// </summary>
|
||||
public MoviesService(
|
||||
ILogger<MoviesService> logger,
|
||||
IServerConfigurationManager serverConfigurationManager,
|
||||
IHttpResultFactory httpResultFactory,
|
||||
IUserManager userManager,
|
||||
ILibraryManager libraryManager,
|
||||
IDtoService dtoService,
|
||||
IAuthorizationContext authContext)
|
||||
: base(logger, serverConfigurationManager, httpResultFactory)
|
||||
{
|
||||
_userManager = userManager;
|
||||
_libraryManager = libraryManager;
|
||||
_dtoService = dtoService;
|
||||
_authContext = authContext;
|
||||
}
|
||||
|
||||
public QueryResult<BaseItemDto> GetSimilarItemsResult(BaseGetSimilarItemsFromItem request)
|
||||
{
|
||||
var user = !request.UserId.Equals(Guid.Empty) ? _userManager.GetUserById(request.UserId) : null;
|
||||
|
||||
var item = string.IsNullOrEmpty(request.Id) ?
|
||||
(!request.UserId.Equals(Guid.Empty) ? _libraryManager.GetUserRootFolder() :
|
||||
_libraryManager.RootFolder) : _libraryManager.GetItemById(request.Id);
|
||||
|
||||
var itemTypes = new List<string> { typeof(Movie).Name };
|
||||
if (ServerConfigurationManager.Configuration.EnableExternalContentInSuggestions)
|
||||
{
|
||||
itemTypes.Add(typeof(Trailer).Name);
|
||||
itemTypes.Add(typeof(LiveTvProgram).Name);
|
||||
}
|
||||
|
||||
var dtoOptions = GetDtoOptions(_authContext, request);
|
||||
|
||||
var itemsResult = _libraryManager.GetItemList(new InternalItemsQuery(user)
|
||||
{
|
||||
Limit = request.Limit,
|
||||
IncludeItemTypes = itemTypes.ToArray(),
|
||||
IsMovie = true,
|
||||
SimilarTo = item,
|
||||
EnableGroupByMetadataKey = true,
|
||||
DtoOptions = dtoOptions
|
||||
|
||||
});
|
||||
|
||||
var returnList = _dtoService.GetBaseItemDtos(itemsResult, dtoOptions, user);
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
{
|
||||
Items = returnList,
|
||||
|
||||
TotalRecordCount = itemsResult.Count
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseStreamingService
|
||||
/// Class BaseStreamingService.
|
||||
/// </summary>
|
||||
public abstract class BaseStreamingService : BaseApiService
|
||||
{
|
||||
@@ -216,7 +216,7 @@ namespace MediaBrowser.Api.Playback
|
||||
UseShellExecute = false,
|
||||
|
||||
// Must consume both stdout and stderr or deadlocks may occur
|
||||
//RedirectStandardOutput = true,
|
||||
// RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
RedirectStandardInput = true,
|
||||
|
||||
@@ -303,6 +303,7 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
StartThrottler(state, transcodingJob);
|
||||
}
|
||||
|
||||
Logger.LogDebug("StartFfMpeg() finished successfully");
|
||||
|
||||
return transcodingJob;
|
||||
@@ -608,6 +609,7 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
throw new ArgumentException("Invalid timeseek header");
|
||||
}
|
||||
|
||||
int index = value.IndexOf('-');
|
||||
value = index == -1
|
||||
? value.Substring(Npt.Length)
|
||||
@@ -639,8 +641,10 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
throw new ArgumentException("Invalid timeseek header");
|
||||
}
|
||||
|
||||
timeFactor /= 60;
|
||||
}
|
||||
|
||||
return TimeSpan.FromSeconds(secondsSum).Ticks;
|
||||
}
|
||||
|
||||
@@ -685,7 +689,7 @@ namespace MediaBrowser.Api.Playback
|
||||
state.User = UserManager.GetUserById(auth.UserId);
|
||||
}
|
||||
|
||||
//if ((Request.UserAgent ?? string.Empty).IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
// if ((Request.UserAgent ?? string.Empty).IndexOf("iphone", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
// (Request.UserAgent ?? string.Empty).IndexOf("ipad", StringComparison.OrdinalIgnoreCase) != -1 ||
|
||||
// (Request.UserAgent ?? string.Empty).IndexOf("ipod", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
//{
|
||||
@@ -716,9 +720,9 @@ namespace MediaBrowser.Api.Playback
|
||||
|
||||
state.IsInputVideo = string.Equals(item.MediaType, MediaType.Video, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
//var primaryImage = item.GetImageInfo(ImageType.Primary, 0) ??
|
||||
// var primaryImage = item.GetImageInfo(ImageType.Primary, 0) ??
|
||||
// item.Parents.Select(i => i.GetImageInfo(ImageType.Primary, 0)).FirstOrDefault(i => i != null);
|
||||
//if (primaryImage != null)
|
||||
// if (primaryImage != null)
|
||||
//{
|
||||
// state.AlbumCoverPath = primaryImage.Path;
|
||||
//}
|
||||
@@ -885,7 +889,7 @@ namespace MediaBrowser.Api.Playback
|
||||
if (transcodingProfile != null)
|
||||
{
|
||||
state.EstimateContentLength = transcodingProfile.EstimateContentLength;
|
||||
//state.EnableMpegtsM2TsMode = transcodingProfile.EnableMpegtsM2TsMode;
|
||||
// state.EnableMpegtsM2TsMode = transcodingProfile.EnableMpegtsM2TsMode;
|
||||
state.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;
|
||||
|
||||
if (state.VideoRequest != null)
|
||||
|
||||
@@ -20,7 +20,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseHlsService
|
||||
/// Class BaseHlsService.
|
||||
/// </summary>
|
||||
public abstract class BaseHlsService : BaseStreamingService
|
||||
{
|
||||
@@ -146,6 +146,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
ApiEntryPoint.Instance.OnTranscodeEndRequest(job);
|
||||
}
|
||||
|
||||
return ResultFactory.GetResult(GetLivePlaylistText(playlist, state.SegmentLength), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
|
||||
}
|
||||
|
||||
@@ -178,7 +179,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
var newDuration = "#EXT-X-TARGETDURATION:" + segmentLength.ToString(CultureInfo.InvariantCulture);
|
||||
|
||||
text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength - 1).ToString(CultureInfo.InvariantCulture), newDuration, StringComparison.OrdinalIgnoreCase);
|
||||
//text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength + 1).ToString(CultureInfo.InvariantCulture), newDuration, StringComparison.OrdinalIgnoreCase);
|
||||
// text = text.Replace("#EXT-X-TARGETDURATION:" + (segmentLength + 1).ToString(CultureInfo.InvariantCulture), newDuration, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -234,6 +234,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
Logger.LogDebug("Starting transcoding because segmentGap is {0} and max allowed gap is {1}. requestedIndex={2}", requestedIndex - currentTranscodingIndex.Value, segmentGapRequiringTranscodingChange, requestedIndex);
|
||||
startTranscoding = true;
|
||||
}
|
||||
|
||||
if (startTranscoding)
|
||||
{
|
||||
// If the playlist doesn't already exist, startup ffmpeg
|
||||
@@ -257,7 +258,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
throw;
|
||||
}
|
||||
|
||||
//await WaitForMinimumSegmentCount(playlistPath, 1, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
// await WaitForMinimumSegmentCount(playlistPath, 1, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -277,8 +278,8 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
}
|
||||
}
|
||||
|
||||
//Logger.LogInformation("waiting for {0}", segmentPath);
|
||||
//while (!File.Exists(segmentPath))
|
||||
// Logger.LogInformation("waiting for {0}", segmentPath);
|
||||
// while (!File.Exists(segmentPath))
|
||||
//{
|
||||
// await Task.Delay(50, cancellationToken).ConfigureAwait(false);
|
||||
//}
|
||||
@@ -518,6 +519,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
Logger.LogDebug("serving {0} as it's on disk and transcoding stopped", segmentPath);
|
||||
}
|
||||
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
}
|
||||
else
|
||||
@@ -717,7 +719,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
|
||||
// Having problems in android
|
||||
return false;
|
||||
//return state.VideoRequest.VideoBitRate.HasValue;
|
||||
// return state.VideoRequest.VideoBitRate.HasValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -972,7 +974,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
var queryStringIndex = Request.RawUrl.IndexOf('?');
|
||||
var queryString = queryStringIndex == -1 ? string.Empty : Request.RawUrl.Substring(queryStringIndex);
|
||||
|
||||
//if ((Request.UserAgent ?? string.Empty).IndexOf("roku", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
// if ((Request.UserAgent ?? string.Empty).IndexOf("roku", StringComparison.OrdinalIgnoreCase) != -1)
|
||||
//{
|
||||
// queryString = string.Empty;
|
||||
//}
|
||||
@@ -1100,7 +1102,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
}
|
||||
}
|
||||
|
||||
//args += " -flags -global_header";
|
||||
// args += " -flags -global_header";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1142,7 +1144,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
args += " " + keyFrameArg + gopArg;
|
||||
}
|
||||
|
||||
//args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
|
||||
// args += " -mixed-refs 0 -refs 3 -x264opts b_pyramid=0:weightb=0:weightp=0";
|
||||
|
||||
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream && state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode;
|
||||
|
||||
@@ -1164,7 +1166,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
args += " -start_at_zero";
|
||||
}
|
||||
|
||||
//args += " -flags -global_header";
|
||||
// args += " -flags -global_header";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(state.OutputVideoSync))
|
||||
|
||||
@@ -13,7 +13,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Playback.Hls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GetHlsAudioSegment
|
||||
/// Class GetHlsAudioSegment.
|
||||
/// </summary>
|
||||
// Can't require authentication just yet due to seeing some requests come from Chrome without full query string
|
||||
//[Authenticated]
|
||||
@@ -37,7 +37,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetHlsVideoSegment
|
||||
/// Class GetHlsVideoSegment.
|
||||
/// </summary>
|
||||
[Route("/Videos/{Id}/hls/{PlaylistId}/stream.m3u8", "GET")]
|
||||
[Authenticated]
|
||||
@@ -66,7 +66,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetHlsVideoSegment
|
||||
/// Class GetHlsVideoSegment.
|
||||
/// </summary>
|
||||
// Can't require authentication just yet due to seeing some requests come from Chrome without full query string
|
||||
//[Authenticated]
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace MediaBrowser.Api.Playback.Hls
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class VideoHlsService
|
||||
/// Class VideoHlsService.
|
||||
/// </summary>
|
||||
[Authenticated]
|
||||
public class VideoHlsService : BaseHlsService
|
||||
|
||||
@@ -546,10 +546,12 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
mediaSource.TranscodingUrl += "&allowVideoStreamCopy=false";
|
||||
}
|
||||
|
||||
if (!allowAudioStreamCopy)
|
||||
{
|
||||
mediaSource.TranscodingUrl += "&allowAudioStreamCopy=false";
|
||||
}
|
||||
|
||||
mediaSource.TranscodingContainer = streamInfo.Container;
|
||||
mediaSource.TranscodingSubProtocol = streamInfo.SubProtocol;
|
||||
}
|
||||
@@ -641,7 +643,6 @@ namespace MediaBrowser.Api.Playback
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}).ThenBy(i =>
|
||||
{
|
||||
// Let's assume direct streaming a file is just as desirable as direct playing a remote url
|
||||
@@ -651,7 +652,6 @@ namespace MediaBrowser.Api.Playback
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}).ThenBy(i =>
|
||||
{
|
||||
return i.Protocol switch
|
||||
@@ -667,7 +667,6 @@ namespace MediaBrowser.Api.Playback
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
}).ThenBy(originalList.IndexOf)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GetAudioStream
|
||||
/// Class GetAudioStream.
|
||||
/// </summary>
|
||||
[Route("/Audio/{Id}/stream.{Container}", "GET", Summary = "Gets an audio stream")]
|
||||
[Route("/Audio/{Id}/stream", "GET", Summary = "Gets an audio stream")]
|
||||
@@ -26,7 +26,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class AudioService
|
||||
/// Class AudioService.
|
||||
/// </summary>
|
||||
// TODO: In order to autheneticate this in the future, Dlna playback will require updating
|
||||
//[Authenticated]
|
||||
|
||||
@@ -21,7 +21,7 @@ using Microsoft.Net.Http.Headers;
|
||||
namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseProgressiveStreamingService
|
||||
/// Class BaseProgressiveStreamingService.
|
||||
/// </summary>
|
||||
public abstract class BaseProgressiveStreamingService : BaseStreamingService
|
||||
{
|
||||
@@ -88,14 +88,17 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
return ".ts";
|
||||
}
|
||||
|
||||
if (string.Equals(videoCodec, "theora", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".ogv";
|
||||
}
|
||||
|
||||
if (string.Equals(videoCodec, "vpx", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".webm";
|
||||
}
|
||||
|
||||
if (string.Equals(videoCodec, "wmv", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".asf";
|
||||
@@ -111,14 +114,17 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
return ".aac";
|
||||
}
|
||||
|
||||
if (string.Equals("mp3", audioCodec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".mp3";
|
||||
}
|
||||
|
||||
if (string.Equals("vorbis", audioCodec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".ogg";
|
||||
}
|
||||
|
||||
if (string.Equals("wma", audioCodec, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ".wma";
|
||||
@@ -231,7 +237,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
}
|
||||
|
||||
//// Not static but transcode cache file exists
|
||||
//if (isTranscodeCached && state.VideoRequest == null)
|
||||
// if (isTranscodeCached && state.VideoRequest == null)
|
||||
//{
|
||||
// var contentType = state.GetMimeType(outputPath);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
|
||||
private long _bytesWritten = 0;
|
||||
public long StartPosition { get; set; }
|
||||
|
||||
public bool AllowEndOfFile = true;
|
||||
|
||||
private readonly IDirectStreamProvider _directStreamProvider;
|
||||
@@ -96,8 +97,8 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
bytesRead = await CopyToInternalAsyncWithSyncRead(inputStream, outputStream, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
//var position = fs.Position;
|
||||
//_logger.LogDebug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
|
||||
// var position = fs.Position;
|
||||
// _logger.LogDebug("Streamed {0} bytes to position {1} from file {2}", bytesRead, position, path);
|
||||
|
||||
if (bytesRead == 0)
|
||||
{
|
||||
@@ -105,6 +106,7 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
eofCount++;
|
||||
}
|
||||
|
||||
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Playback.Progressive
|
||||
{
|
||||
/// <summary>
|
||||
/// Class GetVideoStream
|
||||
/// Class GetVideoStream.
|
||||
/// </summary>
|
||||
[Route("/Videos/{Id}/stream.mpegts", "GET")]
|
||||
[Route("/Videos/{Id}/stream.ts", "GET")]
|
||||
@@ -59,11 +59,10 @@ namespace MediaBrowser.Api.Playback.Progressive
|
||||
[Route("/Videos/{Id}/stream", "HEAD")]
|
||||
public class GetVideoStream : VideoStreamRequest
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class VideoService
|
||||
/// Class VideoService.
|
||||
/// </summary>
|
||||
// TODO: In order to autheneticate this in the future, Dlna playback will require updating
|
||||
//[Authenticated]
|
||||
|
||||
@@ -8,17 +8,17 @@ using MediaBrowser.Model.Services;
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
/// <summary>
|
||||
/// Class StaticRemoteStreamWriter
|
||||
/// Class StaticRemoteStreamWriter.
|
||||
/// </summary>
|
||||
public class StaticRemoteStreamWriter : IAsyncStreamWriter, IHasHeaders
|
||||
{
|
||||
/// <summary>
|
||||
/// The _input stream
|
||||
/// The _input stream.
|
||||
/// </summary>
|
||||
private readonly HttpResponseInfo _response;
|
||||
|
||||
/// <summary>
|
||||
/// The _options
|
||||
/// The _options.
|
||||
/// </summary>
|
||||
private readonly IDictionary<string, string> _options = new Dictionary<string, string>();
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using MediaBrowser.Model.Services;
|
||||
namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
/// <summary>
|
||||
/// Class StreamRequest
|
||||
/// Class StreamRequest.
|
||||
/// </summary>
|
||||
public class StreamRequest : BaseEncodingJobOptions
|
||||
{
|
||||
@@ -12,11 +12,15 @@ namespace MediaBrowser.Api.Playback
|
||||
public string DeviceProfileId { get; set; }
|
||||
|
||||
public string Params { get; set; }
|
||||
|
||||
public string PlaySessionId { get; set; }
|
||||
|
||||
public string Tag { get; set; }
|
||||
|
||||
public string SegmentContainer { get; set; }
|
||||
|
||||
public int? SegmentLength { get; set; }
|
||||
|
||||
public int? MinSegments { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -37,10 +37,13 @@ namespace MediaBrowser.Api.Playback
|
||||
public string DeviceId { get; set; }
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public string AudioCodec { get; set; }
|
||||
|
||||
public string Container { get; set; }
|
||||
|
||||
public int? MaxAudioChannels { get; set; }
|
||||
|
||||
public int? TranscodingAudioChannels { get; set; }
|
||||
|
||||
public long? MaxStreamingBitrate { get; set; }
|
||||
@@ -49,12 +52,17 @@ namespace MediaBrowser.Api.Playback
|
||||
public long? StartTimeTicks { get; set; }
|
||||
|
||||
public string TranscodingContainer { get; set; }
|
||||
|
||||
public string TranscodingProtocol { get; set; }
|
||||
|
||||
public int? MaxAudioSampleRate { get; set; }
|
||||
|
||||
public int? MaxAudioBitDepth { get; set; }
|
||||
|
||||
public bool EnableRedirection { get; set; }
|
||||
|
||||
public bool EnableRemoteMedia { get; set; }
|
||||
|
||||
public bool BreakOnNonKeyFrames { get; set; }
|
||||
|
||||
public BaseUniversalRequest()
|
||||
@@ -114,16 +122,27 @@ namespace MediaBrowser.Api.Playback
|
||||
}
|
||||
|
||||
protected IHttpClient HttpClient { get; private set; }
|
||||
|
||||
protected IUserManager UserManager { get; private set; }
|
||||
|
||||
protected ILibraryManager LibraryManager { get; private set; }
|
||||
|
||||
protected IIsoManager IsoManager { get; private set; }
|
||||
|
||||
protected IMediaEncoder MediaEncoder { get; private set; }
|
||||
|
||||
protected IFileSystem FileSystem { get; private set; }
|
||||
|
||||
protected IDlnaManager DlnaManager { get; private set; }
|
||||
|
||||
protected IDeviceManager DeviceManager { get; private set; }
|
||||
|
||||
protected IMediaSourceManager MediaSourceManager { get; private set; }
|
||||
|
||||
protected IJsonSerializer JsonSerializer { get; private set; }
|
||||
|
||||
protected IAuthorizationContext AuthorizationContext { get; private set; }
|
||||
|
||||
protected INetworkManager NetworkManager { get; private set; }
|
||||
|
||||
public Task<object> Get(GetUniversalAudioStream request)
|
||||
@@ -259,7 +278,6 @@ namespace MediaBrowser.Api.Playback
|
||||
UserId = request.UserId,
|
||||
DeviceProfile = deviceProfile,
|
||||
MediaSourceId = request.MediaSourceId
|
||||
|
||||
}).ConfigureAwait(false);
|
||||
|
||||
var mediaSource = playbackInfoResult.MediaSources[0];
|
||||
@@ -329,6 +347,7 @@ namespace MediaBrowser.Api.Playback
|
||||
{
|
||||
return await service.Head(newRequest).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return await service.Get(newRequest).ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.ScheduledTasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class ScheduledTasksWebSocketListener
|
||||
/// Class ScheduledTasksWebSocketListener.
|
||||
/// </summary>
|
||||
public class ScheduledTasksWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<TaskInfo>, WebSocketListenerState>
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.Sessions
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SessionInfoWebSocketListener
|
||||
/// Class SessionInfoWebSocketListener.
|
||||
/// </summary>
|
||||
public class SessionInfoWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<SessionInfo>, WebSocketListenerState>
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace MediaBrowser.Api.Sessions
|
||||
protected override string Name => "Sessions";
|
||||
|
||||
/// <summary>
|
||||
/// The _kernel
|
||||
/// The _kernel.
|
||||
/// </summary>
|
||||
private readonly ISessionManager _sessionManager;
|
||||
|
||||
|
||||
@@ -1,223 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseGetSimilarItemsFromItem
|
||||
/// </summary>
|
||||
public class BaseGetSimilarItemsFromItem : BaseGetSimilarItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the id.
|
||||
/// </summary>
|
||||
/// <value>The id.</value>
|
||||
[ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
|
||||
public string Id { get; set; }
|
||||
|
||||
public string ExcludeArtistIds { get; set; }
|
||||
}
|
||||
|
||||
public class BaseGetSimilarItems : IReturn<QueryResult<BaseItemDto>>, IHasDtoOptions
|
||||
{
|
||||
[ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
|
||||
public bool? EnableImages { get; set; }
|
||||
|
||||
[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
|
||||
public bool? EnableUserData { get; set; }
|
||||
|
||||
[ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? ImageTypeLimit { get; set; }
|
||||
|
||||
[ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string EnableImageTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "Optional. Filter by user id, and attach user data", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of items to return
|
||||
/// </summary>
|
||||
/// <value>The limit.</value>
|
||||
[ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? Limit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fields to return within the items, in addition to basic information
|
||||
/// </summary>
|
||||
/// <value>The fields.</value>
|
||||
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines, TrailerUrls", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Fields { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class SimilarItemsHelper
|
||||
/// </summary>
|
||||
public static class SimilarItemsHelper
|
||||
{
|
||||
internal static QueryResult<BaseItemDto> GetSimilarItemsResult(DtoOptions dtoOptions, IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataManager userDataRepository, IDtoService dtoService, BaseGetSimilarItemsFromItem request, Type[] includeTypes, Func<BaseItem, List<PersonInfo>, List<PersonInfo>, BaseItem, int> getSimilarityScore)
|
||||
{
|
||||
var user = !request.UserId.Equals(Guid.Empty) ? userManager.GetUserById(request.UserId) : null;
|
||||
|
||||
var item = string.IsNullOrEmpty(request.Id) ?
|
||||
(!request.UserId.Equals(Guid.Empty) ? libraryManager.GetUserRootFolder() :
|
||||
libraryManager.RootFolder) : libraryManager.GetItemById(request.Id);
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
{
|
||||
IncludeItemTypes = includeTypes.Select(i => i.Name).ToArray(),
|
||||
Recursive = true,
|
||||
DtoOptions = dtoOptions
|
||||
};
|
||||
|
||||
// ExcludeArtistIds
|
||||
if (!string.IsNullOrEmpty(request.ExcludeArtistIds))
|
||||
{
|
||||
query.ExcludeArtistIds = BaseApiService.GetGuids(request.ExcludeArtistIds);
|
||||
}
|
||||
|
||||
var inputItems = libraryManager.GetItemList(query);
|
||||
|
||||
var items = GetSimilaritems(item, libraryManager, inputItems, getSimilarityScore)
|
||||
.ToList();
|
||||
|
||||
var returnItems = items;
|
||||
|
||||
if (request.Limit.HasValue)
|
||||
{
|
||||
returnItems = returnItems.Take(request.Limit.Value).ToList();
|
||||
}
|
||||
|
||||
var dtos = dtoService.GetBaseItemDtos(returnItems, dtoOptions, user);
|
||||
|
||||
return new QueryResult<BaseItemDto>
|
||||
{
|
||||
Items = dtos,
|
||||
|
||||
TotalRecordCount = items.Count
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the similaritems.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="inputItems">The input items.</param>
|
||||
/// <param name="getSimilarityScore">The get similarity score.</param>
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
internal static IEnumerable<BaseItem> GetSimilaritems(BaseItem item, ILibraryManager libraryManager, IEnumerable<BaseItem> inputItems, Func<BaseItem, List<PersonInfo>, List<PersonInfo>, BaseItem, int> getSimilarityScore)
|
||||
{
|
||||
var itemId = item.Id;
|
||||
inputItems = inputItems.Where(i => i.Id != itemId);
|
||||
var itemPeople = libraryManager.GetPeople(item);
|
||||
var allPeople = libraryManager.GetPeople(new InternalPeopleQuery
|
||||
{
|
||||
AppearsInItemId = item.Id
|
||||
});
|
||||
|
||||
return inputItems.Select(i => new Tuple<BaseItem, int>(i, getSimilarityScore(item, itemPeople, allPeople, i)))
|
||||
.Where(i => i.Item2 > 2)
|
||||
.OrderByDescending(i => i.Item2)
|
||||
.Select(i => i.Item1);
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetTags(BaseItem item)
|
||||
{
|
||||
return item.Tags;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the similiarity score.
|
||||
/// </summary>
|
||||
/// <param name="item1">The item1.</param>
|
||||
/// <param name="item1People">The item1 people.</param>
|
||||
/// <param name="allPeople">All people.</param>
|
||||
/// <param name="item2">The item2.</param>
|
||||
/// <returns>System.Int32.</returns>
|
||||
internal static int GetSimiliarityScore(BaseItem item1, List<PersonInfo> item1People, List<PersonInfo> allPeople, BaseItem item2)
|
||||
{
|
||||
var points = 0;
|
||||
|
||||
if (!string.IsNullOrEmpty(item1.OfficialRating) && string.Equals(item1.OfficialRating, item2.OfficialRating, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
points += 10;
|
||||
}
|
||||
|
||||
// Find common genres
|
||||
points += item1.Genres.Where(i => item2.Genres.Contains(i, StringComparer.OrdinalIgnoreCase)).Sum(i => 10);
|
||||
|
||||
// Find common tags
|
||||
points += GetTags(item1).Where(i => GetTags(item2).Contains(i, StringComparer.OrdinalIgnoreCase)).Sum(i => 10);
|
||||
|
||||
// Find common studios
|
||||
points += item1.Studios.Where(i => item2.Studios.Contains(i, StringComparer.OrdinalIgnoreCase)).Sum(i => 3);
|
||||
|
||||
var item2PeopleNames = allPeople.Where(i => i.ItemId == item2.Id)
|
||||
.Select(i => i.Name)
|
||||
.Where(i => !string.IsNullOrWhiteSpace(i))
|
||||
.DistinctNames()
|
||||
.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
points += item1People.Where(i => item2PeopleNames.ContainsKey(i.Name)).Sum(i =>
|
||||
{
|
||||
if (string.Equals(i.Type, PersonType.Director, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.Director, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
if (string.Equals(i.Type, PersonType.Actor, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.Actor, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (string.Equals(i.Type, PersonType.Composer, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.Composer, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (string.Equals(i.Type, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.GuestStar, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if (string.Equals(i.Type, PersonType.Writer, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Role, PersonType.Writer, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
if (item1.ProductionYear.HasValue && item2.ProductionYear.HasValue)
|
||||
{
|
||||
var diff = Math.Abs(item1.ProductionYear.Value - item2.ProductionYear.Value);
|
||||
|
||||
// Add if they came out within the same decade
|
||||
if (diff < 10)
|
||||
{
|
||||
points += 2;
|
||||
}
|
||||
|
||||
// And more if within five years
|
||||
if (diff < 5)
|
||||
{
|
||||
points += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace MediaBrowser.Api.System
|
||||
{
|
||||
/// <summary>
|
||||
/// Class SessionInfoWebSocketListener
|
||||
/// Class SessionInfoWebSocketListener.
|
||||
/// </summary>
|
||||
public class ActivityLogWebSocketListener : BasePeriodicWebSocketListener<ActivityLogEntry[], WebSocketListenerState>
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace MediaBrowser.Api.System
|
||||
protected override string Name => "ActivityLogEntry";
|
||||
|
||||
/// <summary>
|
||||
/// The _kernel
|
||||
/// The _kernel.
|
||||
/// </summary>
|
||||
private readonly IActivityManager _activityManager;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace MediaBrowser.Api
|
||||
/// </summary>
|
||||
/// <value>The path.</value>
|
||||
public MediaSourceInfo MediaSource { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the type.
|
||||
@@ -43,6 +44,7 @@ namespace MediaBrowser.Api
|
||||
/// </summary>
|
||||
/// <value>The process.</value>
|
||||
public Process Process { get; set; }
|
||||
|
||||
public ILogger Logger { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the active request count.
|
||||
@@ -62,18 +64,23 @@ namespace MediaBrowser.Api
|
||||
public object ProcessLock = new object();
|
||||
|
||||
public bool HasExited { get; set; }
|
||||
|
||||
public bool IsUserPaused { get; set; }
|
||||
|
||||
public string Id { get; set; }
|
||||
|
||||
public float? Framerate { get; set; }
|
||||
|
||||
public double? CompletionPercentage { get; set; }
|
||||
|
||||
public long? BytesDownloaded { get; set; }
|
||||
|
||||
public long? BytesTranscoded { get; set; }
|
||||
|
||||
public int? BitRate { get; set; }
|
||||
|
||||
public long? TranscodingPositionTicks { get; set; }
|
||||
|
||||
public long? DownloadPositionTicks { get; set; }
|
||||
|
||||
public TranscodingThrottler TranscodingThrottler { get; set; }
|
||||
@@ -81,6 +88,7 @@ namespace MediaBrowser.Api
|
||||
private readonly object _timerLock = new object();
|
||||
|
||||
public DateTime LastPingDate { get; set; }
|
||||
|
||||
public int PingTimeout { get; set; }
|
||||
|
||||
public TranscodingJob(ILogger logger)
|
||||
|
||||
@@ -1,388 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Jellyfin.Data.Entities;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
using MediaBrowser.Controller.Dto;
|
||||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Net;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
/// <summary>
|
||||
/// Class BaseItemsByNameService
|
||||
/// </summary>
|
||||
/// <typeparam name="TItemType">The type of the T item type.</typeparam>
|
||||
public abstract class BaseItemsByNameService<TItemType> : BaseApiService
|
||||
where TItemType : BaseItem, IItemByName
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="BaseItemsByNameService{TItemType}" /> class.
|
||||
/// </summary>
|
||||
/// <param name="userManager">The user manager.</param>
|
||||
/// <param name="libraryManager">The library manager.</param>
|
||||
/// <param name="userDataRepository">The user data repository.</param>
|
||||
/// <param name="dtoService">The dto service.</param>
|
||||
protected BaseItemsByNameService(
|
||||
ILogger<BaseItemsByNameService<TItemType>> logger,
|
||||
IServerConfigurationManager serverConfigurationManager,
|
||||
IHttpResultFactory httpResultFactory,
|
||||
IUserManager userManager,
|
||||
ILibraryManager libraryManager,
|
||||
IUserDataManager userDataRepository,
|
||||
IDtoService dtoService,
|
||||
IAuthorizationContext authorizationContext)
|
||||
: base(logger, serverConfigurationManager, httpResultFactory)
|
||||
{
|
||||
UserManager = userManager;
|
||||
LibraryManager = libraryManager;
|
||||
UserDataRepository = userDataRepository;
|
||||
DtoService = dtoService;
|
||||
AuthorizationContext = authorizationContext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the _user manager.
|
||||
/// </summary>
|
||||
protected IUserManager UserManager { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the library manager
|
||||
/// </summary>
|
||||
protected ILibraryManager LibraryManager { get; }
|
||||
|
||||
protected IUserDataManager UserDataRepository { get; }
|
||||
|
||||
protected IDtoService DtoService { get; }
|
||||
|
||||
protected IAuthorizationContext AuthorizationContext { get; }
|
||||
|
||||
protected BaseItem GetParentItem(GetItemsByName request)
|
||||
{
|
||||
BaseItem parentItem;
|
||||
|
||||
if (!request.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
var user = UserManager.GetUserById(request.UserId);
|
||||
parentItem = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.GetUserRootFolder() : LibraryManager.GetItemById(request.ParentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.RootFolder : LibraryManager.GetItemById(request.ParentId);
|
||||
}
|
||||
|
||||
return parentItem;
|
||||
}
|
||||
|
||||
protected string GetParentItemViewType(GetItemsByName request)
|
||||
{
|
||||
var parent = GetParentItem(request);
|
||||
|
||||
if (parent is IHasCollectionType collectionFolder)
|
||||
{
|
||||
return collectionFolder.CollectionType;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected QueryResult<BaseItemDto> GetResultSlim(GetItemsByName request)
|
||||
{
|
||||
var dtoOptions = GetDtoOptions(AuthorizationContext, request);
|
||||
|
||||
User user = null;
|
||||
BaseItem parentItem;
|
||||
|
||||
if (!request.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
user = UserManager.GetUserById(request.UserId);
|
||||
parentItem = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.GetUserRootFolder() : LibraryManager.GetItemById(request.ParentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.RootFolder : LibraryManager.GetItemById(request.ParentId);
|
||||
}
|
||||
|
||||
var excludeItemTypes = request.GetExcludeItemTypes();
|
||||
var includeItemTypes = request.GetIncludeItemTypes();
|
||||
var mediaTypes = request.GetMediaTypes();
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
{
|
||||
ExcludeItemTypes = excludeItemTypes,
|
||||
IncludeItemTypes = includeItemTypes,
|
||||
MediaTypes = mediaTypes,
|
||||
StartIndex = request.StartIndex,
|
||||
Limit = request.Limit,
|
||||
IsFavorite = request.IsFavorite,
|
||||
NameLessThan = request.NameLessThan,
|
||||
NameStartsWith = request.NameStartsWith,
|
||||
NameStartsWithOrGreater = request.NameStartsWithOrGreater,
|
||||
Tags = request.GetTags(),
|
||||
OfficialRatings = request.GetOfficialRatings(),
|
||||
Genres = request.GetGenres(),
|
||||
GenreIds = GetGuids(request.GenreIds),
|
||||
StudioIds = GetGuids(request.StudioIds),
|
||||
Person = request.Person,
|
||||
PersonIds = GetGuids(request.PersonIds),
|
||||
PersonTypes = request.GetPersonTypes(),
|
||||
Years = request.GetYears(),
|
||||
MinCommunityRating = request.MinCommunityRating,
|
||||
DtoOptions = dtoOptions,
|
||||
SearchTerm = request.SearchTerm,
|
||||
EnableTotalRecordCount = request.EnableTotalRecordCount
|
||||
};
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.ParentId))
|
||||
{
|
||||
if (parentItem is Folder)
|
||||
{
|
||||
query.AncestorIds = new[] { new Guid(request.ParentId) };
|
||||
}
|
||||
else
|
||||
{
|
||||
query.ItemIds = new[] { new Guid(request.ParentId) };
|
||||
}
|
||||
}
|
||||
|
||||
// Studios
|
||||
if (!string.IsNullOrEmpty(request.Studios))
|
||||
{
|
||||
query.StudioIds = request.Studios.Split('|').Select(i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
return LibraryManager.GetStudio(i);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}).Where(i => i != null).Select(i => i.Id).ToArray();
|
||||
}
|
||||
|
||||
foreach (var filter in request.GetFilters())
|
||||
{
|
||||
switch (filter)
|
||||
{
|
||||
case ItemFilter.Dislikes:
|
||||
query.IsLiked = false;
|
||||
break;
|
||||
case ItemFilter.IsFavorite:
|
||||
query.IsFavorite = true;
|
||||
break;
|
||||
case ItemFilter.IsFavoriteOrLikes:
|
||||
query.IsFavoriteOrLiked = true;
|
||||
break;
|
||||
case ItemFilter.IsFolder:
|
||||
query.IsFolder = true;
|
||||
break;
|
||||
case ItemFilter.IsNotFolder:
|
||||
query.IsFolder = false;
|
||||
break;
|
||||
case ItemFilter.IsPlayed:
|
||||
query.IsPlayed = true;
|
||||
break;
|
||||
case ItemFilter.IsResumable:
|
||||
query.IsResumable = true;
|
||||
break;
|
||||
case ItemFilter.IsUnplayed:
|
||||
query.IsPlayed = false;
|
||||
break;
|
||||
case ItemFilter.Likes:
|
||||
query.IsLiked = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var result = GetItems(request, query);
|
||||
|
||||
var dtos = result.Items.Select(i =>
|
||||
{
|
||||
var dto = DtoService.GetItemByNameDto(i.Item1, dtoOptions, null, user);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(request.IncludeItemTypes))
|
||||
{
|
||||
SetItemCounts(dto, i.Item2);
|
||||
}
|
||||
return dto;
|
||||
});
|
||||
|
||||
return new QueryResult<BaseItemDto>
|
||||
{
|
||||
Items = dtos.ToArray(),
|
||||
TotalRecordCount = result.TotalRecordCount
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual QueryResult<(BaseItem, ItemCounts)> GetItems(GetItemsByName request, InternalItemsQuery query)
|
||||
{
|
||||
return new QueryResult<(BaseItem, ItemCounts)>();
|
||||
}
|
||||
|
||||
private void SetItemCounts(BaseItemDto dto, ItemCounts counts)
|
||||
{
|
||||
dto.ChildCount = counts.ItemCount;
|
||||
dto.ProgramCount = counts.ProgramCount;
|
||||
dto.SeriesCount = counts.SeriesCount;
|
||||
dto.EpisodeCount = counts.EpisodeCount;
|
||||
dto.MovieCount = counts.MovieCount;
|
||||
dto.TrailerCount = counts.TrailerCount;
|
||||
dto.AlbumCount = counts.AlbumCount;
|
||||
dto.SongCount = counts.SongCount;
|
||||
dto.ArtistCount = counts.ArtistCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <returns>Task{ItemsResult}.</returns>
|
||||
protected QueryResult<BaseItemDto> GetResult(GetItemsByName request)
|
||||
{
|
||||
var dtoOptions = GetDtoOptions(AuthorizationContext, request);
|
||||
|
||||
User user = null;
|
||||
BaseItem parentItem;
|
||||
|
||||
if (!request.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
user = UserManager.GetUserById(request.UserId);
|
||||
parentItem = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.GetUserRootFolder() : LibraryManager.GetItemById(request.ParentId);
|
||||
}
|
||||
else
|
||||
{
|
||||
parentItem = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.RootFolder : LibraryManager.GetItemById(request.ParentId);
|
||||
}
|
||||
|
||||
IList<BaseItem> items;
|
||||
|
||||
var excludeItemTypes = request.GetExcludeItemTypes();
|
||||
var includeItemTypes = request.GetIncludeItemTypes();
|
||||
var mediaTypes = request.GetMediaTypes();
|
||||
|
||||
var query = new InternalItemsQuery(user)
|
||||
{
|
||||
ExcludeItemTypes = excludeItemTypes,
|
||||
IncludeItemTypes = includeItemTypes,
|
||||
MediaTypes = mediaTypes,
|
||||
DtoOptions = dtoOptions
|
||||
};
|
||||
|
||||
bool Filter(BaseItem i) => FilterItem(request, i, excludeItemTypes, includeItemTypes, mediaTypes);
|
||||
|
||||
if (parentItem.IsFolder)
|
||||
{
|
||||
var folder = (Folder)parentItem;
|
||||
|
||||
if (!request.UserId.Equals(Guid.Empty))
|
||||
{
|
||||
items = request.Recursive ?
|
||||
folder.GetRecursiveChildren(user, query).ToList() :
|
||||
folder.GetChildren(user, true).Where(Filter).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
items = request.Recursive ?
|
||||
folder.GetRecursiveChildren(Filter) :
|
||||
folder.Children.Where(Filter).ToList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
items = new[] { parentItem }.Where(Filter).ToList();
|
||||
}
|
||||
|
||||
var extractedItems = GetAllItems(request, items);
|
||||
|
||||
var filteredItems = LibraryManager.Sort(extractedItems, user, request.GetOrderBy());
|
||||
|
||||
var ibnItemsArray = filteredItems.ToList();
|
||||
|
||||
IEnumerable<BaseItem> ibnItems = ibnItemsArray;
|
||||
|
||||
var result = new QueryResult<BaseItemDto>
|
||||
{
|
||||
TotalRecordCount = ibnItemsArray.Count
|
||||
};
|
||||
|
||||
if (request.StartIndex.HasValue || request.Limit.HasValue)
|
||||
{
|
||||
if (request.StartIndex.HasValue)
|
||||
{
|
||||
ibnItems = ibnItems.Skip(request.StartIndex.Value);
|
||||
}
|
||||
|
||||
if (request.Limit.HasValue)
|
||||
{
|
||||
ibnItems = ibnItems.Take(request.Limit.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var tuples = ibnItems.Select(i => new Tuple<BaseItem, List<BaseItem>>(i, new List<BaseItem>()));
|
||||
|
||||
var dtos = tuples.Select(i => DtoService.GetItemByNameDto(i.Item1, dtoOptions, i.Item2, user));
|
||||
|
||||
result.Items = dtos.Where(i => i != null).ToArray();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Filters the items.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="f">The f.</param>
|
||||
/// <param name="excludeItemTypes">The exclude item types.</param>
|
||||
/// <param name="includeItemTypes">The include item types.</param>
|
||||
/// <param name="mediaTypes">The media types.</param>
|
||||
/// <returns>IEnumerable{BaseItem}.</returns>
|
||||
private bool FilterItem(GetItemsByName request, BaseItem f, string[] excludeItemTypes, string[] includeItemTypes, string[] mediaTypes)
|
||||
{
|
||||
// Exclude item types
|
||||
if (excludeItemTypes.Length > 0 && excludeItemTypes.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Include item types
|
||||
if (includeItemTypes.Length > 0 && !includeItemTypes.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Include MediaTypes
|
||||
if (mediaTypes.Length > 0 && !mediaTypes.Contains(f.MediaType ?? string.Empty, StringComparer.OrdinalIgnoreCase))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all items.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="items">The items.</param>
|
||||
/// <returns>IEnumerable{Task{`0}}.</returns>
|
||||
protected abstract IEnumerable<BaseItem> GetAllItems(GetItemsByName request, IList<BaseItem> items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Class GetItemsByName
|
||||
/// </summary>
|
||||
public class GetItemsByName : BaseItemsRequest, IReturn<QueryResult<BaseItemDto>>
|
||||
{
|
||||
public GetItemsByName()
|
||||
{
|
||||
Recursive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,475 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Querying;
|
||||
using MediaBrowser.Model.Services;
|
||||
|
||||
namespace MediaBrowser.Api.UserLibrary
|
||||
{
|
||||
public abstract class BaseItemsRequest : IHasDtoOptions
|
||||
{
|
||||
protected BaseItemsRequest()
|
||||
{
|
||||
EnableImages = true;
|
||||
EnableTotalRecordCount = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the max offical rating.
|
||||
/// </summary>
|
||||
/// <value>The max offical rating.</value>
|
||||
[ApiMember(Name = "MaxOfficialRating", Description = "Optional filter by maximum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MaxOfficialRating { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasThemeSong", Description = "Optional filter by items with theme songs.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasThemeSong { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasThemeVideo", Description = "Optional filter by items with theme videos.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasThemeVideo { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasSubtitles", Description = "Optional filter by items with subtitles.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasSubtitles { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasSpecialFeature", Description = "Optional filter by items with special features.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasSpecialFeature { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasTrailer", Description = "Optional filter by items with trailers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasTrailer { get; set; }
|
||||
|
||||
[ApiMember(Name = "AdjacentTo", Description = "Optional. Return items that are siblings of a supplied item.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string AdjacentTo { get; set; }
|
||||
|
||||
[ApiMember(Name = "MinIndexNumber", Description = "Optional filter by minimum index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? MinIndexNumber { get; set; }
|
||||
|
||||
[ApiMember(Name = "ParentIndexNumber", Description = "Optional filter by parent index number.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? ParentIndexNumber { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasParentalRating", Description = "Optional filter by items that have or do not have a parental rating", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasParentalRating { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsHD", Description = "Optional filter by items that are HD or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsHD { get; set; }
|
||||
|
||||
public bool? Is4K { get; set; }
|
||||
|
||||
[ApiMember(Name = "LocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string LocationTypes { get; set; }
|
||||
|
||||
[ApiMember(Name = "ExcludeLocationTypes", Description = "Optional. If specified, results will be filtered based on LocationType. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string ExcludeLocationTypes { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsMissing", Description = "Optional filter by items that are missing episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsMissing { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsUnaired", Description = "Optional filter by items that are unaired episodes or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsUnaired { get; set; }
|
||||
|
||||
[ApiMember(Name = "MinCommunityRating", Description = "Optional filter by minimum community rating.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public double? MinCommunityRating { get; set; }
|
||||
|
||||
[ApiMember(Name = "MinCriticRating", Description = "Optional filter by minimum critic rating.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public double? MinCriticRating { get; set; }
|
||||
|
||||
[ApiMember(Name = "AiredDuringSeason", Description = "Gets all episodes that aired during a season, including specials.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? AiredDuringSeason { get; set; }
|
||||
|
||||
[ApiMember(Name = "MinPremiereDate", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MinPremiereDate { get; set; }
|
||||
|
||||
[ApiMember(Name = "MinDateLastSaved", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MinDateLastSaved { get; set; }
|
||||
|
||||
[ApiMember(Name = "MinDateLastSavedForUser", Description = "Optional. The minimum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MinDateLastSavedForUser { get; set; }
|
||||
|
||||
[ApiMember(Name = "MaxPremiereDate", Description = "Optional. The maximum premiere date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MaxPremiereDate { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasOverview", Description = "Optional filter by items that have an overview or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasOverview { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasImdbId", Description = "Optional filter by items that have an imdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasImdbId { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasTmdbId", Description = "Optional filter by items that have a tmdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasTmdbId { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasTvdbId", Description = "Optional filter by items that have a tvdb id or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasTvdbId { get; set; }
|
||||
|
||||
[ApiMember(Name = "ExcludeItemIds", Description = "Optional. If specified, results will be filtered by exxcluding item ids. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string ExcludeItemIds { get; set; }
|
||||
|
||||
public bool EnableTotalRecordCount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Skips over a given number of items within the results. Use for paging.
|
||||
/// </summary>
|
||||
/// <value>The start index.</value>
|
||||
[ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? StartIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The maximum number of items to return
|
||||
/// </summary>
|
||||
/// <value>The limit.</value>
|
||||
[ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? Limit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not to perform the query recursively
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if recursive; otherwise, <c>false</c>.</value>
|
||||
[ApiMember(Name = "Recursive", Description = "When searching within folders, this determines whether or not the search will be recursive. true/false", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
|
||||
public bool Recursive { get; set; }
|
||||
|
||||
public string SearchTerm { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the sort order.
|
||||
/// </summary>
|
||||
/// <value>The sort order.</value>
|
||||
[ApiMember(Name = "SortOrder", Description = "Sort Order - Ascending,Descending", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string SortOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Specify this to localize the search to a specific item or folder. Omit to use the root.
|
||||
/// </summary>
|
||||
/// <value>The parent id.</value>
|
||||
[ApiMember(Name = "ParentId", Description = "Specify this to localize the search to a specific item or folder. Omit to use the root", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fields to return within the items, in addition to basic information
|
||||
/// </summary>
|
||||
/// <value>The fields.</value>
|
||||
[ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Fields { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exclude item types.
|
||||
/// </summary>
|
||||
/// <value>The exclude item types.</value>
|
||||
[ApiMember(Name = "ExcludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string ExcludeItemTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the include item types.
|
||||
/// </summary>
|
||||
/// <value>The include item types.</value>
|
||||
[ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string IncludeItemTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Filters to apply to the results
|
||||
/// </summary>
|
||||
/// <value>The filters.</value>
|
||||
[ApiMember(Name = "Filters", Description = "Optional. Specify additional filters to apply. This allows multiple, comma delimeted. Options: IsFolder, IsNotFolder, IsUnplayed, IsPlayed, IsFavorite, IsResumable, Likes, Dislikes", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Filters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Isfavorite option
|
||||
/// </summary>
|
||||
/// <value>IsFavorite</value>
|
||||
[ApiMember(Name = "IsFavorite", Description = "Optional filter by items that are marked as favorite, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsFavorite { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the media types.
|
||||
/// </summary>
|
||||
/// <value>The media types.</value>
|
||||
[ApiMember(Name = "MediaTypes", Description = "Optional filter by MediaType. Allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string MediaTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the image types.
|
||||
/// </summary>
|
||||
/// <value>The image types.</value>
|
||||
[ApiMember(Name = "ImageTypes", Description = "Optional. If specified, results will be filtered based on those containing image types. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string ImageTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// What to sort the results by
|
||||
/// </summary>
|
||||
/// <value>The sort by.</value>
|
||||
[ApiMember(Name = "SortBy", Description = "Optional. Specify one or more sort orders, comma delimeted. Options: Album, AlbumArtist, Artist, Budget, CommunityRating, CriticRating, DateCreated, DatePlayed, PlayCount, PremiereDate, ProductionYear, SortName, Random, Revenue, Runtime", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string SortBy { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsPlayed", Description = "Optional filter by items that are played, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsPlayed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limit results to items containing specific genres
|
||||
/// </summary>
|
||||
/// <value>The genres.</value>
|
||||
[ApiMember(Name = "Genres", Description = "Optional. If specified, results will be filtered based on genre. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Genres { get; set; }
|
||||
|
||||
public string GenreIds { get; set; }
|
||||
|
||||
[ApiMember(Name = "OfficialRatings", Description = "Optional. If specified, results will be filtered based on OfficialRating. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string OfficialRatings { get; set; }
|
||||
|
||||
[ApiMember(Name = "Tags", Description = "Optional. If specified, results will be filtered based on tag. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Tags { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limit results to items containing specific years
|
||||
/// </summary>
|
||||
/// <value>The years.</value>
|
||||
[ApiMember(Name = "Years", Description = "Optional. If specified, results will be filtered based on production year. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Years { get; set; }
|
||||
|
||||
[ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
|
||||
public bool? EnableImages { get; set; }
|
||||
|
||||
[ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")]
|
||||
public bool? EnableUserData { get; set; }
|
||||
|
||||
[ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
|
||||
public int? ImageTypeLimit { get; set; }
|
||||
|
||||
[ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string EnableImageTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limit results to items containing a specific person
|
||||
/// </summary>
|
||||
/// <value>The person.</value>
|
||||
[ApiMember(Name = "Person", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string Person { get; set; }
|
||||
|
||||
[ApiMember(Name = "PersonIds", Description = "Optional. If specified, results will be filtered to include only those containing the specified person.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string PersonIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If the Person filter is used, this can also be used to restrict to a specific person type
|
||||
/// </summary>
|
||||
/// <value>The type of the person.</value>
|
||||
[ApiMember(Name = "PersonTypes", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string PersonTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Limit results to items containing specific studios
|
||||
/// </summary>
|
||||
/// <value>The studios.</value>
|
||||
[ApiMember(Name = "Studios", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Studios { get; set; }
|
||||
|
||||
[ApiMember(Name = "StudioIds", Description = "Optional. If specified, results will be filtered based on studio. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string StudioIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the studios.
|
||||
/// </summary>
|
||||
/// <value>The studios.</value>
|
||||
[ApiMember(Name = "Artists", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Artists { get; set; }
|
||||
|
||||
public string ExcludeArtistIds { get; set; }
|
||||
|
||||
[ApiMember(Name = "ArtistIds", Description = "Optional. If specified, results will be filtered based on artist. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string ArtistIds { get; set; }
|
||||
|
||||
public string AlbumArtistIds { get; set; }
|
||||
|
||||
public string ContributingArtistIds { get; set; }
|
||||
|
||||
[ApiMember(Name = "Albums", Description = "Optional. If specified, results will be filtered based on album. This allows multiple, pipe delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Albums { get; set; }
|
||||
|
||||
public string AlbumIds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item ids.
|
||||
/// </summary>
|
||||
/// <value>The item ids.</value>
|
||||
[ApiMember(Name = "Ids", Description = "Optional. If specific items are needed, specify a list of item id's to retrieve. This allows multiple, comma delimited.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string Ids { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the video types.
|
||||
/// </summary>
|
||||
/// <value>The video types.</value>
|
||||
[ApiMember(Name = "VideoTypes", Description = "Optional filter by VideoType (videofile, dvd, bluray, iso). Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string VideoTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the user id.
|
||||
/// </summary>
|
||||
/// <value>The user id.</value>
|
||||
[ApiMember(Name = "UserId", Description = "User Id", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the min offical rating.
|
||||
/// </summary>
|
||||
/// <value>The min offical rating.</value>
|
||||
[ApiMember(Name = "MinOfficialRating", Description = "Optional filter by minimum official rating (PG, PG-13, TV-MA, etc).", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string MinOfficialRating { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsLocked", Description = "Optional filter by items that are locked.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsLocked { get; set; }
|
||||
|
||||
[ApiMember(Name = "IsPlaceHolder", Description = "Optional filter by items that are placeholders", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? IsPlaceHolder { get; set; }
|
||||
|
||||
[ApiMember(Name = "HasOfficialRating", Description = "Optional filter by items that have official ratings", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public bool? HasOfficialRating { get; set; }
|
||||
|
||||
[ApiMember(Name = "CollapseBoxSetItems", Description = "Whether or not to hide items behind their boxsets.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? CollapseBoxSetItems { get; set; }
|
||||
|
||||
public int? MinWidth { get; set; }
|
||||
public int? MinHeight { get; set; }
|
||||
public int? MaxWidth { get; set; }
|
||||
public int? MaxHeight { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the video formats.
|
||||
/// </summary>
|
||||
/// <value>The video formats.</value>
|
||||
[ApiMember(Name = "Is3D", Description = "Optional filter by items that are 3D, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
|
||||
public bool? Is3D { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the series status.
|
||||
/// </summary>
|
||||
/// <value>The series status.</value>
|
||||
[ApiMember(Name = "SeriesStatus", Description = "Optional filter by Series Status. Allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
|
||||
public string SeriesStatus { get; set; }
|
||||
|
||||
[ApiMember(Name = "NameStartsWithOrGreater", Description = "Optional filter by items whose name is sorted equally or greater than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string NameStartsWithOrGreater { get; set; }
|
||||
|
||||
[ApiMember(Name = "NameStartsWith", Description = "Optional filter by items whose name is sorted equally than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string NameStartsWith { get; set; }
|
||||
|
||||
[ApiMember(Name = "NameLessThan", Description = "Optional filter by items whose name is equally or lesser than a given input string.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
|
||||
public string NameLessThan { get; set; }
|
||||
|
||||
public string[] GetGenres()
|
||||
{
|
||||
return (Genres ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetTags()
|
||||
{
|
||||
return (Tags ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetOfficialRatings()
|
||||
{
|
||||
return (OfficialRatings ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetMediaTypes()
|
||||
{
|
||||
return (MediaTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetIncludeItemTypes()
|
||||
{
|
||||
return (IncludeItemTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetExcludeItemTypes()
|
||||
{
|
||||
return (ExcludeItemTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public int[] GetYears()
|
||||
{
|
||||
return (Years ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
|
||||
}
|
||||
|
||||
public string[] GetStudios()
|
||||
{
|
||||
return (Studios ?? string.Empty).Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public string[] GetPersonTypes()
|
||||
{
|
||||
return (PersonTypes ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public VideoType[] GetVideoTypes()
|
||||
{
|
||||
return string.IsNullOrEmpty(VideoTypes)
|
||||
? Array.Empty<VideoType>()
|
||||
: VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(v => Enum.Parse<VideoType>(v, true)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the filters.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{ItemFilter}.</returns>
|
||||
public ItemFilter[] GetFilters()
|
||||
{
|
||||
var val = Filters;
|
||||
|
||||
return string.IsNullOrEmpty(val)
|
||||
? Array.Empty<ItemFilter>()
|
||||
: val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(v => Enum.Parse<ItemFilter>(v, true)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the image types.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{ImageType}.</returns>
|
||||
public ImageType[] GetImageTypes()
|
||||
{
|
||||
var val = ImageTypes;
|
||||
|
||||
return string.IsNullOrEmpty(val)
|
||||
? Array.Empty<ImageType>()
|
||||
: val.Split(',').Select(v => Enum.Parse<ImageType>(v, true)).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the order by.
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable{ItemSortBy}.</returns>
|
||||
public ValueTuple<string, SortOrder>[] GetOrderBy()
|
||||
{
|
||||
return GetOrderBy(SortBy, SortOrder);
|
||||
}
|
||||
|
||||
public static ValueTuple<string, SortOrder>[] GetOrderBy(string sortBy, string requestedSortOrder)
|
||||
{
|
||||
var val = sortBy;
|
||||
|
||||
if (string.IsNullOrEmpty(val))
|
||||
{
|
||||
return Array.Empty<ValueTuple<string, SortOrder>>();
|
||||
}
|
||||
|
||||
var vals = val.Split(',');
|
||||
if (string.IsNullOrWhiteSpace(requestedSortOrder))
|
||||
{
|
||||
requestedSortOrder = "Ascending";
|
||||
}
|
||||
|
||||
var sortOrders = requestedSortOrder.Split(',');
|
||||
|
||||
var result = new ValueTuple<string, SortOrder>[vals.Length];
|
||||
|
||||
for (var i = 0; i < vals.Length; i++)
|
||||
{
|
||||
var sortOrderIndex = sortOrders.Length > i ? i : 0;
|
||||
|
||||
var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
|
||||
var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase)
|
||||
? MediaBrowser.Model.Entities.SortOrder.Descending
|
||||
: MediaBrowser.Model.Entities.SortOrder.Ascending;
|
||||
|
||||
result[i] = new ValueTuple<string, SortOrder>(vals[i], sortOrder);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user