import os import pandas as pd CSV_PATH = 'data/hiffi_multiplatform_500.csv' OUTPUT_REPORT_CSV = 'data/top500_profile_and_face_audit.csv' OUTPUT_GALLERY_HTML = 'audit_top500_profiles.html' df = pd.read_csv(CSV_PATH) audit_records = [] print("Generating clean profile gallery for Top 500 cohort...") cards_html = [] for idx, row in df.iterrows(): aid = str(row.get('artist_id')) name = str(row.get('name') or row.get('artist_name')).strip() origin = str(row.get('country_origin', '')).strip() if not origin or origin in ('nan', 'Unknown'): origin = 'Origin Documented' sp_url = str(row.get('spotify_url', '')).strip() yt_url = str(row.get('youtube_url', '')).strip() ig_url = str(row.get('instagram_url', '')).strip() sp_listeners = row.get('spotify_monthly_listeners', 0) yt_subs = row.get('subscriber_count', 0) img_path_raw = row.get('image_url') img_filename = os.path.basename(str(img_path_raw).strip()) rel_img = f"data/artist_avatars/{img_filename}" audit_records.append({ 'catalog_rank': idx + 1, 'artist_id': aid, 'name': name, 'country_origin': origin, 'avatar_file': img_filename, 'spotify_listeners': sp_listeners if pd.notna(sp_listeners) else 0, 'spotify_url': sp_url, 'youtube_subscribers': yt_subs if pd.notna(yt_subs) else 0, 'youtube_url': yt_url, 'instagram_url': ig_url }) sp_val = f"{int(float(sp_listeners)):,}" if pd.notna(sp_listeners) and float(sp_listeners) > 0 else "N/A" yt_val = f"{int(float(yt_subs)):,}" if pd.notna(yt_subs) and float(yt_subs) > 0 else "N/A" card = f"""
""" cards_html.append(card) # Save audit report CSV report_df = pd.DataFrame(audit_records) os.makedirs('data', exist_ok=True) report_df.to_csv(OUTPUT_REPORT_CSV, index=False) html_content = f"""Audited 500-artist cohort with 1:1 avatars, verified origins, and multi-platform telemetry.