Upload thumbnails to S3

This commit is contained in:
2023-08-01 23:08:57 +01:00
parent 99ad1dc439
commit d2b56c14f9
20 changed files with 482 additions and 110 deletions

View File

@ -16,11 +16,9 @@ public class PlaylistController : Controller
private readonly SrsApi _srsApi;
private readonly ViewCounter _viewCounter;
private readonly StreamManagerFactory _streamManagerFactory;
private readonly ThumbnailService _thumbnailService;
public PlaylistController(Config config, ILogger<PlaylistController> logger,
HttpClient client, SrsApi srsApi, ViewCounter viewCounter, StreamManagerFactory streamManagerFactory,
ThumbnailService thumbnailService)
HttpClient client, SrsApi srsApi, ViewCounter viewCounter, StreamManagerFactory streamManagerFactory)
{
_config = config;
_logger = logger;
@ -28,7 +26,6 @@ public class PlaylistController : Controller
_srsApi = srsApi;
_viewCounter = viewCounter;
_streamManagerFactory = streamManagerFactory;
_thumbnailService = thumbnailService;
}
[ResponseCache(Duration = 1, Location = ResponseCacheLocation.Any)]
@ -85,34 +82,6 @@ public class PlaylistController : Controller
}
}
[ResponseCache(Duration = 30, Location = ResponseCacheLocation.Any)]
[HttpGet("{id}.jpg")]
public async Task GetPreview([FromRoute] Guid id)
{
try
{
var stream = _thumbnailService.GetThumbnail(id);
if (stream != default)
{
Response.ContentLength = stream.Length;
Response.ContentType = "image/jpg";
Response.Headers.CacheControl = "public, max-age=60";
await Response.StartAsync();
await stream.CopyToAsync(Response.Body);
await Response.CompleteAsync();
}
else
{
Response.StatusCode = 404;
}
}
catch (Exception ex)
{
_logger.LogWarning("Failed to get preview image for {id} {message}", id, ex.Message);
Response.StatusCode = 404;
}
}
[ResponseCache(Duration = 1, Location = ResponseCacheLocation.Any)]
[HttpGet("{pubkey}.m3u8")]
public async Task<IActionResult> GetCurrentStreamRedirect([FromRoute] string pubkey)