diff --git a/mute_sync.py b/mute_sync.py index 7d4452b..d826b4a 100644 --- a/mute_sync.py +++ b/mute_sync.py @@ -87,10 +87,10 @@ class UserAccount: return r.json() @functools.cached_property - def mutes(self) -> list[dict]: + def mutes(self) -> set[str]: mutes = paginated_get(self.client, '/api/v1/mutes') self.instance.account_cache.extend(mutes) - return mutes + return set((mute['url'] for mute in mutes)) def lookup_acct(self, handle: str) -> dict | None: return self.instance.lookup_acct(handle, self.client) @@ -138,7 +138,34 @@ if __name__ == '__main__': print('accounts:', ', '.join((str(acct) for acct in accounts))) + all_mutes = set() for acct in accounts: - print(str(acct)) - print([mute_acct["acct"] for mute_acct in acct.mutes]) - print(acct.lookup_acct('https://merping.synth.download/@chfour')) + all_mutes.update(acct.mutes) + + print(f'all mutes ({len(all_mutes)} total):') + print(', '.join(all_mutes)) + print() + + for acct in accounts: + not_here = all_mutes.difference(acct.mutes) + + print(f'mutes to add to {acct}:') + count = 0 + for url in not_here: + print(f'looking up {url}...', end='') + found = acct.lookup_acct(url) + print(f'\x1b[2K\r', end='') + + if found is None: + print(f' {url} not found') + continue + + print(f'+ @{found["acct"]} ({url})') + count += 1 + + print(f'{count} total\n') + + choice = input('proceed? (type "yes" to continue) ') + if choice.lower() != 'yes': + print('operation cancelled') + exit()