from fastcore.utils import *from fastcore.xtras import *from atproto import Clientfrom fastprogress.fastprogress import master_bar, progress_barRemove bsky non-mutual follows
You’ll need to pip install fastprogress and atproto.
Create a file “.env” containing one line: bsky_pass=..., in the same directory.
env = parse_env(fn='.env')cli = Client()pv = cli.login('howard.fm', env['bsky_pass'])did = pv.didpv.posts_count,pv.followers_count,pv.follows_count(246, 15061, 979)
def at_paged(did, meth): "Return all pages of results from some method" resp = None while True: resp = meth(did, cursor=resp.cursor if resp else None) yield resp if not resp.cursor: returnposts = L(at_paged(did, cli.get_author_feed)).attrgot('feed').concat()posts[-2].post.recordRecord(created_at='2023-05-08T03:17:47.510Z', text='👋🏽', embed=None, entities=None, facets=None, labels=None, langs=None, reply=ReplyRef(parent=Main(cid='bafyreib7cq47fgqz7fpa4kdlwuz3m7ukdcfyftkev75kldvaorrqqennle', uri='at://did:plc:cn7lps422rbgdpsh3dg5e5c2/app.bsky.feed.post/3jv6axng6re2r', py_type='com.atproto.repo.strongRef'), root=Main(cid='bafyreib7cq47fgqz7fpa4kdlwuz3m7ukdcfyftkev75kldvaorrqqennle', uri='at://did:plc:cn7lps422rbgdpsh3dg5e5c2/app.bsky.feed.post/3jv6axng6re2r', py_type='com.atproto.repo.strongRef'), py_type='app.bsky.feed.post#replyRef'), tags=None, py_type='app.bsky.feed.post')
fws = L(at_paged(did, cli.get_follows))frs = L(at_paged(did, cli.get_followers))following = fws.attrgot('follows').concat()followers = frs.attrgot('followers').concat()len(following),len(followers)(2144, 15016)
to_unfollow = set(following.attrgot('did')) - set(followers.attrgot('did'))len(to_unfollow)1172
followd = {o.did:o.viewer.following for o in following}for fdid in progress_bar(to_unfollow): try: cli.unfollow(followd[fdid]) except Exception as e: print(f"Could not unfollow {fdid}: {e}")
100.00% [1172/1172 04:56<00:00]