แก้ไขและดาวน์โหลดซับไตเติล
งานที่ READY จะเก็บ result.srt และ result.karaoke.vtt ของ worker ไว้โดยไม่แก้ไขตลอดไป — ซับไตเติลที่แก้ไขแล้วถูกบันทึกเป็นสำเนาไว้ข้าง ๆ และถูกส่งให้แทนเมื่อดาวน์โหลด ทุก route ในหน้านี้ตอบ 404 not found สำหรับทุกอย่างที่ไม่ใช่งาน READY (id ไม่มี รูปแบบผิด งานยังไม่เสร็จ หรือเป็นงานของผู้ใช้อื่นเมื่อเรียกด้วย personal API key หรือ session cookie)
Direct editor uploads — POST /jobs/{job_id}/edit-upload-urls
The browser editor uses this authenticated endpoint once when it first needs to save, then reuses its URLs. No request body is required. Cookie callers must send a trusted Origin; bearer callers use the same authentication as the other job routes.
{
"srt": {"url": "<presigned PUT URL>", "headers": {"Content-Type": "text/plain; charset=utf-8"}},
"karaoke_vtt": {"url": "<presigned PUT URL>", "headers": {"Content-Type": "text/vtt; charset=utf-8"}},
"expires_at": 1800000000
}
karaoke_vtt is null for a job without an original karaoke result. expires_at is a
Unix timestamp in seconds; URLs use PRESIGNED_URL_TTL_SECONDS (default 86400 / 24 hours).
PUT the raw UTF-8 subtitle text directly to each URL using its returned headers,
without cookies or an Authorization header. Repeated PUTs overwrite only that job's
edited.srt / edited.karaoke.vtt. Treat these URLs as credentials and do not log them.
Issuance checks job ownership but does not write storage objects or database metadata.
Direct saves do not update edited_at, cue_count, or edited-object flags in GET /jobs;
those fields reflect the original result or the last legacy API save. Download routes
check for edited objects themselves and fall back to originals only if absent.
The editor saves after 10 seconds idle or 30 seconds of continuous editing, confirms success only after both required uploads, and retries failures. Two files are not an atomic transaction; no revision history or concurrent-editor conflict detection is provided. The legacy PUT endpoint below remains available for existing clients.
Headers
| Header | ค่า | จำเป็น |
|---|---|---|
Authorization |
Bearer <API_KEY> |
ต้องระบุ |
Content-Type |
application/json (เฉพาะ PUT) |
ต้องระบุ |
บันทึกซับไตเติลที่แก้ไข — PUT /jobs/{job_id}
PUT https://api.lomasub.ai/jobs/<job_id>
| ฟิลด์ | ชนิด | จำเป็น | คำอธิบาย |
|---|---|---|---|
srt |
string (1 ไบต์ – 2 MiB) | ต้องระบุ | ข้อความ SRT ที่แก้ไขแล้ว บันทึกเป็น edited.srt ข้างผลลัพธ์ของงาน และเขียนทับทุกครั้งที่บันทึก |
cue_count |
int ≥ 0 | — (ค่าเริ่มต้น 0) |
จำนวนบรรทัดที่บันทึกลงรายการงานและแสดงใน GET /jobs |
karaoke_vtt |
string (1 ไบต์ – 2 MiB) | null | — | WebVTT พร้อม timestamp ระดับคำที่แก้ไขแล้ว บันทึกเป็น edited.karaoke.vtt เฉพาะเมื่องานมีผลลัพธ์ karaoke ไม่เช่นนั้นถูกละเลย ไม่ส่งมาถ้าต้องการคงไฟล์ karaoke เดิมไว้ |
ตัวอย่าง Request
curl -X PUT "https://api.lomasub.ai/jobs/7f3c2b1e-9a4d-4c8e-b2f1-5d6e7a8b9c0d" \
-H "Authorization: Bearer $LOMA_API_SECRET_KEY" \
-H "Content-Type: application/json" \
-d "$(jq -n --rawfile srt interview.edited.srt '{srt: $srt, cue_count: 409}')"
Response — 200 OK
{"ok": true}
ดาวน์โหลดซับไตเติล
GET https://api.lomasub.ai/jobs/<job_id>.srt
GET https://api.lomasub.ai/jobs/<job_id>/original.srt
GET https://api.lomasub.ai/jobs/<job_id>/karaoke.vtt
| Route | สิ่งที่ส่งกลับ | ชื่อไฟล์แนบ | Content type |
|---|---|---|---|
/jobs/{id}.srt |
SRT ที่แก้ไขแล้วถ้าเคยบันทึก ไม่เช่นนั้นเป็น result.srt ของ worker |
cancer-doc-check.srt |
text/plain; charset=utf-8 |
/jobs/{id}/original.srt |
result.srt ของ worker ซึ่งไม่ถูกเขียนทับเลย |
cancer-doc-check.original.srt |
text/plain; charset=utf-8 |
/jobs/{id}/karaoke.vtt |
karaoke VTT ที่แก้ไขแล้วถ้าเคยบันทึก ไม่เช่นนั้นเป็นของ worker — ตอบ 404 เมื่องานไม่มีไฟล์นี้ (forcealigner_level = none) |
cancer-doc-check.karaoke.vtt |
text/vtt; charset=utf-8 |
แต่ละ route ส่งกลับเป็นไฟล์แนบที่ตั้งชื่อตาม filename ของงานโดยตัดนามสกุลสื่อออกแล้วต่อท้ายตาม route (ตัวอย่างในตารางคือชื่อสำหรับ cancer-doc-check.mp4) ชื่อภาษาไทยส่งใน filename*=UTF-8''… พร้อมชื่อ ASCII สำรอง มาพร้อม Cache-Control: no-store และต่างจากลิงก์ presigned *_url ใน GET /status ตรงที่ route เหล่านี้ผ่าน API จึงต้องแนบ Authorization header
curl -o interview.current.srt "https://api.lomasub.ai/jobs/7f3c2b1e-9a4d-4c8e-b2f1-5d6e7a8b9c0d.srt" \
-H "Authorization: Bearer $LOMA_API_SECRET_KEY"
ข้อผิดพลาดที่อาจพบ
| สถานะ | สาเหตุ | ตัวอย่างข้อความ |
|---|---|---|
401 Unauthorized |
ไม่มีหรือ API key ไม่ถูกต้อง | — |
404 Not Found |
งานไม่มี รูปแบบ id ผิด งานยังไม่ READY หรือ karaoke VTT ไม่มีสำหรับงานนี้ |
"not found" |
422 Unprocessable Entity |
srt ว่างหรือเกิน 2 MiB, cue_count ติดลบ |
ตอบเป็น list ตามรูปแบบ FastAPI |
502 Bad Gateway |
เขียนลง bucket ไม่สำเร็จตอน PUT |
"storage unavailable" |