Implement movie import functionality and enhance media processing
Added new endpoints for matching and importing movies, allowing for automated processing of film files from the inbox. Introduced logic to parse file names into titles and years, and integrated metadata matching to streamline the import process. Updated the MediaOptions to include a configuration for automatic movie creation from recognized files. Enhanced the InboxScanner to attempt movie attachment upon asset registration, improving user experience and efficiency. Updated documentation to reflect these new features and their usage.
This commit is contained in:
@@ -8,6 +8,7 @@ using TeleWave.Application.Media;
|
||||
using TeleWave.Application.Media.Delete;
|
||||
using TeleWave.Application.Media.ListMedia;
|
||||
using TeleWave.Application.Media.ManualInbox;
|
||||
using TeleWave.Application.Media.MovieImport;
|
||||
using TeleWave.Application.Media.Register;
|
||||
using TeleWave.Application.Media.Stats;
|
||||
using TeleWave.Domain.Media;
|
||||
@@ -33,6 +34,12 @@ public static class MediaEndpoints
|
||||
admin.MapGet("/manual", ListManual).Produces<ManualInboxListDto>();
|
||||
admin.MapPost("/manual/import", ImportManual).Produces<ImportManualInboxResultDto>();
|
||||
|
||||
// Разбор фильмов: имена приходят с клиента (каталог manual/ либо выбранные в браузере
|
||||
// файлы), сервер разбирает их и ищет в источнике. Импорт заводит шоу на файл.
|
||||
admin.MapPost("/movies/match", MatchMovies).Produces<IReadOnlyList<MovieMatchDto>>();
|
||||
admin.MapPost("/movies/match-one", MatchMovie).Produces<MovieMatchDto>();
|
||||
admin.MapPost("/movies/import", ImportMovies).Produces<ImportMoviesResultDto>();
|
||||
|
||||
// Просмотр обработанного ассета в админке (ролики, проверка серии). Публичная раздача идёт
|
||||
// по stream-куке, здесь роут под JWT — плейлист и сегменты грузит hls.js с Bearer.
|
||||
admin.MapGet("/{id:guid}/preview/index.m3u8", PreviewPlaylist);
|
||||
@@ -164,6 +171,45 @@ public static class MediaEndpoints
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
private static async Task<IResult> MatchMovies(
|
||||
MatchMoviesBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new MatchMoviesQuery(body.Names, body.Provider),
|
||||
cancellationToken
|
||||
);
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
private static async Task<IResult> MatchMovie(
|
||||
MatchMovieBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new MatchMovieQuery(body.Name, body.Title, body.Year, body.Provider),
|
||||
cancellationToken
|
||||
);
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
private static async Task<IResult> ImportMovies(
|
||||
ImportMoviesBody body,
|
||||
ISender sender,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var result = await sender.Send(
|
||||
new ImportMoviesCommand(body.Items, body.Provider),
|
||||
cancellationToken
|
||||
);
|
||||
return result.ToHttpResult();
|
||||
}
|
||||
|
||||
private static async Task<IResult> ImportManual(
|
||||
ImportManualInboxBody body,
|
||||
ISender sender,
|
||||
@@ -228,3 +274,9 @@ public sealed record ListMediaFilter(
|
||||
public sealed record UploadMediaResponse(Guid Id);
|
||||
|
||||
public sealed record ImportManualInboxBody(IReadOnlyList<ManualImportItem> Items, Guid ShowId);
|
||||
|
||||
public sealed record MatchMoviesBody(IReadOnlyList<string> Names, string Provider);
|
||||
|
||||
public sealed record MatchMovieBody(string Name, string Title, int? Year, string Provider);
|
||||
|
||||
public sealed record ImportMoviesBody(IReadOnlyList<MovieImportItem> Items, string Provider);
|
||||
|
||||
Reference in New Issue
Block a user