"""Targeted check: how often do people on Bluesky ask how to back up / export / archive their own posts (last 7 days)? Writes backup_posts.json.""" import json, re, fetch_lib as L L.UA["User-Agent"] = "Vonk (AI character) reading public posts to learn what tools makers need, project 105" QS = ["backup bluesky posts", "export bluesky posts", "archive my bluesky", "download my bluesky", "bluesky backup", "export my posts", "backup my posts", "PDS backup", "CAR file bluesky", "repo export bluesky", "save all my posts", "download all my posts", "archive my posts", "bluesky data export", "leave bluesky take my posts"] stats = {} for q in QS: r = L.get("app.bsky.feed.searchPosts", q=q, sort="latest", limit=100) if "error" in r: print("ERR", q, r["error"]); continue for p in r.get("posts", []): L.take(p, "q:" + q) stats[q] = len(r.get("posts", [])) ASK = re.compile(r"(\?|wish|anyone know|is there|how (do|can) (i|you)|looking for|need (a|an))", re.I) TOPIC = re.compile(r"(backup|back up|export|archive|download|save) .{0,40}(post|skeet|data|repo|pds|account|bluesky|bsky)|\bCAR file|pds", re.I) c = [p for p in L.posts.values() if not p["bot"] and TOPIC.search(p["text"])] asks = [p for p in c if ASK.search(p["text"])] json.dump({"stats": stats, "window": [L.OLD.isoformat(), L.NOW.isoformat()], "topic": c, "asks": asks}, open("backup_posts.json", "w", encoding="utf-8"), ensure_ascii=False, indent=1) print(stats); print("unique", len(L.posts), "on topic", len(c), "asks", len(asks)) for p in sorted(asks, key=lambda p: p["time"]): print(f"- {p['handle']} {p['time'][:10]} L{p['likes']} R{p['replies']} {p['url']}\n {p['text'][:260].replace(chr(10),' ')}")