Files
my-vault/.scripts/transcript-extract.sh
T
Noah BrierandClaude 5b00b25240 fix: correct hardcoded folder paths to use underscores
- Fix transcript-extract.sh: `00 Inbox/Clippings` → `00_Inbox/Clippings/`
- Fix firecrawl-batch.sh: `00 Inbox/Clippings` → `00_Inbox/Clippings/`
- Add `-o|--output-dir` flag to firecrawl-batch.sh for custom paths
- Fix update-attachment-links.js: `05 Attachments` → `05_Attachments`
- Fix fix-renamed-links.js: `05 Attachments` → `05_Attachments`
- Fix GEMINI_VISION_QUICK_START.md example paths
- Update README.md with new flag documentation

All folder paths now match actual repo structure (underscores not spaces).
This prevents scripts from failing due to incorrect directory references.

Fixes #9

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-12 21:25:52 -04:00

69 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Transcript extraction script for YouTube videos
# Usage: .scripts/transcript-extract.sh <youtube-url> [output-path]
# Default output: 00_Inbox/Clippings/
set -e
URL="$1"
OUTPUT_PATH="${2:-00_Inbox/Clippings/}"
if [ -z "$URL" ]; then
echo "Usage: $0 <youtube-url> [output-path]"
echo "Default output path: 00_Inbox/Clippings/"
exit 1
fi
echo "🔍 Extracting transcript from: $URL"
echo "📁 Output path: $OUTPUT_PATH"
# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_PATH"
# Extract video ID and title
VIDEO_ID=$(yt-dlp --get-id "$URL")
TITLE=$(yt-dlp --get-title "$URL")
SAFE_TITLE=$(echo "$TITLE" | sed 's/[^a-zA-Z0-9 -]//g' | sed 's/ */ /g' | cut -c1-80)
DATE=$(date +%Y-%m-%d)
echo "📹 Video: $TITLE"
echo "🆔 Video ID: $VIDEO_ID"
# Try to extract captions first (fastest method)
echo "🎯 Attempting to extract captions..."
if yt-dlp --skip-download --write-subs --write-auto-subs --sub-langs 'en.*' --sub-format json3 -o '%(id)s.%(ext)s' "$URL"; then
echo "✅ Captions extracted successfully"
# Convert to markdown
FILENAME="$OUTPUT_PATH/$DATE - $SAFE_TITLE - Transcript.md"
cat > "$FILENAME" << EOF
# $TITLE - Transcript
**Source:** $URL
**Title:** $TITLE
**Video ID:** $VIDEO_ID
**Extracted:** $DATE
**Method:** YouTube captions via yt-dlp
---
EOF
# Process JSON3 captions to clean text
jq -r '.events[] | select(.segs) | .segs | map(.utf8) | join("")' *.json3 | \
sed -E 's/\s+/ /g; s/♪//g; s/^\s*//; s/\s*$//' | \
grep -v '^$' >> "$FILENAME"
# Cleanup temporary files
rm -f *.json3
echo "✅ Transcript saved to: $FILENAME"
echo "📝 $(wc -l < "$FILENAME") lines extracted"
else
echo "❌ No captions available for this video"
echo "💡 You could try manual transcription tools if needed"
exit 1
fi