rework EnableMediaPlayback
This commit is contained in:
parent
7cd41a6ed6
commit
2ceea17bf4
|
@ -12,6 +12,7 @@ using MediaBrowser.Model.Drawing;
|
|||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.IO;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.LiveTv;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -1268,11 +1269,6 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
var user = AuthorizationRequestFilterAttribute.GetCurrentUser(Request, UserManager);
|
||||
|
||||
if (user != null && !user.Configuration.EnableMediaPlayback)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));
|
||||
}
|
||||
|
||||
var url = Request.PathInfo;
|
||||
|
||||
if (!request.AudioCodec.HasValue)
|
||||
|
@ -1288,6 +1284,11 @@ namespace MediaBrowser.Api.Playback
|
|||
|
||||
var item = DtoService.GetItemByDtoId(request.Id);
|
||||
|
||||
if (user != null && item.GetPlayAccess(user) != PlayAccess.Full)
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));
|
||||
}
|
||||
|
||||
if (item is ILiveTvRecording)
|
||||
{
|
||||
var recording = await LiveTvManager.GetInternalRecording(request.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
|
|
@ -7,6 +7,7 @@ using MediaBrowser.Controller.Persistence;
|
|||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -478,6 +479,21 @@ namespace MediaBrowser.Controller.Entities
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the play access.
|
||||
/// </summary>
|
||||
/// <param name="user">The user.</param>
|
||||
/// <returns>PlayAccess.</returns>
|
||||
public PlayAccess GetPlayAccess(User user)
|
||||
{
|
||||
if (!user.Configuration.EnableMediaPlayback)
|
||||
{
|
||||
return PlayAccess.None;
|
||||
}
|
||||
|
||||
return PlayAccess.Full;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads local trailers from the file system
|
||||
/// </summary>
|
||||
|
|
|
@ -233,6 +233,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
|
||||
<Link>IO\IZipClient.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Library\PlayAccess.cs">
|
||||
<Link>Library\PlayAccess.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
|
||||
<Link>LiveTv\ChannelInfoDto.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -220,6 +220,9 @@
|
|||
<Compile Include="..\MediaBrowser.Model\IO\IZipClient.cs">
|
||||
<Link>IO\IZipClient.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\Library\PlayAccess.cs">
|
||||
<Link>Library\PlayAccess.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\MediaBrowser.Model\LiveTv\ChannelInfoDto.cs">
|
||||
<Link>LiveTv\ChannelInfoDto.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
using MediaBrowser.Model.Library;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
|
@ -153,6 +154,12 @@ namespace MediaBrowser.Model.Dto
|
|||
/// </summary>
|
||||
/// <value>The cumulative run time ticks.</value>
|
||||
public long? CumulativeRunTimeTicks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the original run time ticks.
|
||||
/// </summary>
|
||||
/// <value>The original run time ticks.</value>
|
||||
public long? OriginalRunTimeTicks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the run time ticks.
|
||||
|
@ -160,6 +167,12 @@ namespace MediaBrowser.Model.Dto
|
|||
/// <value>The run time ticks.</value>
|
||||
public long? RunTimeTicks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the play access.
|
||||
/// </summary>
|
||||
/// <value>The play access.</value>
|
||||
public PlayAccess PlayAccess { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the aspect ratio.
|
||||
/// </summary>
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Model.Dto
|
||||
{
|
||||
public class RecordingInfoDto
|
||||
{
|
||||
}
|
||||
}
|
9
MediaBrowser.Model/Library/PlayAccess.cs
Normal file
9
MediaBrowser.Model/Library/PlayAccess.cs
Normal file
|
@ -0,0 +1,9 @@
|
|||
|
||||
namespace MediaBrowser.Model.Library
|
||||
{
|
||||
public enum PlayAccess
|
||||
{
|
||||
Full = 0,
|
||||
None = 1
|
||||
}
|
||||
}
|
|
@ -76,6 +76,7 @@
|
|||
<Compile Include="Entities\PackageReviewInfo.cs" />
|
||||
<Compile Include="FileOrganization\FileOrganizationResult.cs" />
|
||||
<Compile Include="FileOrganization\FileOrganizationQuery.cs" />
|
||||
<Compile Include="Library\PlayAccess.cs" />
|
||||
<Compile Include="LiveTv\ChannelInfoDto.cs" />
|
||||
<Compile Include="LiveTv\ChannelQuery.cs" />
|
||||
<Compile Include="LiveTv\ProgramInfoDto.cs" />
|
||||
|
|
|
@ -10,7 +10,6 @@ using MediaBrowser.Controller.Entities.TV;
|
|||
using MediaBrowser.Controller.Library;
|
||||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Configuration;
|
||||
using MediaBrowser.Model.Drawing;
|
||||
using MediaBrowser.Model.Dto;
|
||||
using MediaBrowser.Model.Entities;
|
||||
|
@ -185,6 +184,8 @@ namespace MediaBrowser.Server.Implementations.Dto
|
|||
{
|
||||
dto.UserData.Played = dto.PlayedPercentage.HasValue && dto.PlayedPercentage.Value >= 100;
|
||||
}
|
||||
|
||||
dto.PlayAccess = item.GetPlayAccess(user);
|
||||
}
|
||||
|
||||
private int GetChildCount(Folder folder, User user)
|
||||
|
|
|
@ -7,6 +7,7 @@ using MediaBrowser.Controller.Library;
|
|||
using MediaBrowser.Controller.Persistence;
|
||||
using MediaBrowser.Controller.Session;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Model.Library;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Model.Session;
|
||||
using System;
|
||||
|
@ -604,20 +605,20 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
{
|
||||
var session = GetSessionForRemoteControl(sessionId);
|
||||
|
||||
var items = command.ItemIds.Select(i => _libraryManager.GetItemById(new Guid(i)))
|
||||
.Where(i => i.LocationType != LocationType.Virtual)
|
||||
.ToList();
|
||||
|
||||
if (session.UserId.HasValue)
|
||||
{
|
||||
var user = _userManager.GetUserById(session.UserId.Value);
|
||||
|
||||
if (!user.Configuration.EnableMediaPlayback)
|
||||
if (items.Any(i => i.GetPlayAccess(user) != PlayAccess.Full))
|
||||
{
|
||||
throw new ArgumentException(string.Format("{0} is not allowed to play media.", user.Name));
|
||||
}
|
||||
}
|
||||
|
||||
var items = command.ItemIds.Select(i => _libraryManager.GetItemById(new Guid(i)))
|
||||
.Where(i => i.LocationType != LocationType.Virtual)
|
||||
.ToList();
|
||||
|
||||
if (command.PlayCommand != PlayCommand.PlayNow)
|
||||
{
|
||||
if (items.Any(i => !session.QueueableMediaTypes.Contains(i.MediaType, StringComparer.OrdinalIgnoreCase)))
|
||||
|
|
Loading…
Reference in New Issue
Block a user