import os
import sys
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'NetworkMonitoring.settings')

import django
django.setup()

from extractly.models import SourceHtml

sh = SourceHtml.objects.get(source_id='779dc8fa-ef0b-4627-8cf6-755f3375d949')
cfg = sh.selectors['sliced_html']

print("=" * 70)
print("MORIZON LEVEL 2 CONFIGURATION - FINAL VERIFICATION")
print("=" * 70)
print(f"\n✅ Selectors structure: {list(sh.selectors.keys())}")
print(f"✅ Content type ID: {cfg.get('content_type')}")
print(f"✅ Content field: {cfg.get('content_field')}")
print(f"✅ Merge enabled: {cfg.get('merge')}")
print(f"✅ Skip selectors: {len(cfg.get('skip_selectors', []))} ad removal patterns")
print(f"✅ Extraction sections: {[k for k in cfg.keys() if k.startswith('sliced_')]}")
print(f"✅ Actions count: {len(sh.actions) if sh.actions else 0}")
print(f"✅ No _comment fields in actions: {all('_comment' not in a for a in sh.actions)}")

print("\n" + "=" * 70)
print("CONFIGURATION IS COMPLETE AND CORRECT!")
print("=" * 70)
print("\nNext step: Run HTML collection command:")
print("  python manage.py run_html --name morizon --include-fetched --headless")
print("\nThis will process all 599 Morizon pages.")
print("Note: May take 3-4 hours due to cookie handling. Be patient!")
print("=" * 70)
