| from __future__ import annotations |
|
|
| from copy import deepcopy |
| from typing import Any |
|
|
|
|
| PRESETS: dict[str, dict[str, Any]] = { |
| "tiktok_9_16_fast": { |
| "creative_style": "viral_shorts", |
| "platform": "tiktok", |
| "template": "tiktok_classic", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "preview": False, |
| "normalize": True, |
| }, |
| "youtube_shorts_hd": { |
| "creative_style": "viral_shorts", |
| "platform": "youtube_shorts", |
| "template": "youtube_shorts", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "normalize": True, |
| }, |
| "podcast_square": { |
| "creative_style": "podcast_clip", |
| "platform": "instagram_feed_square", |
| "template": "podcast_style", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "normalize": True, |
| "metadata": {"target_aspect": "1:1"}, |
| }, |
| "reels_with_subtitles": { |
| "creative_style": "story_vlog", |
| "platform": "instagram_reels", |
| "template": "modern_minimal", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "normalize": True, |
| }, |
| "draft_preview": { |
| "creative_style": "product_demo", |
| "platform": "tiktok", |
| "template": "modern_minimal", |
| "subtitle_format": "ass", |
| "preview": True, |
| "normalize": True, |
| }, |
| "tiktok_music_ducked": { |
| "creative_style": "viral_shorts", |
| "platform": "tiktok", |
| "template": "tiktok_classic", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "audio_normalize": True, |
| "music_volume": 0.25, |
| "music_fade_in": 0.4, |
| "music_fade_out": 1.0, |
| "music_loop": True, |
| "music_ducking": True, |
| "normalize": True, |
| }, |
| "instagram_reels_music": { |
| "creative_style": "story_vlog", |
| "platform": "instagram_reels", |
| "template": "modern_minimal", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "audio_normalize": True, |
| "music_volume": 0.28, |
| "music_fade_in": 0.3, |
| "music_fade_out": 0.8, |
| "music_loop": True, |
| "music_ducking": True, |
| "normalize": True, |
| }, |
| "youtube_landscape_1080p": { |
| "creative_style": "news_explainer", |
| "platform": "youtube_1080p", |
| "template": "news_style", |
| "subtitle_format": "ass", |
| "auto_subtitles": False, |
| "audio_normalize": True, |
| "normalize": True, |
| }, |
| "capcut_viral_auto": { |
| "creative_style": "viral_shorts", |
| "platform": "tiktok", |
| "template": "neon_pop", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "audio_normalize": True, |
| "music_volume": 0.24, |
| "music_fade_in": 0.2, |
| "music_fade_out": 0.8, |
| "music_loop": True, |
| "music_ducking": True, |
| "normalize": True, |
| }, |
| "capcut_product_launch": { |
| "creative_style": "product_demo", |
| "platform": "instagram_reels", |
| "template": "product_demo", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "audio_normalize": True, |
| "music_volume": 0.18, |
| "music_fade_in": 0.3, |
| "music_fade_out": 0.7, |
| "music_loop": True, |
| "music_ducking": True, |
| "normalize": True, |
| }, |
| "capcut_cinematic_story": { |
| "creative_style": "cinematic_story", |
| "platform": "youtube_shorts", |
| "template": "cinematic_gold", |
| "subtitle_format": "ass", |
| "auto_subtitles": True, |
| "audio_normalize": True, |
| "music_volume": 0.26, |
| "music_fade_in": 0.8, |
| "music_fade_out": 1.4, |
| "music_loop": True, |
| "music_ducking": True, |
| "normalize": True, |
| }, |
| } |
|
|
|
|
| def list_presets() -> list[str]: |
| return sorted(PRESETS) |
|
|
|
|
| def apply_preset(payload: dict[str, Any]) -> dict[str, Any]: |
| preset_name = payload.get("preset") |
| if not preset_name: |
| return payload |
| preset = deepcopy(PRESETS.get(preset_name, {})) |
| preset.update(payload) |
| if "metadata" in PRESETS.get(preset_name, {}) or "metadata" in payload: |
| metadata = deepcopy(PRESETS.get(preset_name, {}).get("metadata", {})) |
| metadata.update(payload.get("metadata", {})) |
| preset["metadata"] = metadata |
| return preset |
|
|