Commit graph

36 commits

Author SHA1 Message Date
michael
2ebe470a83 feat(download): use signed URLs for video download
Download button now redirects to backend endpoint that generates
GCS signed URLs with Content-Disposition: attachment header,
forcing browser download instead of opening in new tab.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 14:48:06 -06:00
michael
1c996c5919 fix: add backward compatibility for in-flight tasks during GCS migration
Handle both old (audio_path) and new (audio_blob_path) keys in create_video
task to support tasks that were queued before the GCS migration deployed.
Also properly detect local vs GCS paths for photo_path.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 09:23:08 -06:00
michael
c41e559e81 feat: migrate file storage from local filesystem to Google Cloud Storage
- Add google-cloud-storage dependency to requirements.txt
- Add GCS configuration settings to config.py
- Create storage.py utility module with upload/download/delete operations
  and temp file context managers for video generation
- Update submissions.py to upload photos to GCS and return full GCS URLs
- Update results.py to return full GCS URLs for video and record image
- Update workers.py to use GCS for audio download, video creation, and cleanup
- Update result.js to use audio_url directly from API response
- Update docker-compose.yml with GCS credentials mount

Storage now uses GCS bucket vday2026 in project holiday-project-india.
Database stores blob paths; URLs constructed at API response time.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 08:40:42 -06:00
Harshad
cc84dee940 vertical video background image 2026-02-04 22:07:43 +05:30
Harshad
da2a247e97 feat(video): change layout to vertical 2026-02-04 22:07:05 +05:30
michael
05a8115dd0 feat: add human detection using NudeNet for pet photo validation
Adds server-side image safety check to ensure users upload pet photos instead
of human images. Uses NudeNet with 0.5 confidence threshold and fail-open
behavior. Frontend shows loading state during analysis and error UI when
humans are detected.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 08:57:23 -06:00
michael
ce95d61796 feat: add server-side profanity filter with real-time validation
Add profanity detection using better-profanity library with:
- Real-time API validation during typing (500ms debounce)
- Defense-in-depth server-side validation on form submission
- Visual feedback with red borders and warning message
- Submit button disabled when profanity detected
- Fail-open behavior on API errors to not block users

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 08:29:58 -06:00
michael
7fa4132cd7 feat(api): add audio_url to status endpoint response
Allows frontend to access the MP3 audio URL as soon as download
completes, even while video generation is still in progress.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 08:04:55 -06:00
michael
2d9c6ca7a7 refactor: convert polling tasks to event-based architecture
- Remove process_pending_queue and check_credits scheduled tasks
- Add check_submission_timeout task for per-submission timeout handling
- Modify send_to_sonauto to schedule timeout check after successful API call
- Reduce check_timeouts frequency to 30min (safety net only)
- Update submissions endpoint to use apply_async with better error logging
- Remove unused config settings (QUEUE_PROCESSOR_INTERVAL, CREDITS_CHECK_INTERVAL)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:28:52 -06:00
michael
621a0ae097 feat: add dedicated Celery queue for video generation
Route create_video task to dedicated 'video' queue with concurrency=2.
Default worker now has concurrency=10 for all other tasks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:11:37 -06:00
michael
4463a6eb04 perf: optimize video generation with faster encoding
- Change frame format from PNG to JPEG (quality 85) for faster encoding
- Use mjpeg input codec instead of png for FFmpeg
- Change preset from 'faster' to 'superfast' for quicker encoding

Trade-off: ~20-30% larger file size for significantly faster generation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 00:01:48 -06:00
michael
6a7429cb9e feat: save composite record image and return URL in results API
Add composite PNG generation (vinyl record + pet photo with transparent
background, no needle) saved to storage/images/. The results API now
returns record_image_url pointing to the composite or default-record.png
for submissions without a user photo.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 19:08:52 -06:00
michael
12a6b5e7af feat: add Happy Hardcore music vibe
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 18:25:35 -06:00
michael
05dcfd6613 fix: make default-record.png square (736x736) to match vinyl template
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 18:20:20 -06:00
michael
1d6aa014ec feat: add Dubstep and Metal Ballad music vibes
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 18:05:59 -06:00
michael
c6ee1e6695 feat: make pet image upload optional
Users can now submit the form without uploading a photo. When no photo is
provided, the video will display the default "Pet Love Songs" record instead
of a pet image in the vinyl center.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 18:03:25 -06:00
michael
1196ad17c7 feat: dispatch to Sonauto immediately on submission
Triggers send_to_sonauto.delay() right after creating a submission,
eliminating up to 60 seconds of wait time. The periodic task remains
as a fallback for edge cases (Celery unavailable, immediate dispatch fails).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:23:51 -06:00
michael
f7ef053d81 fix: resolve 'flush of closed file' error in video generation
Replace communicate() with stderr.read() + wait() after manually
closing stdin. communicate() tries to flush stdin internally which
fails when stdin is already closed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 17:12:38 -06:00
michael
c3d29426e0 refactor: use Sonauto streaming URL directly
Replace backend proxy streaming endpoint with direct access to
Sonauto's public streaming URL (api-stream.sonauto.ai). This
simplifies the architecture and reduces latency.

