Production Readiness Improvements: - Fixed scheduling to match spec (8 AM & 12 PM ADT instead of 6 AM/6 PM) - Enabled NAS synchronization in production runner with error handling - Fixed file naming convention to spec format (hvacknowitall_combined_YYYY-MM-DD-THHMMSS.md) - Made systemd services portable (removed hardcoded user/paths) - Added environment variable validation on startup - Moved DISPLAY/XAUTHORITY to .env configuration Systemd Improvements: - Created template service file (@.service) for any user - Changed all paths to /opt/hvac-kia-content - Updated installation script for portable deployment - Fixed service dependencies and resource limits Documentation: - Created comprehensive PRODUCTION_TODO.md with 25 tasks - Added PRODUCTION_GUIDE.md with deployment instructions - Documented spec compliance gaps (65% complete) Remaining work includes retry logic, connection pooling, media downloads, and pytest test suite as documented in PRODUCTION_TODO.md 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
79 lines
No EOL
2.2 KiB
Python
79 lines
No EOL
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Debug Instagram context issue
|
|
"""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
from dotenv import load_dotenv
|
|
import instaloader
|
|
|
|
load_dotenv()
|
|
|
|
username = os.getenv('INSTAGRAM_USERNAME')
|
|
password = os.getenv('INSTAGRAM_PASSWORD')
|
|
target = os.getenv('INSTAGRAM_TARGET')
|
|
|
|
print(f"Username: {username}")
|
|
print(f"Target: {target}")
|
|
|
|
# Test different loader creation approaches
|
|
print("\n" + "="*50)
|
|
print("Testing context availability:")
|
|
print("="*50)
|
|
|
|
# Method 1: Default loader
|
|
print("\n1. Default Instaloader():")
|
|
L1 = instaloader.Instaloader()
|
|
print(f" Has context: {L1.context is not None}")
|
|
print(f" Context type: {type(L1.context)}")
|
|
|
|
# Method 2: With parameters
|
|
print("\n2. Instaloader with params:")
|
|
L2 = instaloader.Instaloader(
|
|
quiet=True,
|
|
download_pictures=False,
|
|
download_videos=False
|
|
)
|
|
print(f" Has context: {L2.context is not None}")
|
|
|
|
# Method 3: After login
|
|
print("\n3. After login:")
|
|
L3 = instaloader.Instaloader()
|
|
print(f" Before login - Has context: {L3.context is not None}")
|
|
try:
|
|
L3.login(username, password)
|
|
print(f" After login - Has context: {L3.context is not None}")
|
|
print(f" Context logged in: {L3.context.is_logged_in if L3.context else 'N/A'}")
|
|
except Exception as e:
|
|
print(f" Login failed: {e}")
|
|
|
|
# Method 4: Test what our scraper does
|
|
print("\n4. Testing our scraper pattern:")
|
|
from src.base_scraper import ScraperConfig
|
|
from src.instagram_scraper import InstagramScraper
|
|
|
|
config = ScraperConfig(
|
|
source_name='instagram',
|
|
brand_name='hvacknowitall',
|
|
data_dir=Path('test_data'),
|
|
logs_dir=Path('test_logs'),
|
|
timezone='America/Halifax'
|
|
)
|
|
|
|
print("Creating scraper...")
|
|
scraper = InstagramScraper(config)
|
|
print(f" Scraper loader context: {scraper.loader.context is not None}")
|
|
if scraper.loader.context:
|
|
print(f" Context logged in: {scraper.loader.context.is_logged_in}")
|
|
|
|
# Test if we can get a profile without error
|
|
print("\n5. Testing profile fetch:")
|
|
try:
|
|
if scraper.loader.context:
|
|
profile = instaloader.Profile.from_username(scraper.loader.context, target)
|
|
print(f"✅ Got profile: @{profile.username}")
|
|
else:
|
|
print("❌ No context available")
|
|
except Exception as e:
|
|
print(f"❌ Profile fetch failed: {e}") |