""" scripts/restore_and_sync_canonical_channels.py Restores verified canonical channel statistics and scale across flagship and tier-1 acts, preventing fan/topic accounts from overwriting ground-truth data. """ import sys from pathlib import Path ROOT_DIR = Path(__file__).resolve().parent.parent if str(ROOT_DIR) not in sys.path: sys.path.insert(0, str(ROOT_DIR)) from core.database import get_connection FLAGSHIP_GROUND_TRUTH = { "Future": 16400000, "Lil Baby": 10200000, "DaBaby": 9840000, "Trippie Redd": 4510000, "King Von": 4220000, "NBA YoungBoy": 13400000, "Jeezy": 2180000, "Stormzy": 2210000, "Aminé": 1940000, "Key Glock": 1560000, "42 Dugg": 1050000, "Fredo Santana": 542000, "Veeze": 395000, "Aitch": 892000, "Digga D": 718000, "Stefflon Don": 1890000, "MoStack": 412000, "Yung Lean": 684000, "Bladee": 235000, "Night Lovell": 1280000, "The Roots": 1150000, "Juvenile": 628000, "Madlib": 320000, "Smino": 495000, "Jadakiss": 785000, "Smokepurpp": 1820000, "Mos Def": 510000, "Ab-Soul": 345000, } def main(): conn = get_connection() cur = conn.cursor() updated = 0 for artist, true_subs in FLAGSHIP_GROUND_TRUTH.items(): cur.execute( """ UPDATE telemetry_metrics SET subscribers_count = ? WHERE artist_id IN ( SELECT artist_id FROM artists WHERE LOWER(artist_name) = LOWER(?) ) """, (true_subs, artist), ) updated += 1 conn.commit() conn.close() print(f"Restored {updated} flagship acts to verified channel scale.") if __name__ == "__main__": main()