Commit graph

461 commits

Author SHA1 Message Date
victorcavero14
696659a828 fix(download): fetch only the paid minutes of a long or endless source
A capped job (MAX_SOURCE_MINUTES, or the SOURCE_CAP_MINUTES safety cap on
every metered job) still downloaded the whole source and cut it after.
On a finished livestream (hours of 1080p60) that meant GBs through the
proxy and a job stuck downloading for tens of minutes, long enough to
outlive a deploy drain and restart on the next instance.

When the source is longer than the cap (plus a margin) or has no known
duration, yt-dlp now downloads only that range (download_ranges);
cap_source_duration still makes the exact cut. Sources within the cap
download exactly as before. The early audio track is skipped for ranged
downloads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:35:04 +02:00
victorcavero14
bb24a5e5ca fix(pipeline): let metered jobs use the early transcript
SOURCE_CAP_MINUTES is set on every metered job, so the early audio path
never ran in production. It is only a safety cap (it cuts a download
clearly longer than the reservation), so the early work now runs there
too and is dropped when the cut actually happens (the file is rewritten
in place: size/mtime change). MAX_SOURCE_MINUTES jobs, which are always
cut, keep the sequential path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 00:18:25 +02:00
victormanuel.caverogracia
aaeffcf002 perf(pipeline): transcribe and pick clips while the video downloads
The audio track is fetched on its own, in parallel with the video (same
m4a format the merged mp4 gets), and transcription + the Gemini pick start
as soon as it lands. By the time the video is in, the clips are usually
already chosen and the render starts right away.

- download_youtube_video(on_audio=): background audio-only fetch from the
  already extracted info; never on the per-GB proxy.
- main: uses the early transcript/clips when they are ready; any failure,
  capped sources (the cut is done on the video), checkpoints and
  --transcript keep the old sequential path. EARLY_AUDIO=0 turns it off.

Bench (real downloads, alternating runs): render starts 2-17 s sooner
with fast downloads and replayed Gemini; the transcript is identical.
Also drops internal details from comments and CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 23:51:18 +02:00
victormanuel.caverogracia
a404a11673 fix(hooks): say why the combined hook+captions pass failed
3 of 40 prod clips fell back to the two-pass path with no visible reason:
the job log truncates the CalledProcessError (argv first). Log the exit
code and the last non-progress stderr lines instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 21:13:42 +02:00
victormanuel.caverogracia
1679f8d7dc docs(claude): what the 25-sep speed work changed and how it was measured
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 20:42:07 +02:00
victormanuel.caverogracia
991cdef3ba perf(download): extract the video once per attempt, not twice
ydl.download([url]) re-ran the whole extraction (player clients, API JSON,
m3u8) that extract_info had just done: 4-9 s of round trips per attempt.
The unprocessed info is now handed to process_ie_result. Same file (MD5)
on a real 1080p video; falls back to ydl.download for playlists and
anything without formats.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 20:39:21 +02:00
victormanuel.caverogracia
6e660d8f92 perf(pipeline): GPU cut, CPU VAD, cheap blur, hook+captions in one pass, 6 clip workers
Same clips to the eye (SSIM 0.990-0.9998 vs before, audio identical,
frames checked by eye), faster:
- Cut on the card end to end (NVDEC -> NVENC, hwaccel_output_format cuda)
  for 8-bit 4:2:0 h264/hevc/vp9/av1 sources; byte-identical decoded frames
  to the CPU cut, -64% CPU. Anything else, or a failed GPU cut, decodes on
  the CPU as before.
- Silero VAD on one CPU thread instead of CUDA (one 32 ms chunk per launch):
  transcription 2-3x faster (9 min audio: 28 -> 9 s). Over 3,939 words one
  changed ("claudio" -> "cloud", said "Claude") and a few times moved <=48 ms.
- The blurred backdrop is blurred at quarter size and scaled up
  (ffmpeg_utils.blurred_backdrop): ~45% less CPU on those segments.
- hooked_ and subtitled_ come out of ONE ffmpeg (hooks.add_hook_to_video
  also=...), one decode instead of two; subtitled_ is one generation fewer.
  Same filenames, so the editor's walk-back is unchanged. Falls back to the
  two passes if the combined one fails.
- CLIP_WORKERS default 3 -> 6: -14-16% wall per job at load 48-67, same CPU,
  peak VRAM 12 GB of 20.

Bench on balrog (3 Carlos Gracia videos, old/new side by side).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 20:28:22 +02:00
victormanuel.caverogracia
90b10c1902 perf(render): burn the watermark in the reframe encode; read AV1 sources
- The free-plan watermark (~97% of jobs) rode a pass of its own: decode
  the finished clip, overlay, encode it all again. It now goes into each
  reframe segment's own encode (reframe_v2.render(watermark=True), same
  geometry via main.watermark_filter). One NVENC encode less per clip; the
  v1 fallback and horizontal clips still use apply_watermark. The editor's
  paths (recut.py) are untouched.
- layout_picker.sample_frames falls back to the ffmpeg CLI when OpenCV
  reads no frame: OpenCV's bundled FFmpeg has no AV1 software decoder, so
  AV1 YouTube sources always got the default layout. H.264 sources return
  byte-identical frames (same JPEG MD5).

Bench on balrog, 3 videos, old and new run side by side: job CPU -27 to
-43%, wall -6 to -12%; clips SSIM 0.990-0.999 vs before (one generation
fewer), audio identical, watermark position checked by eye.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 19:47:34 +02:00
victormanuel.caverogracia
a4c92cac2c perf(pipeline): halve a job's CPU with byte-identical clips
Reverts 1d3d20c (NVDEC decode + quarter-size blur): it changed the
delivered pixels (SSIM 0.998-0.9997, not identical), and clips must not
change. Replaces it with two fixes that leave every clip byte-identical.

