import os
from dotenv import load_dotenv
from notion_to_md import export_notion_page_to_markdown

# Load environment variables
load_dotenv()

def test_title_extraction():
    """Test the title extraction with the updated code"""
    page_id = '2725bd136a8480a69301d6e70171cdad'
    try:
        print("Testing title extraction...")
        page_title, markdown_content = export_notion_page_to_markdown(page_id)
        print(f"✅ Successfully extracted title: '{page_title}'")
        print(f"✅ Content length: {len(markdown_content)} characters")
        
        # Show first few lines of content
        lines = markdown_content.split('\n')[:5]
        print("\n📄 First few lines of content:")
        for i, line in enumerate(lines, 1):
            print(f"  {i}: {line}")
        
        return True
    except Exception as e:
        print(f"❌ Error: {str(e)}")
        return False

if __name__ == '__main__':
    test_title_extraction()
