pkgs: Correctly render all bitwarden possibilities

This commit is contained in:
traxys 2023-07-24 22:26:27 +02:00
parent f844a99919
commit bf1c459a79

View file

@ -23,12 +23,18 @@ if process.returncode != 0:
data = json.loads(data)
for item in data:
print(f"==== {item['name']} ====")
print(f" {item['login']['username']}")
print(f" {item['login']['password']}")
if "totp" in item["login"] and item["login"]["totp"] is not None:
totp = pyotp.TOTP(item["login"]["totp"])
time_remaining = (
totp.interval - datetime.datetime.now().timestamp() % totp.interval
)
print(f" {totp.now()} ({int(time_remaining)})")
if "login" in item:
print(f"==== {item['name']} ====")
if "username" in item["login"]:
print(f" {item['login']['username']}")
if "password" in item["login"]:
print(f" {item['login']['password']}")
if "totp" in item["login"] and item["login"]["totp"] is not None:
if item["login"]["totp"].startswith("otpauth://"):
totp = pyotp.parse_uri(item["login"]["totp"])
else:
totp = pyotp.TOTP(item["login"]["totp"])
time_remaining = (
totp.interval - datetime.datetime.now().timestamp() % totp.interval
)
print(f" {totp.now()} ({int(time_remaining)})")