# Content Processing Scripts Reference

Scripts for handling content from multiple sources and transforming it into structured slideshow data.

## extract_content.py

Extract and process content from various sources.

### Basic Usage

```bash
# Extract from chat conversation
python scripts/extract_content.py project-path \
  --source chat \
  --file conversation.txt

# Extract from PowerPoint
python scripts/extract_content.py project-path \
  --source pptx \
  --file presentation.pptx

# Extract from API endpoint
python scripts/extract_content.py project-path \
  --source api \
  --endpoint "https://api.notion.com/v1/pages/123" \
  --auth-header "Authorization: Bearer token"
```

### Advanced Extraction

```bash
# Extract with content transformation
python scripts/extract_content.py project-path \
  --source markdown \
  --file slides-content.md \
  --transform extract-headings,clean-text \
  --slide-delimiter "---" \
  --output extracted-content.json

# Extract with AI processing
python scripts/extract_content.py project-path \
  --source text \
  --file raw-notes.txt \
  --ai-processing \
  --model gpt-4 \
  --prompt "Extract slide content with clear headings and bullet points"

# Batch extract from directory
python scripts/extract_content.py project-path \
  --source directory \
  --path /source/documents/ \
  --file-types "md,txt,docx" \
  --merge-output
```

## Content Source Handlers

### Chat/Discord Extraction

Extract structured content from chat exports:

```python
from content_extractors import ChatExtractor

extractor = ChatExtractor()

# Extract from Discord export
content = extractor.extract_discord_channel(
    export_path='/path/to/discord-export/',
    channel_name='project-discussion',
    filter_users=['@designer', '@pm'],
    extract_images=True
)

# Extract from Slack export
content = extractor.extract_slack_workspace(
    export_path='/path/to/slack-export/',
    channel_name='design-reviews',
    date_range=('2024-01-01', '2024-02-01'),
    include_threads=True
)
```

### Presentation Import

```python
from content_extractors import PresentationExtractor

extractor = PresentationExtractor()

# Extract from PowerPoint
content = extractor.extract_pptx(
    file_path='source.pptx',
    preserve_formatting=True,
    extract_speaker_notes=True,
    image_extraction=True
)

# Extract from Google Slides
content = extractor.extract_google_slides(
    presentation_id='ABC123',
    credentials_file='creds.json',
    export_format='json'
)

# Extract from Keynote (via export)
content = extractor.extract_keynote(
    file_path='presentation.key',
    export_method='pdf_ocr'  # or 'xml_parse'
)
```

### Document Processing

```python
from content_extractors import DocumentExtractor

extractor = DocumentExtractor()

# Extract from Word documents
content = extractor.extract_docx(
    file_path='outline.docx',
    heading_levels=[1, 2, 3],
    extract_images=True,
    preserve_tables=True
)

# Extract from Notion pages
content = extractor.extract_notion_pages(
    page_ids=['page1', 'page2'],
    api_token='notion_token',
    include_children=True,
    export_format='blocks'
)

# Extract from Confluence
content = extractor.extract_confluence_space(
    space_key='PROJECT',
    base_url='https://company.atlassian.net',
    credentials=('user', 'token'),
    page_filter='slide'
)
```

## Content Transformation

### transform_content.py

Transform extracted content into slide-ready format.

```bash
# Basic transformation
python scripts/transform_content.py project-path \
  --input extracted/raw-content.json \
  --output content/slides.json \
  --transform slide-structure

# Advanced transformation with AI
python scripts/transform_content.py project-path \
  --input extracted/notes.txt \
  --ai-transform \
  --model claude-3 \
  --style "executive presentation" \
  --target-slides 10

# Custom transformation pipeline
python scripts/transform_content.py project-path \
  --input multiple-sources/ \
  --pipeline "merge,structure,enhance,validate" \
  --config transform-config.json
```

### Content Transformers

```python
from content_transformers import ContentTransformer

transformer = ContentTransformer()

# Structure raw text into slides
slides = transformer.structure_content(
    raw_text="Long form content...",
    slide_count=8,
    style="business_pitch"
)

# Enhance content with AI
enhanced = transformer.ai_enhance(
    content=slides,
    enhancements=['headlines', 'bullet_points', 'call_to_action'],
    brand_voice='professional'
)

# Optimize for presentation format
optimized = transformer.optimize_for_slides(
    content=enhanced,
    max_bullets_per_slide=5,
    max_words_per_bullet=12,
    readability_level='executive'
)
```

## Content Validation and Quality

### validate_content.py

```bash
# Validate content structure
python scripts/validate_content.py project-path \
  --check structure,completeness,readability

# Validate against brand guidelines
python scripts/validate_content.py project-path \
  --brand ce \
  --check-tone \
  --check-terminology

# Generate content quality report
python scripts/validate_content.py project-path \
  --report content-quality.json \
  --recommendations
```

### Content Quality Checks

```python
from content_validators import ContentValidator

validator = ContentValidator()

# Check slide structure
structure_issues = validator.validate_structure(content)
for issue in structure_issues:
    print(f"Slide {issue.slide_id}: {issue.message}")

# Check readability
readability = validator.check_readability(content)
print(f"Average reading level: {readability.level}")
print(f"Slides above target: {readability.difficult_slides}")

# Check brand compliance
brand_issues = validator.validate_brand_compliance(content, brand='ce')
for issue in brand_issues:
    print(f"Brand violation: {issue.type} - {issue.description}")
```

## Multi-Source Content Pipeline

### merge_content.py

Combine content from multiple sources into unified presentation.

