mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
Add API for fetching manga info from ID
This commit is contained in:
parent
aecac748dc
commit
a3356344fa
@ -1,4 +1,5 @@
|
||||
require "./router"
|
||||
require "../mangadex/*"
|
||||
|
||||
class APIRouter < Router
|
||||
def setup
|
||||
@ -88,5 +89,18 @@ class APIRouter < Router
|
||||
send_json env, {"success" => true}.to_json
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user