- Parakeet's onnxruntime pool threads no longer spin
  (transcribe_backends.parakeet_session_options). While the GPU did the
  work they burned ~160 CPU-s per 9 min of audio, the biggest CPU cost of
  a job. The VAD keeps load_vad's defaults: any options there make
  onnx_asr drop its default providers and a word changes.
- analyze_scenes_strategy and split_layout read their sampled frames in
  one forward pass (frame_sampler.read_at) instead of a seek per sample,
  which re-decoded the GOP every time: 89 -> 6 CPU-s for one clip's
  samples, same frames.

Bench on balrog, 3 Carlos Gracia videos (2.5/9/17 min, 15 clips), Gemini
decisions recorded once and replayed: every clip identical to the old
code (decoded-frame MD5s + audio). Serial stage profile of the 9 min
video: 629 -> 273 CPU-s per job; Python side 332 -> 57 CPU-s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:40:22 +02:00
victormanuel.caverogracia
cbf0eb37f3 ci: install greenlet explicitly (SQLAlchemy asyncio no longer pulls it in)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 13:34:28 +02:00
victormanuel.caverogracia
1d3d20c77c perf(render): decode on the GPU and blur the backdrop at quarter size
At peak (8 jobs x 3 clip workers) balrog sat at load ~100 on 20 threads
while the RTX 4000's decoder stayed at 0%: NVENC only took the encode, and
decoding plus the filter graphs ran on the CPU, starving the Coolify builds
and every other service on the box.

- ffmpeg_utils.video_decode_args(): -hwaccel cuda before the video input
  whenever the encode is on nvenc (FFMPEG_HWDECODE=0 turns it off). Used in
  the cut, the reframe v2 segments, watermark, hook and caption passes.
- ffmpeg_utils.blurred_backdrop(): the GENERAL and INSET blurred fill blurs
  at a quarter of the output size and scales up, instead of a full-size
  gblur on 1080x1920.

Measured in the prod container on a real 1080p source, 10 s GENERAL
segment: ~16-18 s of CPU before, ~5-7 s after, SSIM 0.994 against the old
output. All four hwaccel passes checked end to end on the prod GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 13:33:30 +02:00
victorcavero14
0e5b733385 test: use documentation-only tailnet addresses in the SSRF tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 00:45:50 +02:00
victorcavero14
497de58a1f fix(api): upload to Upload-Post off the event loop
/api/social/post and the AI Shorts post sent the clip with a sync
httpx.Client inside an async handler, so the whole API froze for the
length of the upload. 23-sep-2026 19:47:48 UTC: one TikTok+YouTube post
stalled every request, /health included, for 42 s and the uptime monitor
paged "openshorts-api down" for 2 min. Both uploads (and the actor image
fetch in saasshorts_generate) now run through asyncio.to_thread; an AST
test rejects blocking httpx/requests calls inside async defs in app.py.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 00:37:02 +02:00
victorcavero14
d585b93ea2 feat(dashboard): say a video is too short the moment it is picked
Uploads under 45 s (MIN_SOURCE_SECONDS) were only rejected by the server after
the whole file went up. The browser now reads the file's duration on select,
explains why it cannot be clipped, keeps Generate disabled, and the drop zone
states the minimum. A file the browser cannot read is left to the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 08:38:52 +02:00
victorcavero14
681bfb5719 fix(dashboard): show why a job was rejected instead of a generic failure
A new user in the first-clips tutorial who submitted a 30 s video saw only
'That run failed. Try another video'; the server's actual reason ('this video
is only 30s long, clip generation needs at least 45s') was hidden, and outside
the tutorial it landed in the log panel as raw JSON. The FastAPI detail is now
read into plain text and shown in the tutorial card and the logs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 08:34:27 +02:00
victorcavero14
56484dac02 fix(tools): tell a caption-less video from a throttled route; AAC audio in 9:16 MP4s
- Transcript: a finished live stream answers with a duration and no formats,
  and was being reported as "YouTube is blocking us". The degraded-route test
  now keys on the missing duration (watch page served without its player
  response, seen anonymously on two of the three statics), so real
  no-caption videos get the honest no-captions answer. Global daily cap
  1,500.
- 9:16 converter: request AAC for MP4 output when the browser can encode it
  (Opus-in-MP4 does not play in Safari) and only trim when the video is over
  the 5 minute cap; show a frame in the preview instead of a black box.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 01:19:20 +02:00
victorcavero14
8a8db96ec3 fix(billing): withdraw free minutes from temp-mail farms and re-registrations
- users.free_plan_denied (nullable, additive ALTER at boot): when set,
  free_plan_eligible is False for any sign-in method; paid plans and
  top-ups are untouched. is_free_user keeps such accounts on the free
  7-day retention.
- Sign-up (magic link and Google) stamps "recreated_after_deletion" when
  the address's fingerprint is in account_deletions within
  FREE_REDO_BLOCK_DAYS (90): deleting and re-registering reset the
  monthly 20 minutes.
- A magic-link request for an existing account re-checks its MX and stamps
  "disposable_mx" when it matches the list (never blocks the sign-in).
- disposable_mx.txt: wabblywabble.com, wallywatts.com (the sep-2026 farm,
  ~100 front domains), den.yt, temp-mail-pro.com.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 01:03:05 +02:00
