Nodes/ComfyUI-nkxx/3. Sora2 异步获取视频 (Grsai)
ComfyUI Node

3. Sora2 异步获取视频 (Grsai)

The node that finally hands you the finished video

By nkxx188·Created 11 months ago·Updated 6 months ago· 14
3. Sora2 异步获取视频 (Grsai)
    • video
    • report

    The payoff node. No inputs at all - it opens the pack's Sora2 task database, finds the oldest task marked succeeded, downloads the video to your ComfyUI output folder, and marks it downloaded so the next run picks up the next one. Run it after Sora2QueryTasks_Grsai has told you something is ready and you get a real video out the other end.

    Outputs:

    • video - a proper ComfyUI VIDEO (a VideoAdapter-wrapped local MP4), so you can wire it into a VHS-style player node, a save node, or further processing. Saved as sora2_<taskid8>_<random>.mp4 in your output dir.
    • report - STRING: "下载成功: <taskid>... (PID: ...)" on success, or one of the failure messages below.

    Mechanically it's refreshingly simple: sort tasks by submission time ascending, take the first succeeded one, download via the pack's robust_download_video (yt-dlp first, curl fallback, three retries, 300s timeout), then write status: downloaded + the local path back into data/sora2_task_history.json. One run = one video, oldest first, so it drains a batch in submission order. Its forced re-execution (IS_CHANGED) means re-queueing it naturally walks the queue.

    Two failure modes the code handles explicitly, both worth knowing:

    • No succeeded task → returns "当前无新完成的任务可供下载." with an empty video. It does not error, so don't read that as a crash.
    • Auto-download fails (URL missing, network died, both yt-dlp and curl gave up) → marks the task download_failed and hands you the raw URL in the report so you can grab it manually. This is the pack's most honest design decision: it'd rather tell you "copy this link" than silently re-bill you.

    Install is the pack-wide routine:

    cd ComfyUI/custom_nodes
    git clone https://github.com/jieg9341-lab/ComfyUI-nkxx
    

    Restart; first boot auto-installs requests, pandas, yt-dlp (the downloader's primary engine - if you've got an old broken yt-dlp in your Python env, that's the usual "download always fails" culprit), plus opencv-python and aiohttp. Needs a Grsai key from nkxx.grsai.ai for the earlier steps; this node itself doesn't even read one, because the URL is already sitting in the database.

    Grounded gotchas:

    • It only fetches one video per run. To drain a 50-task batch you re-run it 50 times (or loop it). That's by design - oldest-first, one at a time.
    • The download marks a task downloaded only on success; a download_failed task stays in the queue and will not be retried automatically by later runs (they only look for succeeded). Once a task is marked download_failed, the manual-URL path is your only route, or clear it from the JSON.
    • If the URL is present but the status never flipped to succeeded - because you never ran the query node - this node finds nothing. The pipeline order matters: submit → query → fetch.
    CategoryNkxx/Grsai/视频 (异步)

    Inputs (0)

    No inputs

    Outputs (2)

    NameTypeDescription
    videoVIDEO
    reportSTRING