Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ def handle_suggest_clips(task_id: str, params: dict):

segments = params.get("segments", [])
top_n = params.get("top_n", 5)
existing_clips = params.get("existing_clips", [])

if not segments:
emit_result(task_id, "error", error="segments is required")
Expand All @@ -522,6 +523,7 @@ def handle_suggest_clips(task_id: str, params: dict):
clips = suggest_with_claude(
segments=segments,
top_n=top_n,
exclude_clips=existing_clips,
progress_callback=lambda pct, msg: emit_progress(task_id, "suggesting", pct, msg),
)

Expand Down
28 changes: 27 additions & 1 deletion backend/services/claude_suggest.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,30 @@ def _dedupe_clips_by_range(clips: list[dict]) -> list[dict]:
return sorted(kept, key=lambda c: c.get("start_second", 0))


def _drop_clips_overlapping(clips: list[dict], exclude_clips: list[dict]) -> list[dict]:
"""Drop clips that overlap an excluded range by >50% of the shorter clip.
The prompt already asks the AI to skip these; this enforces it if it doesn't."""
if not exclude_clips:
return clips
kept = []
for clip in clips:
start = float(clip.get("start_second", 0))
end = float(clip.get("end_second", 0))
dur = max(0.0, end - start)
overlaps = False
for ex in exclude_clips:
ex_start = float(ex.get("start_second", 0))
ex_end = float(ex.get("end_second", 0))
overlap = max(0.0, min(end, ex_end) - max(start, ex_start))
shorter = min(dur, max(0.0, ex_end - ex_start)) or 1.0
if overlap / shorter > 0.5:
overlaps = True
break
if not overlaps:
kept.append(clip)
return kept


def _select_top_by_score(clips: list[dict], top_n: int) -> list[dict]:
"""Keep the highest-scored `top_n` clips, then order them by start time.
Ranking by score must come before truncation — otherwise the earliest clips
Expand Down Expand Up @@ -1014,7 +1038,9 @@ def _parse_seconds(val) -> float:
"_ai_engine": engine,
})

selected = _select_top_by_score(normalized, top_n)
selected = _select_top_by_score(
_drop_clips_overlapping(normalized, exclude_clips or []), top_n
)

if selected:
if progress_callback:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "podcli",
"version": "2.2.1",
"version": "2.3.1",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Version bump not synced with cli/main.go.

cli/main.go hardcodes var Version = "2.2.1" independently of package.json. Bumping only package.json to 2.3.1 leaves the CLI reporting a stale version.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package.json` at line 3, The version update is only applied in package.json,
while cli/main.go still hardcodes the older Version value, so both sources need
to be kept in sync. Update the Version variable in cli/main.go to match the new
package.json version and ensure any future bump changes both package.json and
the cli/main.go Version constant together.

"description": "AI-powered podcast clip generator for TikTok/YouTube Shorts. Transcribe, find viral moments, export vertical clips with burned captions.",
"type": "module",
"license": "AGPL-3.0-only",
Expand Down
2 changes: 1 addition & 1 deletion src/ui/client/ClipDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default function ClipDetail() {

<div className="section">
<label style={labelStyle}>Title & captions</label>
<input type="text" value={title} onChange={(e) => setTitle(e.target.value)} style={{ width: "100%" }} />
<textarea value={title} onChange={(e) => setTitle(e.target.value)} rows={2} style={{ width: "100%", resize: "vertical", lineHeight: 1.5 }} />
<div style={{ display: "flex", gap: 10, marginTop: 10, alignItems: "center" }}>
<select value={captionStyle} onChange={(e) => setCaptionStyle(e.target.value)} style={{ flex: 1 }}>
{CAPTION_STYLES.map((s) => <option key={s} value={s}>{s}</option>)}
Expand Down
12 changes: 11 additions & 1 deletion src/ui/web-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2635,7 +2635,17 @@ app.post("/api/claude-suggest", async (req, res) => {
}

try {
const params: Record<string, unknown> = { segments: segs, top_n };
// Feed already-known moments to the AI so it doesn't re-suggest the same
// ranges: clips already rendered for this video plus current suggestions.
const rendered = uiState.videoPath
? await clipsHistory.getBySource(uiState.videoPath).catch(() => [])
: [];
const existing_clips = [
...rendered.map((c) => ({ start_second: c.start_second, end_second: c.end_second, title: c.title })),
...uiState.suggestions.map((s) => ({ start_second: s.start_second, end_second: s.end_second, title: s.title })),
];

const params: Record<string, unknown> = { segments: segs, top_n, existing_clips };
if (min_duration) params.min_duration = min_duration;
if (max_duration) params.max_duration = max_duration;
const result = await executor.execute<{ clips?: SuggestedClip[] }>(
Expand Down
Loading