mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-11-16 02:18:54 -07:00
add delete to multi-select
This commit is contained in:
parent
a04f4421bd
commit
a2a620a4c4
@ -162,6 +162,14 @@ namespace MediaBrowser.Api.Library
|
||||
public string Id { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Items", "DELETE", Summary = "Deletes an item from the library and file system")]
|
||||
[Authenticated]
|
||||
public class DeleteItems : IReturnVoid
|
||||
{
|
||||
[ApiMember(Name = "Ids", Description = "Ids", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
|
||||
public string Ids { get; set; }
|
||||
}
|
||||
|
||||
[Route("/Items/Counts", "GET")]
|
||||
[Authenticated]
|
||||
public class GetItemCounts : IReturn<ItemCounts>
|
||||
@ -755,31 +763,53 @@ namespace MediaBrowser.Api.Library
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
public void Delete(DeleteItems request)
|
||||
{
|
||||
var ids = string.IsNullOrWhiteSpace(request.Ids)
|
||||
? new string[] { }
|
||||
: request.Ids.Split(',');
|
||||
|
||||
var tasks = ids.Select(i =>
|
||||
{
|
||||
var item = _libraryManager.GetItemById(i);
|
||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||
var user = _userManager.GetUserById(auth.UserId);
|
||||
|
||||
if (!item.CanDelete(user))
|
||||
{
|
||||
if (ids.Length > 1)
|
||||
{
|
||||
throw new SecurityException("Unauthorized access");
|
||||
}
|
||||
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
if (item is ILiveTvRecording)
|
||||
{
|
||||
return _liveTv.DeleteRecording(i);
|
||||
}
|
||||
|
||||
return _libraryManager.DeleteItem(item);
|
||||
}).ToArray();
|
||||
|
||||
Task.WaitAll(tasks);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the specified request.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
public void Delete(DeleteItem request)
|
||||
{
|
||||
var item = _libraryManager.GetItemById(request.Id);
|
||||
var auth = _authContext.GetAuthorizationInfo(Request);
|
||||
var user = _userManager.GetUserById(auth.UserId);
|
||||
|
||||
if (!item.CanDelete(user))
|
||||
Delete(new DeleteItems
|
||||
{
|
||||
throw new SecurityException("Unauthorized access");
|
||||
}
|
||||
|
||||
if (item is ILiveTvRecording)
|
||||
{
|
||||
var task = _liveTv.DeleteRecording(request.Id);
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
else
|
||||
{
|
||||
var task = _libraryManager.DeleteItem(item);
|
||||
Task.WaitAll(task);
|
||||
}
|
||||
Ids = request.Id
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Controller.LiveTv;
|
||||
using MediaBrowser.Controller.MediaEncoding;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Serialization;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts
|
||||
{
|
||||
public class SatIp : BaseTunerHost
|
||||
{
|
||||
public SatIp(IConfigurationManager config, ILogger logger, IJsonSerializer jsonSerializer, IMediaEncoder mediaEncoder)
|
||||
: base(config, logger, jsonSerializer, mediaEncoder)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Task<IEnumerable<ChannelInfo>> GetChannelsInternal(TunerHostInfo tuner, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string Type
|
||||
{
|
||||
get { return "SatIp"; }
|
||||
}
|
||||
|
||||
protected override Task<List<MediaSourceInfo>> GetChannelStreamMediaSources(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Task<MediaSourceInfo> GetChannelStream(TunerHostInfo tuner, string channelId, string streamId, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override Task<bool> IsAvailableInternal(TunerHostInfo tuner, string channelId, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override bool IsValidChannelId(string channelId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user