mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-07-05 21:33:02 +02:00
Don't throw when livestream file isn't found
This commit is contained in:
parent
1a5a74d2a9
commit
026a7af0e8
|
@ -602,7 +602,8 @@ namespace Emby.Server.Implementations.Library
|
||||||
|
|
||||||
public async Task<MediaSourceInfo> GetLiveStreamMediaInfo(string id, CancellationToken cancellationToken)
|
public async Task<MediaSourceInfo> GetLiveStreamMediaInfo(string id, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var liveStreamInfo = GetLiveStreamInfo(id);
|
// TODO probably shouldn't throw here but it is kept for "backwards compatibility"
|
||||||
|
var liveStreamInfo = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
|
||||||
|
|
||||||
var mediaSource = liveStreamInfo.MediaSource;
|
var mediaSource = liveStreamInfo.MediaSource;
|
||||||
|
|
||||||
|
@ -778,7 +779,8 @@ namespace Emby.Server.Implementations.Library
|
||||||
throw new ArgumentNullException(nameof(id));
|
throw new ArgumentNullException(nameof(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
var info = GetLiveStreamInfo(id);
|
// TODO probably shouldn't throw here but it is kept for "backwards compatibility"
|
||||||
|
var info = GetLiveStreamInfo(id) ?? throw new ResourceNotFoundException();
|
||||||
return Task.FromResult(new Tuple<MediaSourceInfo, IDirectStreamProvider>(info.MediaSource, info as IDirectStreamProvider));
|
return Task.FromResult(new Tuple<MediaSourceInfo, IDirectStreamProvider>(info.MediaSource, info as IDirectStreamProvider));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -794,7 +796,7 @@ namespace Emby.Server.Implementations.Library
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ResourceNotFoundException();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<MediaSourceInfo> GetLiveStream(string id, CancellationToken cancellationToken)
|
public async Task<MediaSourceInfo> GetLiveStream(string id, CancellationToken cancellationToken)
|
||||||
|
|
|
@ -454,6 +454,10 @@ namespace Jellyfin.Api.Controllers
|
||||||
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, startTimeTicks, Request, _dlnaManager);
|
StreamingHelpers.AddDlnaHeaders(state, Response.Headers, true, startTimeTicks, Request, _dlnaManager);
|
||||||
|
|
||||||
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
|
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
|
||||||
|
if (liveStreamInfo == null)
|
||||||
|
{
|
||||||
|
return NotFound();
|
||||||
|
}
|
||||||
var liveStream = new ProgressiveFileStream(liveStreamInfo.GetStream());
|
var liveStream = new ProgressiveFileStream(liveStreamInfo.GetStream());
|
||||||
// TODO (moved from MediaBrowser.Api): Don't hardcode contentType
|
// TODO (moved from MediaBrowser.Api): Don't hardcode contentType
|
||||||
return File(liveStream, MimeTypes.GetMimeType("file.ts")!);
|
return File(liveStream, MimeTypes.GetMimeType("file.ts")!);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Net.Http;
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Jellyfin.Api.Models.StreamingDtos;
|
using Jellyfin.Api.Models.StreamingDtos;
|
||||||
|
@ -121,6 +122,10 @@ namespace Jellyfin.Api.Helpers
|
||||||
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);
|
StreamingHelpers.AddDlnaHeaders(state, _httpContextAccessor.HttpContext.Response.Headers, true, streamingRequest.StartTimeTicks, _httpContextAccessor.HttpContext.Request, _dlnaManager);
|
||||||
|
|
||||||
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
|
var liveStreamInfo = _mediaSourceManager.GetLiveStreamInfo(streamingRequest.LiveStreamId);
|
||||||
|
if (liveStreamInfo == null)
|
||||||
|
{
|
||||||
|
throw new FileNotFoundException();
|
||||||
|
}
|
||||||
var liveStream = new ProgressiveFileStream(liveStreamInfo.GetStream());
|
var liveStream = new ProgressiveFileStream(liveStreamInfo.GetStream());
|
||||||
// TODO (moved from MediaBrowser.Api): Don't hardcode contentType
|
// TODO (moved from MediaBrowser.Api): Don't hardcode contentType
|
||||||
return new FileStreamResult(liveStream, MimeTypes.GetMimeType("file.ts"));
|
return new FileStreamResult(liveStream, MimeTypes.GetMimeType("file.ts"));
|
||||||
|
|
Loading…
Reference in a new issue