- Update waiting.php to use task_id from status API response
- Add autoplay attribute to audio element per Sonauto docs
- Remove stream.py proxy router (no longer needed)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 14:32:48 -06:00
Harshad
7de0b10988 create-video minor performance gains 2026-02-03 11:14:04 +05:30
michael
d30ca2d051 fix: Add banned words list to all pet prompts
Add restriction to prevent potentially inappropriate double-meaning
words from appearing in generated song lyrics: pussy, cock, beaver,
bitch, ass, tit, tits, puppies, trouser snake.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:17:18 -06:00
michael
a447994375 feat: Add per-pet-type prompt templates for song generation
Replace the generic song generation prompt with pet-specific prompt
templates. Each pet type (Dog, Cat, Fish, Bird, Hamster, Gerbil,
Guinea Pig, Rabbit, Bearded Dragon, Leopard Gecko, Corn Snake) now
has its own tailored prompt with pet-specific behaviors and content
restrictions.

Also fix typo: "Beared Dragon" → "Bearded Dragon" in schemas.py and
home.js. The prompts.py file includes backwards compatibility for the
old spelling to handle any pending database records.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 09:47:44 -06:00
michael
59357cff06 fix: Fetch Sonauto credits directly if cache is empty
The queue-status endpoint now fetches credits from the Sonauto API
when the Redis cache is empty/zero, making the admin dashboard
more reliable.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 09:21:59 -06:00
michael
9354085694 fix: Remove tags field from Sonauto API request
Sonauto rejects custom tag values. The prompt already contains all
necessary style and content guidance, so tags are not needed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:45:53 -06:00
michael
56bc3d6059 fix: Move music vibe from tags to prompt for Sonauto API
Sonauto only accepts specific predefined tags. The custom frontend
music vibes (Hip-Hop, Boy Band, etc.) were being rejected with 422.

Now using fixed tags ["love song", "valentine"] and including the
music vibe in the prompt text instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:43:10 -06:00
michael
a570ac657f fix: Improve audio streaming reliability and playback
Stream endpoint:
- Increase read timeout to 600s for progressive audio generation
- Use larger 16KB chunks for smoother playback
- Remove misleading Accept-Ranges header (we don't support range requests)
- Add logging for stream start/completion
- Properly close httpx client after streaming

Frontend:
- Wait for 'canplay' event before attempting autoplay
- Add event listeners for play, error, stalled, waiting
- Native audio controls' play button now properly hides tap message
- Add 5s fallback timeout if canplay doesn't fire

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:40:02 -06:00
michael
a411f962f0 fix: Sync backend schema with frontend pet types and music vibes
Frontend was updated in 1b26b7a but backend validation wasn't updated,
causing 422 errors on form submission.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:29:42 -06:00
michael
9c5b054dcc feat: Add Sonauto streaming audio on waiting page
Enable users to listen to their song while video generation continues
in the background. Backend proxies authenticated Sonauto stream API
since HTML audio elements cannot send auth headers.

- Add streaming_ready_at column to track when stream becomes available
- Enable streaming in Sonauto API request payload
- Handle GENERATING_STREAMING_READY webhook status
- Add /api/stream/{session_id} proxy endpoint using httpx
- Update StatusResponse with streaming_ready and task_id fields
- Add audio player UI with autoplay fallback for mobile
- Fade out audio gracefully before redirect to result page

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 08:23:14 -06:00
Harshad
58da81fd73 feat(backend): admin dashboard api 2026-02-01 19:38:11 +05:30
michael
d4376d092b docker: make storage host path configurable
Add STORAGE_HOST_PATH env var for volume mount.
Defaults to ../storage for local dev.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:54:54 -06:00
michael
fa58a15e58 video: fix flush of closed file error
Use wait() instead of communicate() after manually closing stdin.
communicate() tries to flush stdin which fails if already closed.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:42:06 -06:00
michael
318a1e1d8d celery: fix invalid Sonauto tags
Only use the music_vibe as the tag - "love song" and "valentine"
are not valid Sonauto API tags.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:22:59 -06:00
michael
3c7f4142aa celery: add error logging for Sonauto API responses
Also update CLAUDE.md to require commit+push after changes.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:20:40 -06:00
michael
1b2bc8497c celery: bypass credit check for testing
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 08:11:31 -06:00
michael
70b0f665cb celery: fix task autodiscovery 2026-01-31 07:30:26 -06:00
michael
9d53adaaf3 Add backend API, video generator, and frontend updates
- Add Python/FastAPI backend with Celery workers
- Add video generation with FFmpeg (spinning record animation)
- Add API endpoints: submissions, status polling, webhook, results
- Add database schema and Alembic migrations
- Update frontend pages with API integration
- Add project documentation and spec

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 10:31:58 -06:00