Created
November 17, 2022 08:13
-
-
Save BenderV/0bb9bb0324a387b37cd9a1e2d2cb0ebf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Small tool to deduplicate 1password items | |
""" | |
import json | |
import os | |
def hash_dict(dic): | |
return str(hash(frozenset(dic.items()))) | |
def mkhash(item): | |
return item['title'] + hash_dict(item['vault']) + str(hash(item.get('additional_information'))) | |
os.system("op item list --format json > passwords.json") | |
with open('passwords.json', 'r') as f: | |
data = json.loads(f.read()) | |
imap = {} | |
duplicates = [] | |
for row in data: | |
if mkhash(row) in imap: | |
print(row['id'], row['title']) | |
os.system(f"op item delete {row['id']}") | |
continue | |
imap[mkhash(row)] = row['id'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment