Expose page ratios through API

This commit is contained in:
Alex Ling
2020-09-10 13:16:10 +00:00
parent ef1ab940f5
commit 88394d4636
4 changed files with 56 additions and 0 deletions

View File

@@ -332,5 +332,28 @@ class APIRouter < Router
}.to_json
end
end
get "/api/ratios/:tid/:eid" do |env|
begin
tid = env.params.url["tid"]
eid = env.params.url["eid"]
title = @context.library.get_title tid
raise "Title ID `#{tid}` not found" if title.nil?
entry = title.get_entry eid
raise "Entry ID `#{eid}` of `#{title.title}` not found" if entry.nil?
ratios = entry.page_aspect_ratios
send_json env, {
"success" => true,
"ratios" => ratios,
}.to_json
rescue e
send_json env, {
"success" => false,
"error" => e.message,
}.to_json
end
end
end
end