Wave 2: Script quality and other changes - #1
Merged
Conversation
… FFmpeg 0-byte read at EOF Adiciona _ensure_duration() que faz loop dos clips fonte com concatenate_videoclips() para garantir que cubram todo o target_duration. Aplica em _create_with_overlay_mode (blurred bg e fg) e _create_simple_mode. Antes: FFMPEG_VideoReader devolvia 0 bytes ao ler frames além do fim do arquivo -> MoviePy silenciava com 'using last valid frame' -> output congelado e render acelerava artificialmente sem fazer decode real.
The Resize effect changes pixel dimensions but leaves clips at the default
top-left (0,0) position, making the zoom appear anchored to the corner.
Adding with_position(('center', 'center')) centers the clip dynamically
at each frame, so the zoom emerges from the center.
- Remove FALLBACK_PARAGRAPHS ('No final fica uma licao...') entirely
- Remove 'Do NOT fact-check yourself' from the draft prompt
- Add _is_filler() and _validate_paragraphs() to detect/reject vague paragraphs
- All prompts now require: verifiable fact per paragraph, factual conclusion,
correct date calculation, explicit ban on 'fica uma licao'
- Pipeline now fails early (return False) if generated script has <3 paragraphs
- Search queries with more specific terms (fundacao, dados, estatisticas)
…t-generation fact verification - Replace draft-derived LLM queries with _generate_search_queries(): a separate LLM call with a neutral prompt that has never seen the draft, eliminating the circular 'draft -> queries confirming draft -> more draft' loop - Add _verify_factual_claims(): extracts all years from the generated script, searches each year + subject via DDGS, then calls the LLM as a strict fact-checker to cross-reference every claim against web sources - Add _generate_title_from_script(): generates title from final script instead of draft - Update all tests for the new 3-call flow (queries -> script -> title)
…language Every prompt now includes TONE (dramatic/scandalous), FIRST SENTENCE (hook, not dry date), STRUCTURE (Hook -> Context -> Drama -> Ending), and FORBIDDEN (Ltda, S.A., addresses, corporate speak). _is_filler() expanded to catch legal/corporate patterns. Paragraphs shortened to 1-2 punchy sentences.
The old prompt forced terms like 'explicado', 'documentario', 'reportagem', 'historia' into every query, causing YouTube to return generic explainer videos (e.g. FNAF explainers) instead of subject-specific content. Removed those keywords and the 'family-friendly educational' framing. Now the LLM generates specific queries with concrete names and events.
…inst subject - _repair_paragraphs(): generate only missing paragraphs via LLM instead of full draft regeneration - _is_suitable_video(): reject videos whose title lacks subject keywords - _generate_title_from_script: PT-BR prompt to avoid mixed-language titles - _verify_factual_claims: extract scores, tabus, and date contexts alongside years - Consolidate all prompts to use _tone_instructions() - remove duplicated tone rules
….loads list, None title, missing .get())
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR:
fix/script-qualitySummary
20 commits focused on script quality, data sanity, and pipeline robustness for explainer videos.
Changes
🎬 Script Generation (
script_generator.py)🔧 Robustness
_make_json_api_call: Addedisinstance(result, dict)guard — API could return an array and crash all.get()callers._validate_paragraphs: Addedisinstance(p, str) andfilter — LLM sometimes returns dicts instead of strings.video_background.py: Fixed.lower()crash onNonetitle from yt-dlp. Changedr["href"]→r.get("href")to preventKeyError.web_search.py: Changedr["snippet"]→r.get("snippet")to preventKeyError.tts_system.py: Added try/except with fallback forfloat("")crash when ffprobe fails.explainer.py: Sanitized output filenames (?,:,", etc) — Windows FFmpeg crashed on invalid characters.🖼️ Image Searcher
crossdresser,hentai,porn,onlyfans, etc) and keywords in DDGS image titles/URLs.🧪 CLI
--batch: Now accepts a single string with semicolon-separated topics instead oflist[str].🧹 Type Safety
Files Changed
13 files, +814/−227