Add API for fetching manga info from ID

This commit is contained in:
Alex Ling 2020-02-21 02:00:01 +00:00
parent aecac748dc
commit a3356344fa

View File

@ -1,4 +1,5 @@
require "./router" require "./router"
require "../mangadex/*"
class APIRouter < Router class APIRouter < Router
def setup def setup
@ -88,5 +89,18 @@ class APIRouter < Router
send_json env, {"success" => true}.to_json send_json env, {"success" => true}.to_json
end end
end end
get "/api/admin/mangadex/manga/:id" do |env|
begin
id = env.params.url["id"]
api = Mangadex::API.new \
@context.config.mangadex["api_url"].to_s
manga = api.get_manga id
send_json env, manga.to_info_json
rescue e
@context.error e
send_json env, {"error" => e.messsage}.to_json
end
end
end end
end end