mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 03:15:31 -04:00
Update download API to use Queue in Context and use @full_title
This commit is contained in:
parent
4ca8daca29
commit
8c47d50291
@ -106,20 +106,18 @@ class APIRouter < Router
|
|||||||
post "/api/admin/mangadex/download" do |env|
|
post "/api/admin/mangadex/download" do |env|
|
||||||
begin
|
begin
|
||||||
chapters = env.params.json["chapters"].as(Array).map{|c| c.as_h}
|
chapters = env.params.json["chapters"].as(Array).map{|c| c.as_h}
|
||||||
queue = MangaDex::Queue.new \
|
|
||||||
@context.config.mangadex["download_queue_db_path"].to_s
|
|
||||||
jobs = chapters.map {|chapter|
|
jobs = chapters.map {|chapter|
|
||||||
MangaDex::Job.new(
|
MangaDex::Job.new(
|
||||||
chapter["id"].as_s,
|
chapter["id"].as_s,
|
||||||
chapter["manga_id"].as_s,
|
chapter["manga_id"].as_s,
|
||||||
chapter["title"].as_s,
|
chapter["full_title"].as_s,
|
||||||
chapter["manga_title"].as_s,
|
chapter["manga_title"].as_s,
|
||||||
MangaDex::JobStatus::Pending,
|
MangaDex::JobStatus::Pending,
|
||||||
"",
|
"",
|
||||||
Time.utc
|
Time.utc
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
inserted_count = queue.push jobs
|
inserted_count = @context.queue.push jobs
|
||||||
send_json env, {
|
send_json env, {
|
||||||
"success": inserted_count,
|
"success": inserted_count,
|
||||||
"fail": jobs.size - inserted_count
|
"fail": jobs.size - inserted_count
|
||||||
|
Loading…
x
Reference in New Issue
Block a user