```bash
# Merge content from multiple sources
python scripts/merge_content.py project-path \
  --sources "chat-export.json,slides.pptx,notes.md" \
  --strategy prioritized \
  --output merged-content.json

# Merge with conflict resolution
python scripts/merge_content.py project-path \
  --sources "source1.json,source2.json" \
  --conflicts resolve-ai \
  --model gpt-4 \
  --merge-strategy complement
```

### Content Merging Strategies

```python
from content_merger import ContentMerger

merger = ContentMerger()

# Prioritized merge (first source wins conflicts)
merged = merger.merge_prioritized([source1, source2, source3])

# Complementary merge (combine unique content)
merged = merger.merge_complementary([source1, source2], 
                                   overlap_threshold=0.7)

# AI-assisted merge (intelligent conflict resolution)
merged = merger.merge_with_ai([source1, source2],
                             model='claude-3',
                             strategy='best_of_both')
```

## Content Enhancement

### enhance_content.py

Improve content quality and presentation readiness.

```bash
# Enhance with AI
python scripts/enhance_content.py project-path \
  --ai-enhance \
  --model claude-3 \
  --enhancements "headlines,flow,clarity"

# Enhance for specific audience
python scripts/enhance_content.py project-path \
  --audience "C-level executives" \
  --industry "fintech" \
  --presentation-length "15-minutes"

# Enhance with brand voice
python scripts/enhance_content.py project-path \
  --brand-voice config/ce-voice.json \
  --tone professional \
  --avoid-jargon
```

### Content Enhancers

```python
from content_enhancers import ContentEnhancer

enhancer = ContentEnhancer()

# Improve headlines
enhanced = enhancer.enhance_headlines(
    content,
    style='action_oriented',
    max_length=60,
    include_numbers=True
)

# Enhance bullet points
enhanced = enhancer.enhance_bullets(
    content,
    style='parallel_structure',
    max_bullets=5,
    action_verbs=True
)

# Add storytelling elements
enhanced = enhancer.add_storytelling(
    content,
    narrative_structure='problem_solution',
    emotional_hooks=True
)
```

## Interactive Content Creation

### interactive_content.py

Interactive content creation and editing.

```bash
# Interactive content builder
python scripts/interactive_content.py project-path

# Guided content creation
python scripts/interactive_content.py project-path \
  --guided \
  --template business-pitch

# Content wizard with AI assistance
python scripts/interactive_content.py project-path \
  --wizard \
  --ai-assist \
  --model gpt-4
```

### Content Builder Interface

```python
from content_builder import InteractiveBuilder

builder = InteractiveBuilder(project_path)

# Guided slide creation
slide = builder.create_slide_interactive()
# Prompts for: type, headline, content, layout preferences

# Batch slide creation
slides = builder.create_slides_batch(
    slide_count=8,
    content_outline="Business model, Market size, Competition..."
)

# Template-based creation
slides = builder.create_from_template(
    template='investor-pitch',
    company_info={'name': 'PHAT Foods', 'industry': 'Food Tech'}
)
```

## Content API Integration

### content_sync.py

Synchronize content with external systems.

```bash
# Sync with Notion
python scripts/content_sync.py project-path \
  --source notion \
  --database-id "ABC123" \
  --bidirectional

# Sync with Google Docs
python scripts/content_sync.py project-path \
  --source google-docs \
  --document-id "XYZ789" \
  --auto-sync

# Sync with CMS
python scripts/content_sync.py project-path \
  --source cms \
  --endpoint "https://cms.company.com/api" \
  --content-type "presentations"
```

### Real-time Content Updates

```python
from content_sync import ContentSynchronizer

sync = ContentSynchronizer(project_path)

# Setup real-time sync
sync.setup_webhook_listener(
    port=8080,
    endpoints=['/notion-update', '/gdocs-change']
)

# Auto-update on external changes
sync.enable_auto_sync(
    sources=['notion', 'google-docs'],
    interval_seconds=30,
    conflict_resolution='prompt_user'
)
```

## Content Versioning

### version_content.py

Version control for content changes.

```bash
# Create content version
python scripts/version_content.py project-path \
  --create-version "v1.0" \
  --message "Initial slide content"

# Compare versions
python scripts/version_content.py project-path \
  --compare v1.0 v1.1 \
  --output-diff changes.html

# Restore previous version
python scripts/version_content.py project-path \
  --restore v1.0 \
  --backup-current
```

### Version Management

```python
from content_versioning import ContentVersionManager

version_manager = ContentVersionManager(project_path)

# Create snapshot
version_manager.create_snapshot('pre-review-changes')

# Track changes
changes = version_manager.track_changes()
print(f"Modified slides: {changes.modified_slides}")
print(f"New slides: {changes.new_slides}")
print(f"Deleted slides: {changes.deleted_slides}")

# Restore to previous state
version_manager.restore_to_snapshot('pre-review-changes')
```

## Performance Optimization

### optimize_content.py

Optimize content for performance and delivery.

```bash
# Optimize for web delivery
python scripts/optimize_content.py project-path \
  --target web \
  --minify \
  --compress-assets

# Optimize for large presentations
python scripts/optimize_content.py project-path \
  --lazy-loading \
  --chunk-content \
  --progressive-enhancement
```

### Content Optimization Strategies

```python
from content_optimizer import ContentOptimizer

optimizer = ContentOptimizer()

# Optimize for performance
optimized = optimizer.optimize_for_web(
    content,
    strategies=['lazy_loading', 'image_optimization', 'chunking']
)

# Optimize for accessibility
accessible = optimizer.enhance_accessibility(
    content,
    features=['alt_text', 'screen_reader', 'high_contrast']
)

# Optimize for mobile
mobile_ready = optimizer.optimize_for_mobile(
    content,
    features=['responsive_text', 'touch_friendly', 'reduced_motion']
)
```