victorcavero14
4bcdc36a6f fix(security): block tailnet SSRF, gate the quality probe, strip job secrets
- security_utils: accept only is_global addresses (100.64.0.0/10, the
  Tailscale range, went through is_private), judging IPv4-mapped / 6to4 /
  Teredo / NAT64 IPv6 by the IPv4 inside.
- /api/process validates the URL (public host, one YouTube video) before
  anything fetches it, and the quality probe now runs after the metering
  step (balance, job limit, hourly probe cap); a low-quality confirm or a
  too-short source hands the reservation back. quality_probe.py checks the
  same itself, passes noplaylist and no longer disables TLS verification.
- Metered whole-video URL jobs carry SOURCE_CAP_MINUTES = reserved minutes
  (job env + resume manifest); main.py cuts a download clearly longer than
  that, so a server cannot answer the probe short and the download long.
- main.py / quality_probe.py get child_env(): the server secrets (Stripe,
  JWT, DB, SMTP, Telegram, R2, AgentLedger, managed keys) are dropped; a
  test fails if the pipeline ever reads one.
- /api/social/user no longer logs the whole Upload-Post profile list.
- Owner checks on /api/thumbnail/generate, /api/thumbnail/publish/status
  (dashboard now polls with apiFetch) and /api/render/{id}; /video/{id}
  and /gallery escape every interpolated value and drop non-http URLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 01:03:05 +02:00
victorcavero14
8de011ed36 feat(seo): free tools hub, /auto-clip and /youtube-automation, SEO-page attribution
Free tools (no login), linked from nav and footer via /tools:
- /youtube-transcript-generator: reads the captions a video already has on
  YouTube (free_tools.py, yt-dlp over the flat-rate static proxies only, never
  the per-GB proxy, never the GPU). Per-IP limits, global daily cap, 24 h
  cache, honest "no captions" answer with a CTA to the clip generator.
  Copy / TXT / SRT export in the browser.
- /youtube-tag-generator: tags, 10 titles or a description from a brief, one
  Gemini text call, rules taken from YouTube's own docs (sourced on the page).
- /video-aspect-ratio-converter: 16:9 to 9:16 in the browser with mediabunny
  and WebCodecs (blur / crop / bars), nothing uploaded.
Tool pages keep the form in the static HTML; the behaviour is a Vite entry
(dashboard/tools) that vite-plugin-seo resolves by name.

New pages /auto-clip and /youtube-automation with real, blurred screenshots
of the Autopilot tab and the connect-an-agent card, Autopilot rules from
cloud/autopilot.py, plan prices from the billing API and aggregate usage
from the ledger (dated).

SEO fixes: titles/metas for /how-openshorts-works, /podcast-to-shorts, /mcp
and /free-ai-clip-generator (brand queries at pos 1-2 with <1% CTR); a free
AI clipper / free clipping website section and FAQ, and contextual "free AI
clip generator" anchors from sibling pages and the homepage.

Attribution: static pages now write the same first-touch os_attrib key the
app writes, so the signup is credited to the page the visit started on
(7,481 of 7,481 signups in 30 days said "/"). Signup, CheckoutStarted and
Subscribed carry landing_path / referrer_host / utm props in OpenPanel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 01:02:01 +02:00
victorcavero14
fdad2a46fa perf(asr): Parakeet peak VRAM 6.1 -> 4.6 GB with the same transcripts
Benchmarked in the prod container on 10 real user videos (40 min of audio,
EN/ES/PT/FR-AR, 4,850 words) before changing anything:

  config              peak VRAM  ASR time  words != prod  ts drift
  prod (batch 8)        6.1 GB     32 s        -             -
  batch 4 + lean arena  4.6 GB     38 s      1 (*)        0.1 ms
  batch 2 + lean arena  4.1 GB     40 s      dropped a sentence
  int8                  3.9 GB    350 s      11.7 %       168 ms

(*) outside the mixed-language clip, which goes to whisper in prod anyway.
Ship batch 4 with the arena growing only by what is requested and no max
cuDNN workspace (those two alone change nothing in the output).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 00:55:08 +02:00
juancarlos.cavero
4cc2fe32e0 fix(selection): score every window and enforce the clip floor
A 9:10 source delivered 3 clips in prod where the pipeline had asked
itself for 6-12. Two independent leaks, both in the chain that derives
the clip count.

The scoring pass SELECTED instead of ranking: "choose up to 3 windows
from this batch" put the shortlist ceiling at 3 * n_batches rather than
shortlist_target, so 9 windows batched 8 + 1 shortlisted 4 of a target
of 8, and clip_count_targets then asked the detail pass for 4-8 clips
instead of 6-12. Every source under ~30 min was starved the same way,
which is the mechanism behind "95% of jobs deliver 3 clips or fewer" —
the clip count D2 retention hangs on (0.4% for 1-3 clips, 16.1% for
4-9). It also discarded the ranking it was computing: a batch holding
five great moments could still contribute only three, while a batch of
filler contributed its own three. The prompt now scores every window it
is given and the shortlist is the global top N.

Batches are near-equal instead of "full ones plus the remainder": a
trailing batch of one window came back with that window whatever its
score, because a cap of 3 cannot filter a batch of 1, so the tail of the
video entered the shortlist by arithmetic. Same call count as before.

And the floor was only a sentence in the detail prompt, with nothing in
code checking it, so a pass that returned half shipped half. When it
comes back under min_clips the shortlist windows that produced nothing
get one more call for the difference; an empty answer is accepted,
because padding is worse than a short list.

