added attachment loop search and save
This commit is contained in:
@@ -470,6 +470,21 @@ if __name__ == "__main__":
|
||||
logger.debug("Exporting organization vault to JSON")
|
||||
logger.debug((subprocess.run([bitwarden_cli_executable, 'export', '--organizationid', '{}'.format(organization['id']), '--output', os.path.join(script_directory, 'Bitwarden Organziation {} Export {}.json'.format(organization['name'], datetime_string)), '--format', 'json'], capture_output=True).stdout).decode())
|
||||
|
||||
logger.info("Looking for items with attachments")
|
||||
bitwarden_items = json.loads(((subprocess.run([bitwarden_cli_executable, 'list', 'items'], capture_output=True)).stdout).decode())
|
||||
bitwarden_items_with_attachments = ()
|
||||
for item in bitwarden_items:
|
||||
logger.debug("Working on item {} ({})".format(item['name'], item['id']))
|
||||
if "attachments" in item:
|
||||
logger.debug("Found {} attachments".format(len(item['attachments'])))
|
||||
attachment_folder_name = os.path.join(script_directory, "attachments", "{}".format(item['name']))
|
||||
for attachment in item['attachments']:
|
||||
logger.debug("Downloading attachment ({}) with name {} to folder {}".format(attachment['id'], attachment['name'], attachment_folder_name))
|
||||
logger.debug((subprocess.run([bitwarden_cli_executable, 'get', 'attachment', attachment['id'], '--itemid', item['id'], '--output', os.path.join(attachment_folder_name, attachment['filename'])], capture_output=True).stdout).decode())
|
||||
|
||||
else:
|
||||
logger.debug("Item has no attachments")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user