diff --git a/run_live_test.sh b/run_live_test.sh new file mode 100755 index 0000000..4c69b68 --- /dev/null +++ b/run_live_test.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +set -e + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +VIDEO_ID="jNQXAC9IVRw" + +# 1. Auto-detect and configure SOCKS5 proxy if active on 7890 +if nc -z 127.0.0.1 7890 >/dev/null 2>&1; then + echo "=== Auto-detected local proxy on port 7890. Enabling proxy... ===" + export http_proxy=socks5://127.0.0.1:7890 + export https_proxy=socks5://127.0.0.1:7890 + export all_proxy=socks5://127.0.0.1:7890 + export HTTP_PROXY=socks5://127.0.0.1:7890 + export HTTPS_PROXY=socks5://127.0.0.1:7890 + export ALL_PROXY=socks5://127.0.0.1:7890 +fi + +# 2. Set up virtual environment and install requirements if not set up +if [ ! -d "$DIR/backend/.venv" ]; then + echo "=== Initializing Python Virtual Environment ===" + python3 -m venv "$DIR/backend/.venv" + "$DIR/backend/.venv/bin/pip" install -q -r "$DIR/backend/requirements.txt" +fi + +# 3. Seed the database with the test video record +echo "=== Seeding database with test video ID: $VIDEO_ID ===" +"$DIR/backend/.venv/bin/python3" -c "import asyncio, aiosqlite, sys; sys.path.insert(0, '$DIR/backend'); import db; +async def run(): + await db.init_db() + async with aiosqlite.connect(db.DB_PATH) as conn: + await conn.execute(\"INSERT OR IGNORE INTO videos (video_id, title, url, status) VALUES ('$VIDEO_ID', 'Me at the zoo', 'https://www.youtube.com/watch?v=$VIDEO_ID', 'pending')\") + await conn.commit() +asyncio.run(run())" + +# 4. Execute summarizer +echo "=== Running Live Ingestion & AI Summarization ===" +"$DIR/backend/.venv/bin/python3" "$DIR/backend/summarizer.py" "$VIDEO_ID" + +# 5. Verify database storage +echo "=== Verifying SQLite Database Storage ===" +"$DIR/backend/.venv/bin/python3" -c "import asyncio, aiosqlite, sys; sys.path.insert(0, '$DIR/backend'); import db; +async def run(): + async with aiosqlite.connect(db.DB_PATH) as conn: + conn.row_factory = aiosqlite.Row + cursor = await conn.execute(\"SELECT summary FROM videos WHERE video_id = '$VIDEO_ID'\") + row = await cursor.fetchone() + if row and row['summary'] and not row['summary'].startswith('Error') and not row['summary'].startswith('Could not'): + print('VERIFICATION: SUCCESS (Summary saved in DB)') + else: + print('VERIFICATION: FAILED (Database record missing or has error)') +asyncio.run(run())"