Measured on that source, same transcript, three runs: shortlist 4 -> 8,
clips 4 -> 6, cost unchanged (~$0.005, 3 calls).
2026-09-23 00:27:14 +02:00
victorcavero14
d4480c6257 feat(queue): auto-retry transient failures, resume on shutdown, queue position
- A job that fails for a reason on our side (CUDA/OOM, NVENC, cublas,
  Gemini 5xx, no clip rendered) is re-queued once after 30 s, keeping its
  reservation and transcript checkpoint. Content failures stay final.
- main.py renders clips best-score first and retries each failed clip once.
- A deploy's drain timeout no longer fails and refunds running jobs: the
  child is killed, the manifest kept, and the next instance resumes it
  (22-sep-2026: 6 jobs failed at once this way). Mid-render manifests are
  resumed instead of being recovered as completed.
- /api/status returns the queue position and an ETA; the dashboard shows
  it with a 'paid plans skip the line' upsell.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 23:48:23 +02:00
victorcavero14
fed9395022 fix(gpu): stop jobs from filling the card (CUDA OOM at peak)
On 22-sep-2026 30-60% of jobs failed per hour at peak with 8 concurrent
jobs on a 20 GB GPU: a job three clips into its render still held 5.9 GB.

- main.py releases the ASR models right after transcribing (Parakeet's
  onnxruntime CUDA arena lived until the process exited); TransNetV2
  empties torch's cache after each pass.
- Host-wide cap on GPU transcriptions (flock slots on the shared output
  volume, ASR_HOST_SLOTS=2), across job processes and deploy containers.
