mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
update access denied exceptions
This commit is contained in:
@@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{typeof (FileNotFoundException), 404},
|
||||
{typeof (DirectoryNotFoundException), 404},
|
||||
{typeof (SecurityException), 401},
|
||||
{typeof (UnauthorizedAccessException), 401}
|
||||
{typeof (UnauthorizedAccessException), 500}
|
||||
};
|
||||
|
||||
HostConfig.Instance.DebugMode = true;
|
||||
|
||||
@@ -611,11 +611,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
|
||||
try
|
||||
{
|
||||
var recordingEndDate = timer.EndDate.AddSeconds(timer.PostPaddingSeconds);
|
||||
|
||||
if (recordingEndDate <= DateTime.UtcNow)
|
||||
{
|
||||
_logger.Warn("Recording timer fired for timer {0}, Id: {1}, but the program has already ended.", timer.Name, timer.Id);
|
||||
return;
|
||||
}
|
||||
|
||||
var cancellationTokenSource = new CancellationTokenSource();
|
||||
|
||||
if (_activeRecordings.TryAdd(timer.Id, cancellationTokenSource))
|
||||
{
|
||||
await RecordStream(timer, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
await RecordStream(timer, recordingEndDate, cancellationTokenSource.Token).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
@@ -628,22 +636,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
}
|
||||
}
|
||||
|
||||
private async Task RecordStream(TimerInfo timer, CancellationToken cancellationToken)
|
||||
private async Task RecordStream(TimerInfo timer, DateTime recordingEndDate, CancellationToken cancellationToken)
|
||||
{
|
||||
if (timer == null)
|
||||
{
|
||||
throw new ArgumentNullException("timer");
|
||||
}
|
||||
|
||||
var mediaStreamInfo = await GetChannelStream(timer.ChannelId, null, CancellationToken.None);
|
||||
var duration = (timer.EndDate - DateTime.UtcNow).Add(TimeSpan.FromSeconds(timer.PostPaddingSeconds));
|
||||
|
||||
HttpRequestOptions httpRequestOptions = new HttpRequestOptions()
|
||||
{
|
||||
Url = mediaStreamInfo.Path
|
||||
};
|
||||
|
||||
var info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
|
||||
|
||||
var recordPath = RecordingPath;
|
||||
|
||||
if (info.IsMovie)
|
||||
@@ -708,15 +709,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
||||
_recordingProvider.Add(recording);
|
||||
}
|
||||
|
||||
recording.Path = recordPath;
|
||||
recording.Status = RecordingStatus.InProgress;
|
||||
recording.DateLastUpdated = DateTime.UtcNow;
|
||||
_recordingProvider.Update(recording);
|
||||
|
||||
_logger.Info("Beginning recording.");
|
||||
|
||||
try
|
||||
{
|
||||
var mediaStreamInfo = await GetChannelStream(timer.ChannelId, null, CancellationToken.None);
|
||||
|
||||
// HDHR doesn't seem to release the tuner right away after first probing with ffmpeg
|
||||
await Task.Delay(3000, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
var duration = recordingEndDate - DateTime.UtcNow;
|
||||
|
||||
HttpRequestOptions httpRequestOptions = new HttpRequestOptions()
|
||||
{
|
||||
Url = mediaStreamInfo.Path
|
||||
};
|
||||
|
||||
recording.Path = recordPath;
|
||||
recording.Status = RecordingStatus.InProgress;
|
||||
recording.DateLastUpdated = DateTime.UtcNow;
|
||||
_recordingProvider.Update(recording);
|
||||
|
||||
_logger.Info("Beginning recording.");
|
||||
|
||||
httpRequestOptions.BufferContent = false;
|
||||
var durationToken = new CancellationTokenSource(duration);
|
||||
var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
|
||||
|
||||
@@ -29,6 +29,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Net;
|
||||
|
||||
namespace MediaBrowser.Server.Implementations.Session
|
||||
{
|
||||
@@ -1276,7 +1277,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
{
|
||||
if (!_deviceManager.CanAccessDevice(user.Id.ToString("N"), request.DeviceId))
|
||||
{
|
||||
throw new UnauthorizedAccessException("User is not allowed access from this device.");
|
||||
throw new SecurityException("User is not allowed access from this device.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1286,7 +1287,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
||||
{
|
||||
EventHelper.FireEventIfNotNull(AuthenticationFailed, this, new GenericEventArgs<AuthenticationRequest>(request), _logger);
|
||||
|
||||
throw new UnauthorizedAccessException("Invalid user or password entered.");
|
||||
throw new SecurityException("Invalid user or password entered.");
|
||||
}
|
||||
|
||||
var token = await GetAuthorizationToken(user.Id.ToString("N"), request.DeviceId, request.App, request.AppVersion, request.DeviceName).ConfigureAwait(false);
|
||||
|
||||
Reference in New Issue
Block a user