import xml.etree.ElementTree as ET
import re

file_path = "/home/user/uploads/thediscinitiatives.WordPress.2025-08-09.xml"

# Set up namespaces
namespaces = {
    'wp': 'http://wordpress.org/export/1.2/',
    'content': 'http://purl.org/rss/1.0/modules/content/'
}

try:
    tree = ET.parse(file_path)
    root = tree.getroot()
    
    items = root.findall('.//item')
    print(f"Total items found: {len(items)}")
    
    post_types = {}
    for item in items:
        post_type = item.find('wp:post_type', namespaces)
        status = item.find('wp:status', namespaces)
        
        pt = post_type.text if post_type is not None else 'unknown'
        st = status.text if status is not None else 'unknown'
        
        if st == 'publish':
            post_types[pt] = post_types.get(pt, 0) + 1
            
    print("Published items by type:")
    for pt, count in post_types.items():
        print(f"  {pt}: {count}")

except Exception as e:
    print(f"Error parsing XML: {e}")

