Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
File size: 6,647 Bytes
d15f07c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | #!/bin/bash
# Quick-start script to load and update meeting data for priority states
# States: AL, GA, IN, MA, MT, WA, WI
set -e # Exit on error
STATES="AL,GA,IN,MA,MT,WA,WI"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
echo "=========================================================================="
echo "ποΈ MEETING DATA LOADER FOR PRIORITY STATES"
echo "=========================================================================="
echo ""
echo "States: $STATES"
echo "Project: $PROJECT_ROOT"
echo ""
# Check virtual environment
if [[ -z "$VIRTUAL_ENV" ]]; then
echo "β οΈ Virtual environment not activated. Activating..."
source "$PROJECT_ROOT/.venv/bin/activate"
fi
# Step 1: Check current data status
echo "=========================================================================="
echo "Step 1: Checking Current Data Status"
echo "=========================================================================="
python "$PROJECT_ROOT/scripts/datasources/localview/check_meeting_data.py" --states "$STATES"
echo ""
echo "=========================================================================="
echo "Next Steps"
echo "=========================================================================="
echo ""
echo "Choose what you want to do:"
echo ""
echo "1. Download LocalView Historical Data (2006-2023)"
echo " - Visit: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/NJTBEM"
echo " - Download CSV files to: $PROJECT_ROOT/data/cache/localview/"
echo " - Then run: python -m ingestion.localview.events"
echo ""
echo "2. Scrape Recent Meetings from YouTube (2024-2026)"
echo " - Get YouTube API key: https://console.cloud.google.com/apis/credentials"
echo " - Add to .env: YOUTUBE_API_KEY=your_key_here"
echo " - Run this script with --scrape flag (scrapes last 850 days)"
echo ""
echo "3. Use Existing OpenStates Legislative Events"
echo " - Already loaded for all 7 states"
echo " - Contains committee hearings, sessions, participants"
echo " - See: data/gold/states/{STATE}/events_events.parquet"
echo ""
# Check for scrape flag
if [[ "$1" == "--scrape" ]]; then
echo "=========================================================================="
echo "Starting YouTube Scraping (Recent Meetings 2024-2026)"
echo "=========================================================================="
# Check for YouTube API key
if ! grep -q "YOUTUBE_API_KEY=" "$PROJECT_ROOT/.env" 2>/dev/null; then
echo "β YOUTUBE_API_KEY not found in .env"
echo ""
echo "To get an API key:"
echo "1. Go to: https://console.cloud.google.com/apis/credentials"
echo "2. Create project (if needed)"
echo "3. Enable YouTube Data API v3"
echo "4. Create credentials -> API Key"
echo "5. Add to .env: YOUTUBE_API_KEY=your_key_here"
echo ""
exit 1
fi
echo "β
YouTube API key found"
echo ""
# Scrape YouTube channels
echo "Scraping municipal YouTube channels..."
# --since-days 850 covers from Jan 1, 2024 to now (May 2026)
python -m scrapers.youtube.scrape_youtube_channels \
--states "$STATES" \
--since-days 850
echo ""
echo "β
Scraping complete!"
echo ""
# Extract transcripts
echo "=========================================================================="
echo "Extracting Transcripts"
echo "=========================================================================="
python "$PROJECT_ROOT/scripts/datasources/localview/extract_transcripts.py" \
--states "$STATES"
echo ""
echo "β
Transcript extraction complete!"
echo ""
# Extract contacts
echo "=========================================================================="
echo "Extracting Contacts from Meeting Transcripts"
echo "=========================================================================="
python -m ingestion.publication.gold.manage_contacts extract \
--states "$STATES" \
--batch-size 1000
echo ""
echo "β
Contact extraction complete!"
echo ""
# Final status
echo "=========================================================================="
echo "Final Data Status"
echo "=========================================================================="
python "$PROJECT_ROOT/scripts/datasources/localview/check_meeting_data.py" --states "$STATES"
fi
if [[ "$1" == "--localview" ]]; then
echo "=========================================================================="
echo "Loading LocalView Historical Data"
echo "=========================================================================="
# Check for LocalView files
if [[ ! -f "$PROJECT_ROOT/data/cache/localview/municipalities.csv" ]] && \
[[ ! -f "$PROJECT_ROOT/data/cache/localview/meetings.csv" ]]; then
echo "β LocalView CSV files not found in data/cache/localview/"
echo ""
echo "Download files from:"
echo "https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/NJTBEM"
echo ""
echo "Expected files:"
echo " - municipalities.csv (or municipalities.tab)"
echo " - meetings.csv (or meetings.tab)"
echo " - videos.csv (or videos.tab)"
echo ""
exit 1
fi
echo "β
LocalView files found"
echo ""
# Run ingestion
python -m ingestion.localview.events
echo ""
echo "β
LocalView ingestion complete!"
echo ""
# Filter for priority states
echo "Filtering for priority states ($STATES)..."
python -m ingestion.publication.gold.organize_meetings_by_state \
--states "$STATES"
echo ""
echo "β
Data organized by state!"
echo ""
# Final status
echo "=========================================================================="
echo "Final Data Status"
echo "=========================================================================="
python "$PROJECT_ROOT/scripts/datasources/localview/check_meeting_data.py" --states "$STATES"
fi
echo ""
echo "=========================================================================="
echo "π Documentation"
echo "=========================================================================="
echo ""
echo "For more details, see:"
echo " - web_docs/docs/guides/loading-meeting-data.md"
echo " - web_docs/docs/integrations/localview.md"
echo " - web_docs/docs/integrations/contacts-meetings-workflow.md"
echo ""
|