Add endpoint to get metadata

This commit is contained in:
MrLetsplay 2025-02-10 23:00:48 +01:00
parent ae1d9e2bc1
commit 3dbc1b54d6
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg

View File

@ -91,6 +91,17 @@ public class LibraryAPI implements EndpointCollection {
ctx.respond(HttpStatusCodes.OK_200, new JsonResponse(videoToJSON(video))); ctx.respond(HttpStatusCodes.OK_200, new JsonResponse(videoToJSON(video)));
} }
@Endpoint(method = HttpRequestMethod.GET, path = "/video/{video}/metadata", pathPattern = true)
public void getMetadata(HttpRequestContext ctx, @RequestParameter("video") String videoId) {
Video video = VideoBase.getLibrary().findVideoById(videoId);
if(video == null) {
ctx.respond(HttpStatusCodes.NOT_FOUND_404, new TextResponse("Not found"));
return;
}
ctx.respond(HttpStatusCodes.OK_200, new JsonResponse(video.getMetadata().getRaw()));
}
@Endpoint(method = HttpRequestMethod.PUT, path = "/video/{video}/metadata", pathPattern = true) @Endpoint(method = HttpRequestMethod.PUT, path = "/video/{video}/metadata", pathPattern = true)
public void updateVideoMetadata(HttpRequestContext ctx, @RequestParameter("video") String videoId) { public void updateVideoMetadata(HttpRequestContext ctx, @RequestParameter("video") String videoId) {
Library library = VideoBase.getLibrary(); Library library = VideoBase.getLibrary();