Every file the pipeline and the clip editor write is now clean. On the free plan the served file is a wm_<final> copy with the mark burned in (main.mark_delivery, last step after captions; app._deliver for the editor endpoints, decided from the caller's plan), and both twins go to R2. An upgrade re-points the user's library at the clean twins from the Stripe webhook (cloud.videos.unmark_user_library): no render, no source video, and the dashboard chases the job result until no served URL carries wm_. Before, the mark rode the reframe encode, so every derivative inherited it and the upgrade modal's "upgrade to remove the watermark" was false for the clips already made. The first cancellation for "clip quality" (29-sep) was a user who paid 15 minutes after their first job and kept the mark on every download and restyle. - /videos guard refuses a marked job's clean deliverables (.marked dotfile), so the twin cannot be fetched by stripping the prefix off a URL; editor scratch files stay servable. Re-checked after an R2 restore. - Walk-backs treat wm_ as the outermost layer; _canonical_clip_file globs it. - Jobs from before this scheme (mark burned into the canonical) never get a second copy; a failed mark still serves under the wm_ name. - Watermark notice once per job when the clips land on a free account, and before the first download if skipped; tracked with source=results|download. Upsell/banner/win-back copy now promise the instant removal.
79 lines
3.4 KiB
Python
79 lines
3.4 KiB
Python
"""The clip a job in flight shows must be the FINISHED clip.
|
|
|
|
Before this, the status poller guessed each clip's file as the clean reframe
|
|
name, so every clip appeared stripped of its hook and its captions until the
|
|
whole job ended and the result was rebuilt through _canonical_clip_file. A
|
|
six-clip job meant clip 1 sat there hook-less for the five clips after it, and
|
|
it read as "the hooks are broken" (reported 24-ago-2026).
|
|
|
|
main.py now announces each clip once its whole chain is done and names the file
|
|
to serve; app.py consumes the marker the way it already consumes PROXY_BYTES.
|
|
"""
|
|
import io
|
|
|
|
import pytest
|
|
|
|
app = pytest.importorskip("app")
|
|
|
|
|
|
def _feed(job_id, *lines):
|
|
"""Run enqueue_output over these stdout lines, as the log thread would."""
|
|
stream = io.BytesIO(b"".join(line.encode("utf-8") + b"\n" for line in lines))
|
|
app.enqueue_output(stream, job_id)
|
|
|
|
|
|
class TestClipReadyMarker:
|
|
def setup_method(self):
|
|
self.job_id = "test-clip-ready"
|
|
app.jobs[self.job_id] = {"logs": []}
|
|
|
|
def teardown_method(self):
|
|
app.jobs.pop(self.job_id, None)
|
|
|
|
def test_records_the_file_to_serve_per_clip(self):
|
|
_feed(self.job_id,
|
|
"CLIP_READY 0 subtitled_1_hooked_2_My_Video_clip_1.mp4",
|
|
"CLIP_READY 2 hooked_3_My_Video_clip_3.mp4")
|
|
assert app.jobs[self.job_id]["ready_files"] == {
|
|
0: "subtitled_1_hooked_2_My_Video_clip_1.mp4",
|
|
2: "hooked_3_My_Video_clip_3.mp4",
|
|
}
|
|
|
|
def test_the_marker_never_reaches_the_user_log(self):
|
|
_feed(self.job_id,
|
|
"🎬 Processing Clip 1",
|
|
"CLIP_READY 0 subtitled_1_My_Video_clip_1.mp4")
|
|
assert app.jobs[self.job_id]["logs"] == ["🎬 Processing Clip 1"]
|
|
|
|
def test_clips_arriving_out_of_order_keep_their_own_index(self):
|
|
# CLIP_WORKERS renders three clips at once, so clip 3 can finish first.
|
|
_feed(self.job_id,
|
|
"CLIP_READY 2 subtitled_9_My_Video_clip_3.mp4",
|
|
"CLIP_READY 0 subtitled_7_My_Video_clip_1.mp4")
|
|
ready = app.jobs[self.job_id]["ready_files"]
|
|
assert ready[2].endswith("_clip_3.mp4")
|
|
assert ready[0].endswith("_clip_1.mp4")
|
|
|
|
def test_a_malformed_marker_is_ignored_not_fatal(self):
|
|
_feed(self.job_id, "CLIP_READY notanumber file.mp4", "CLIP_READY 1 ok.mp4")
|
|
assert app.jobs[self.job_id]["ready_files"] == {1: "ok.mp4"}
|
|
|
|
def test_an_unknown_job_does_not_raise(self):
|
|
_feed("no-such-job", "CLIP_READY 0 whatever.mp4")
|
|
|
|
|
|
class TestMainAnnouncesTheDeliveredFile:
|
|
def test_main_prints_the_marker_after_the_caption_step(self):
|
|
"""The marker must sit AFTER auto_caption_clip and carry its result.
|
|
|
|
Announcing the pre-caption path would put the poller back on a file the
|
|
pipeline is about to supersede, which is the bug this fixes.
|
|
"""
|
|
main_src = open("main.py", encoding="utf-8").read()
|
|
caption_at = main_src.index("captioned = auto_caption_clip(")
|
|
# The free plan's served file is a wm_ copy of the captioned final
|
|
# (mark_delivery), so the marker must also come after that step.
|
|
served_at = main_src.index("served = captioned or deliver_path")
|
|
mark_at = main_src.index("served = mark_delivery(served)")
|
|
marker_at = main_src.index('print(f"CLIP_READY {i} {os.path.basename(served)}")')
|
|
assert caption_at < served_at < mark_at < marker_at
|