summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-11-30 23:01:00 +0100
committerCarl Hetherington <cth@carlh.net>2026-02-03 21:37:04 +0100
commit76a37b29981d77c9bd7f20dc4ecca4a73b10b8f4 (patch)
tree8ff913bc93c63a4bae27f76972f0701278d8d66a
parent77d1cc87652e3dbcee64cc4be4bc69015db95106 (diff)
Add content GET endpoint.
-rw-r--r--src/lib/http_server.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/http_server.cc b/src/lib/http_server.cc
index 1797b025c..4d1823bc4 100644
--- a/src/lib/http_server.cc
+++ b/src/lib/http_server.cc
@@ -24,6 +24,7 @@
#include "dcpomatic_socket.h"
#include "http_server.h"
#include "show_playlist.h"
+#include "show_playlist_content_store.h"
#include "show_playlist_list.h"
#include "util.h"
#include "variant.h"
@@ -161,6 +162,30 @@ HTTPServer::get(string const& url)
auto response = Response(200, json.dump());
response.set_type(Response::Type::JSON);
return response;
+ } else if (url == "/api/v1/content") {
+ nlohmann::json json;
+ for (auto i: ShowPlaylistContentStore::instance()->all()) {
+ /* XXX: converting to JSON this way feels a bit grotty */
+ json.push_back(ShowPlaylistEntry(i, {}).as_json());
+ }
+ auto response = Response(200, json.dump());
+ response.set_type(Response::Type::JSON);
+ return response;
+ } else if (boost::algorithm::starts_with(url, "/api/v1/content/")) {
+ vector<string> parts;
+ boost::algorithm::split(parts, url, boost::is_any_of("/"));
+ if (parts.size() != 5) {
+ return Response::ERROR_404;
+ }
+ auto content = ShowPlaylistContentStore::instance()->get(parts[4]);
+ if (!content) {
+ return Response::ERROR_404;
+ }
+ /* XXX: converting to JSON this way feels a bit grotty */
+ auto json = ShowPlaylistEntry(content, {}).as_json();
+ auto response = Response(200, json.dump());
+ response.set_type(Response::Type::JSON);
+ return response;
} else {
LOG_HTTP("404 {}", url);
return Response::ERROR_404;