- The queue only starts a job when nvidia-smi reports GPU_MIN_FREE_MB free
  (an idle card always starts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 22:42:52 +02:00
victorcavero14
faf633ed43 fix(deploy): hold new jobs while the draining instance still fills the GPU
During a rolling deploy the old container finishes its running jobs on the
same GPU while the new one starts its own full MAX_CONCURRENT_JOBS. On
22-sep-2026 that was 7 old + 3 new jobs on a 20 GB card: TransNetV2 and
NVENC ran out of memory and 5 of 12 managed jobs failed. The new instance
now counts the jobs another instance is heartbeating and waits until the
total fits (bounded by the drain timeout; a killed instance goes stale in 60 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 22:18:09 +02:00
victorcavero14
b7b5e95e7c fix(autopilot): send the YouTube consent cookie when checking for Shorts
From the EU prod servers every /shorts/<id> HEAD is first a 302 to
consent.youtube.com, which read as 'not a Short' and let a 53 s Short
through to the pipeline. With SOCS/CONSENT set, a Short answers 200 and a
regular video 303 to /watch (checked from the prod container).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 22:06:18 +02:00
victorcavero14
8f57560fa5 feat(autopilot): clip every new video on the connected YouTube channel
Most subscribers use OpenShorts on one day and cancel. Autopilot makes the
value recur: once switched on, every new upload on the user's YouTube channel
(listed through the existing Upload-Post connection, no scraping) is sent
through the normal /api/process pipeline, the user gets an email when the
clips are ready, and with autopublish on the best clips are scheduled on
their socials, one a day.

- cloud/autopilot.py: poller, in-process job submission as the user,
  completion hook, autopublish, and /api/autopilot{,/videos,/run}
- guard rails: only videos published after switching on, max 3 days old,
  1 automatic job per user per day, first N minutes per video, Shorts skipped,
  paid plans only, dedupe by (user, video) across the deploy handover
- dashboard: new Autopilot tab (sidebar + mobile menu, #app?tab=autopilot)
- connect page can return to the Autopilot tab
- analytics: ClipsDelivered/JobFailed now report source=url and the plan

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 21:36:19 +02:00
victorcavero14
ea789999e8 fix(cleanup): never sweep a job that is still queued or running
The hourly sweep deleted job dirs and source uploads by age alone. With the
queue backed up (22-sep-2026) free jobs waited over an hour, so their dir
was removed under the worker: no clips, and the minute reservation stayed
held until the 3 h stuck sweep. 21 free users lost their job that way today,
most of them on their first run.

- _job_is_active(): running here, queued/processing in memory, or a fresh
  resume manifest (the other instance's jobs during a handover). Manifests
  pin a dir for at most ACTIVE_JOB_MAX_SECONDS (24 h).
- The age sweeps and both size caps skip active jobs and their sources.
- run_job_wrapper settles the reservation from the job record it started
  with, so a vanished entry releases the minutes instead of holding them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-22 20:21:14 +02:00
juancarlos.cavero
4b2cf58922 dashboard: show the full clip 'why' in a popover when it is clamped
The line is clamped to two lines so cards in a row stay level; a long
sentence then reads as '...how easily audiences...' with the rest only in
the native title tooltip. When the text actually overflows, hovering
(desktop) or tapping (touch) now floats the whole sentence over the card,
so nothing grows and the grid stays aligned.
2026-09-21 23:28:03 +02:00
juancarlos.cavero
36dba9b3b1 feat(selection): say why each clip was picked, drop clips that overlap a better one
The detail pass now returns a one-sentence `why` per clip (what makes this
moment a clip, not the topic), stored in the metadata and shown under the
title in the dashboard card: the score said how much, nothing said why.
Defaulted in the schema so a small local model that skips it keeps the clip.

After the word snap, clips overlapping an already-kept clip by half the
shorter one are dropped in favour of the higher predicted_score. The prompt's
DIVERSITY rule was the only thing preventing the same moment twice; in ~330
clips over 8 talks it never fired, so this is a guard, not a fix.

Each clip also keeps the model's raw `proposed` boundaries before the snap,
which is what made boundary accuracy measurable: p90 0.4-0.5 s from a word
on 8 talks (21-sep-2026), inside snap_clip_to_words' 1.5 s reach.

Two ideas borrowed from AutoClip were measured with a blind judge on the
same corpus and NOT adopted: quoting per-sentence timestamps in the detail
pass lost 24%/23% (p<0.001, two seeds — it shortens clips and drops the
payoff), and an "end on the reaction, not the line" rule was inert
(47%/53%, p=0.71).
2026-09-21 22:47:55 +02:00
juancarlos.cavero
0db0a3a04b fix(proxy): refuse every YouTube URL that is not one video, by allowlist
The guard named the pages it knew (search, playlist, channel, @handle)
and let everything else through. A hashtag page and the legacy /<vanity>
channel URL are neither, so yt-dlp paginated the browse: on 20-sep-2026
one of them walked to page 23 on the static pool, the "Unable to
download API page" errors that produced read as an IP problem, and the
per-GB proxy was paid to walk the same pages again until YouTube
rate-limited it.

The set of pages that fan out is open-ended, so invert it: allow only
the paths that carry a video id (watch?v=, youtu.be/<id>, shorts, live,
embed, v, e, clip) and refuse the rest before any request. A
single-video shape we forgot costs the user one clear error message; a
browse we forgot costs a paginated crawl on three IPs plus the paid one.
2026-09-21 03:56:59 +02:00
juancarlos.cavero
ff2fd1005e fix(gemini): upload the source by handle, not by path
Handed a path, the SDK copies os.path.basename(path) verbatim into the
X-Goog-Upload-File-Name header, and httpx encodes header values as ASCII.
The downloaded file is named after the video's title, so every source
titled in Japanese, Cyrillic, Arabic or Greek died with "'ascii' codec
can't encode characters in position 0-4" before a byte left the
container, on the three stages that upload the whole file: the
silent-footage vision pass, the screencast detector and the AI editor.
The user saw "the AI model did not return usable clips for this video".

gemini_worker.upload_media() passes an open handle instead, which skips
that header; the readable name still travels as display_name, in the
JSON body, which is UTF-8. An extension the stdlib cannot place falls
back to video/mp4 rather than reaching the API as octet-stream.

The test reproduces the failure through the SDK's own header building
and httpx, and fails if a new call site uses files.upload directly.
2026-09-21 03:56:59 +02:00
juancarlos.cavero
86bbc8b1cb fix(gpu): release the ASR models after a SaaSShorts transcription too
30 minutes after 60fa37a reached prod the uvicorn process held 5.1 GB of
VRAM again, with the release counter at zero: saasshorts.generate_tiktok_subs
transcribes in-process through its own call to transcribe_media, a third
path next to the thumbnail studio and the dubbed-subtitle one. Same
finally-release there, and release_models() now also drops the TransNetV2
singleton that the same in-process pipeline leaves in torch.
2026-09-21 03:56:59 +02:00
Víctor Cavero
27d4916ca7
SEO: medir las páginas SEO, convertirlas y ampliar el cluster de comparativas (#86)
* feat(seo): measure the SEO pages, convert from them, and widen the cluster

The audit of 17-sep-2026 found the static SEO surface ranking at positions
1.8-4 with a 0.2-1.6% CTR while leaking every click it earned: the pages
carried no analytics at all (~424 clicks/month invisible, confirmed with
curl), the only link into the app was the fixed nav button, ten internal
links pointed at /cdn-cgi/l/email-protection, thirteen titles and
twenty-one descriptions were past the length Google renders, and every URL
in the sitemap claimed the same lastmod.

What changes, and how it is verified:

- Analytics (render.js). The shim, the %VITE_OPENPANEL_*% gate and
  ANALYTICS_HOSTS are ported verbatim from index.html, plus the init call
  the SPA makes from lib/consent.js — first-party measurement is exempt
  from prior consent and always on, so there is nothing to ask here. Vite
  only rewrites index.html and these files are emitted assets, so the
  plugin substitutes the placeholders itself; unset still yields an inert
  page. Verified by building with and without the variables.

- Body CTA (render.js, per-page copy in pages.js). Rendered between the
  TL;DR and the body, with the text that fits each page's argument, and
  never on legal pages or the 404. The link carries utm_* so
  lib/attribution.js can post the click with the signup, and fires a
  SeoCtaClick event so the CTA can be told apart from the nav button.

- Broken mailto links (legal.js). 46 plain-text addresses rewritten as
  <a href="mailto:...">. Cloudflare Scrape Shield turns the bare address
  into a /cdn-cgi/l/email-protection link, which is a 404 for crawlers.

- Titles and descriptions. Every title is now <=60 characters and every
  description <=160, measured across all 35 emitted pages rather than
  eyeballed (/gta-5-clips, merged the same week, was over on both). The
  check is part of the verification, not a one-off.

- Resume the job after sign-in (App.jsx). Pressing "get free clips" with no
  session opened the login modal and dropped the request: the magic link
  lands on a fresh document, so the pasted URL was gone. The request is now
  written down before the redirect and replayed after it, through the same
  handleProcess, so the isSignedIn -> isManaged -> keysMissing gate that
  decides billing is untouched: an unentitled account still lands on
  #/pricing, with the request parked until it pays. Files cannot be
  serialised, so those resume only within the same document.

- Gallery surface (app.py). The gallery head had no canonical; the JSON-LD
  was built from html.escape() output, producing &amp;amp;/&amp;quot; and
  valid-JSON-but-wrong names; the video page's nav and CTAs were relative
  hrefs on the api host, where "/" is a 404 (the app is on www). JSON-LD is
  now serialised as JSON with <> and & escaped as unicode, both pages carry
  their canonical, and cross-host links are absolute. Verified by rendering
  both routes with a monkeypatched gallery: the JSON parses and a title
  with quotes, an ampersand and markup survives round-trip.

- New comparison pages (pages.js): /opus-clip-pricing, /opus-clip-free-
  alternative, /opus-ai, /opus-pro, /vizard-ai-video-to-text,
  /submagic-reviews and a Spanish index at /alternativas. They target
  buying-intent variants (opus clips pricing, opus clip free trial, opus ai,
  opus pro, is vizard ai free) that the existing pages do not answer, read
  every price from data.js, and join the related-page ring, the footer and
  the landing links. /alternatives/vizard also gained the brand Q&A ("Is
  Vizard AI free?"), since "vizard ai" is how its volume is spelled.

Build: npm run build green (35 HTML files, all metadata in range, all
JSON-LD parseable). Tests: pytest tests/ -q, 777 passed, 19 skipped.

* fix(seo): CTA sin UTM interno, tutorial no pisa el job reanudado, mailto en el agente DMCA

- El CTA de las paginas SEO enlazaba al mismo origen con utm_*, lo que
  sobrescribia la atribucion real del visitante en lib/attribution.js y
  partia la sesion en OpenPanel. El evento SeoCtaClick sigue midiendo el clic.
- Alta nueva con un enlace aparcado: no abrir el tutorial intro encima del
  job que se reanuda solo.
- LoginModal solo promete 'tu video esta guardado' cuando el payload es una
  URL; un File no sobrevive al magic link en otra pestana.
- Los dos info@upload-post.com del agente DMCA tambien en mailto.

---------

Co-authored-by: victormanuel.caverogracia <>
2026-09-17 19:26:04 +02:00
juancarlos.cavero
60fa37a969 fix(gpu,proxy): release ASR models in the API, probe one video not the playlist
Three failures measured in prod on 17-sep-2026, one deploy.

1. 5 of 12 jobs failed with "ffmpeg could not cut clip ... exit 187, 0 bytes".
   Exit 187 is AVERROR_EXIT after "h264_nvenc: Could not open encoder":
   VRAM was full. The uvicorn process itself held 7.7 GB of the 20 GB card
   while idle: the thumbnail studio and /api/subtitle on a dubbed clip
   transcribe in-process, and the whisper (ctranslate2) and parakeet
   (onnxruntime CUDA) singletons then lived in the API for good. Both call
   transcribe_backends.release_models() now; the loaders fetch their model
   inside the ASR gate so a release can never pull it from under a running
   transcription.

2. 26 of the 37 probes that reached the per-GB proxy in 10 days were
   `watch?v=X&list=...` or mix links. Neither the probe nor the download set
   `noplaylist`, so yt-dlp walked the whole list, died on its first private /
   age-gated / bot-checked entry (a video nobody pasted), the probe read it
   as an IP problem and paid the proxy to walk the same list again, and the
   user got a 400 for a valid link. Reproduced in the prod container: the
   same URL with noplaylist answers in 9.6 s on a static. The probe also
   keeps every attempt's error per route now, so the anonymous retry's
   bot-check cannot overwrite a "confirm your age" from the cookie attempt
   into an escalation.

3. noplaylist does nothing for a search or a bare playlist URL: one
   `results?search_query=` held the probe thread for 2220 s in the container
   and still failed. Search, playlist, channel and feed URLs are refused by
   path before any request, with a message that says what to paste.
2026-09-17 17:19:57 +02:00
juancarlos.cavero
490ce455c0 chore: ignore CLAUDE.local.md (internal infra notes, repo is public) 2026-09-17 17:19:56 +02:00
juancarlos.cavero
2607d1252e fix(ci): keep the subscriber-alert rule importable without the stripe SDK
The minimal CI env has no stripe package, and the new test imported
cloud.billing, which does. The rule is a pure function of the subscription
state, so it now lives in cloud/config.py next to the state tuples it
belongs with, and billing.py imports it from there.
2026-09-16 23:20:21 +02:00
juancarlos.cavero
03c8a1f887 feat(quota): offer the first N minutes of a long video instead of a bare wall
93 of the 99 quota walls sampled on 16-sep-2026 were shown to accounts with
their 20 free minutes untouched that had pasted a 21-90 min video: asked to
pay before seeing one clip, most left Stripe without paying.

The 402 now carries partial_minutes (the floored balance, at least
PARTIAL_MIN_MINUTES and shorter than the source). The wall shows 'clip the
first N min' next to the plans and resubmits with max_minutes; the server
reserves min(asked, balance) and sets MAX_SOURCE_MINUTES, and main.py cuts
the source in place before anything reads it, so every later stage and the
editor see a short video. The cut travels in the resume manifest so a
redeploy cannot re-run the whole video on a partial reservation. Status and
the results view say which part of the video the clips came from.
2026-09-16 21:02:38 +02:00
juancarlos.cavero
afd29e1718 fix(alerts): announce a subscriber when the payment lands, not when Checkout opens
Stripe creates the subscription in 'incomplete' seconds after the Checkout
page opens, before the user types anything, and the 'New subscriber' alert
fired on that row. In the 30 days to 16-sep-2026, 41 of 68 subscriptions
expired unpaid that way (none a card decline) and each one sent an email.
The alert now fires only for active/trialing rows; an incomplete one that
later pays is announced by the 'Payment received' alert on invoice.paid.
2026-09-16 21:02:38 +02:00
juancarlos.cavero
5c0e01d1c3 docs: document the silent-footage vision fallback
get_visual_clips was named once in passing, in the local-LLM section, and
nowhere explained. Nothing said that it exists, that main.py routes to it
on its own, or that speech_is_sparse() triggers it as well as a missing
audio track. Writing the /gta-5-clips page off the CLAUDE.md I had, I
stated on a live marketing page that silent gameplay could not be clipped
at all, which is the opposite of what the code does.

So: both triggers and their thresholds, why the sparse test exists at all
(music-only and a muted mic transcribe to stray words, which is worse than
silence), what the pass returns and why those clips have no subtitles, and
the ceiling that comes with being the one stage that uploads footage
instead of sampling frames, including the fact that no guard enforces it.
2026-09-15 22:51:28 +02:00
juancarlos.cavero
5cf6c14062 fix(seo): the GTA page was wrong about silent gameplay
It said a stream with no commentary 'gives the picker nothing to score'
and that no amount of tuning fixes it. That is not what the code does.
main.py switches to a vision pass by itself in two cases: NoAudioError,
and speech_is_sparse() coming back true (under MIN_SPEECH_WORDS=8 total
or MIN_SPEECH_WORDS_PER_MIN=5). Gemini then watches the footage and
returns the same 3 to 15 moments in the same duration band, and every
stage after it, layouts and inset detection included, is identical.

So the section becomes a differentiator rather than a disclaimer, since
a transcript-only clipper simply cannot do this. The real constraint is
moved with it and stated plainly: the vision pass is the one stage that
uploads the footage instead of sampling frames, Gemini bills video at
~300 tokens/second, and nothing guards the length, so a silent
multi-hour VOD fails at the model. Clips from that path have no
captions, which is correct and now said out loud.
2026-09-15 22:46:37 +02:00
juancarlos.cavero
6835565dbf feat(seo): add a GTA 5 clips page for the gaming-VOD query cluster
Gaming is the biggest clip-producing category on the vertical platforms and
the one the generic pipeline pages describe worst: the source is a multi-hour
stream VOD, the gameplay fills the whole 16:9 frame, and the only face on
screen is a webcam box in a corner that a centre crop throws away.

The page is built on the two code paths that actually answer that (the
geometric webcam-inset detector and the WIDE layout) plus the arithmetic that
decides the category: per-minute credits against a source measured in hours.
It states the hard limit up front too, that moments are scored from the
transcript, so silent gameplay has nothing to score.

Emits a HowTo node alongside the Article, since the head query here is a
procedure and extraNodes was already supported but unused.

Sitemap lastmod becomes per-page while I am here: the new page is dated
2026-09-15 and stamping every other URL with that date because one page
changed is the fastest way to have a crawler stop trusting the field.
2026-09-15 22:27:18 +02:00
juancarlos.cavero
b08df5568a fix(billing): collect the customer's VAT and legal name at checkout
A company that pays for OpenShorts is never asked for its fiscal data:
the Checkout Session carried no `tax_id_collection`, and
`ensure_stripe_customer` creates the customer with an e-mail and nothing
else. So every B2B invoice goes out addressed to an e-mail address, and
the buyer writes to support asking for a corrected one (ticket #4520) —
which cannot be done in place, because the invoice is issued and its
customer data frozen, so it takes a rectificativa in the accounting.

`customer_update.name` is what makes Checkout save the collected name
onto an EXISTING customer, and we always pass one, so without it the
tax ID would land while the name stayed empty. Not `required`: the form
only shows in supported countries and forcing it adds a field to a
funnel that already converts at ~1%.

Claude-Session: https://claude.ai/code/session_01HmESVgJzPkP3LuUB6fmRL3
2026-09-10 18:25:52 +02:00
juancarlos.cavero
8f64c8385a fix(clips): never hand the reframer a cut ffmpeg failed to write
The cut ran with its return code ignored and stderr captured into a pipe
nobody read, so a failed encode left an empty temp file that flowed on to
render_clip. The job's only visible error was "moov atom not found",
reported three layers downstream by ffmpeg, TransNetV2 and PySceneDetect in
turn, each naming the temp clip rather than the encode that never wrote it.
In prod on 9-sep-2026 that lost all three clips of a job and the cause was
unrecoverable, because the one process that knew it had been discarded.

cut_clip() now checks the return code AND the file size (ffmpeg has been
seen exiting 0 having written nothing), retries twice on the same encoder
after 3s and 9s, and otherwise raises with ffmpeg's own stderr so the job
error text names the real failure.

The retry deliberately stays on the GPU instead of falling back to libx264:
the failure is transient — the same command on the same source cut fine by
hand minutes later — and the nvenc probe is a 256x256 lavfi frame cached for
the life of the process, so it keeps saying yes while a real 1080p session
cannot allocate on a GPU other jobs are filling.

Claude-Session: https://claude.ai/code/session_01GdkAaRGLyARP5aSZaXXF19
2026-09-09 17:44:21 +02:00
juancarlos.cavero
d13fb8e359 fix(probe): retry the duration probe anonymously before paying per GB
With YOUTUBE_COOKIES attached, YouTube answers UNPLAYABLE for every client
(web_embedded, tv_downgraded, web AND mweb) on a share of videos, and yt-dlp
reports that as "Video unavailable". Measured in prod on 9-sep-2026 with
e_04ZrNroTo, same static IP minutes apart: cookies -> UNPLAYABLE on all three
statics; anonymous -> 1080p (137+140). The 6-sep default,mweb fix is no longer
enough on its own.

The download already recovers from this through its anonymous fallback-static
attempt. The probe carried the cookies on every route including the paid one,
so it read a cookie problem as an IP problem ("video unavailable" is in
_IP_SPECIFIC_HINTS) and escalated to DataImpulse, which fails identically with
the same cookies. That is what fired the two paid-proxy alerts that morning,
and a probe that dies outright 400s a video the download would have fetched.

Probe strategies are now (extractor_args, use_cookies): first attempt on a
route authenticated, second anonymous, mirroring the download. With no HD path
(self-host without a PO token provider) the fallback keeps the operator's
cookies, since it is then the only attempt.

Claude-Session: https://claude.ai/code/session_01Qfgs1gca8UeEEZ2pvjjC8i
2026-09-09 12:12:45 +02:00
juancarlos.cavero
5a6f428075 fix(alerts): probe the static pool the way the download asks
The watcher fetched the YouTube watch page through each static IP with a
bare httpx client and no cookies. Anonymously, a datacenter IP making ~400
YouTube hits a day is rate-limited into "Sign in to confirm you're not a
bot", so playabilityStatus comes back LOGIN_REQUIRED and the watcher
declared the pool down. Those same IPs were serving every real download
fine, because a download carries YOUTUBE_COOKIES.

Measured in production on 8-sep-2026, all three statics, same minute:

    anonymous (what the watcher did)  -> LOGIN_REQUIRED
    with the download's cookies       -> OK

while proxy_usage showed 119 YouTube jobs routed to HD-static1 in the last
24 h with zero paid bytes. So the page that said "every download costs
money until the statics are back" fired while nothing was being spent, and
it re-nags every 2 h.

CLAUDE.md already recorded this shape for cloud/metering.probe_url_minutes
("The probe also carries YOUTUBE_COOKIES, like the download does"); the
watcher probe never got the same treatment. It does now, parsed once and
cached, and a blob that is not a Netscape cookie file is recognised before
the stdlib prints "http.cookiejar bug!" into the log every 30 minutes.

The paid probe stays anonymous on the cheap HTTP 204: it is billed per GB
and has no reason to carry a session.

The failure detail now names what YouTube actually said
(playabilityStatus: LOGIN_REQUIRED / UNPLAYABLE / ...) instead of blaming
the IP for every case. With cookies configured, LOGIN_REQUIRED means the
session expired and wants rotating, which is not the same problem as a
flagged address and should not read as one.

Claude-Session: https://claude.ai/code/session_01UZGqjYcZyfmKww1gcyKrp5
2026-09-08 11:30:26 +02:00
victormanuel.caverogracia
41aa9bc013 docs: require green CI after every push (ci-wait)
Claude-Session: https://claude.ai/code/session_0174biCAUrv7B2cBcV6vgUTK
2026-09-08 00:39:19 +02:00
juancarlos.cavero
134ad5431e fix(videos): stop serving the working directory, only deliverables
media_auth landed in 96f0139 with the allowlist and the capability tokens,
but nothing imported it: app.py still mounted /videos as a plain
StaticFiles over OUTPUT_DIR. The module was deployed as dead code and the
hole it was written to close stayed open.

Verified against production on 7-sep-2026, unauthenticated, with nothing
but a job id (which travels in every clip URL the dashboard builds):

    /videos/<job>/.owner                 -> 200, a user uuid
    /videos/<job>/<title>_metadata.json  -> 200, the full transcript
    /videos/<job>/<title>.mp4            -> 200, the untouched source

Wiring media_auth.is_servable into the mount closes the first two, plus
.resume.json (which carries the customer's own webhook_secret),
.transcript_checkpoint.json, .instance and the .layout.json sidecars. A
refused path 404s before touching the filesystem, so it is indistinguishable
from a missing one.

Safe for every consumer: the dashboard reads transcripts through the
authenticated /api/clip/{job}/{i}/transcript, never from /videos, and every
/videos URL the backend builds is a clip, preview (.mp4), scene thumbnail
(.jpg), actor upload (.png) or subtitle (.ass) — all allowlisted.

This is the path half only. The clips themselves and the source video in
the same directory are still public to anyone holding the job id; closing
that needs the capability tokens media_auth also provides, which means
request handlers, an /api/media-token endpoint and the dashboard appending
the token in getApiUrl. That ships with its frontend half, not here.

Claude-Session: https://claude.ai/code/session_01UZGqjYcZyfmKww1gcyKrp5
2026-09-07 21:16:17 +02:00
Victor Cavero
978e549c2e docs: no nombrar hosts internos en la documentación pública
Claude-Session: https://claude.ai/code/session_01UNZxBnD6dnMGEdbvBVwoS7
2026-09-07 20:29:02 +02:00
juancarlos.cavero
a9e2e9b1c4 fix(alerts): keep the reframe v2 failure in a job's error text
A clip render dies in two steps: reframe_v2.render raises (it has a single
`return True` and no False path), main.py prints "Reframe v2 failed
(<Type>: <msg>)" and falls back to the v1 frame loop, and only if v1 also
fails does "Clip N failed" appear. The alert classifier picked the second
line and not the first, so it named the fallback's exception and hid the
one that actually started it.

Both lines are wanted now. This matters because the zero-clip jobs fixed
in ff2ad3d were reported as completed and never alerted at all; from now
on they fail properly and page, and the page should carry the root cause
rather than v1's symptom.

Claude-Session: https://claude.ai/code/session_01UZGqjYcZyfmKww1gcyKrp5
2026-09-07 20:20:50 +02:00
Victor Cavero
5cc3d46997 fix(consent): la medición propia siempre activa; rechazar marketing ya no recarga la página
Claude-Session: https://claude.ai/code/session_01UNZxBnD6dnMGEdbvBVwoS7
2026-09-07 20:04:14 +02:00