initial commit

This commit is contained in:
2025-03-18 10:38:59 +01:00
commit c37f4dcd75
5 changed files with 129 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
3.13
+49
View File
@@ -0,0 +1,49 @@
# Bitwarden Markdown Generator
This Python script converts a Bitwarden JSON export file into a formatted Markdown file. It organizes password entries by folder and includes details such as creation date, modification date, username, password, and notes.
## Features
- Converts Bitwarden JSON export to Markdown format.
- Organizes entries by folder.
- Includes detailed information for each entry.
- Easy to use and customize.
## Requirements
- Python 3.x
- uv dependency manager
## Installation
1. Clone the repository:
```bash
git clone https://github.com/gurix/bitwarden-md-generator.git
cd bitwarden-md-generator
```
2. Install the required dependencies using `uv`:
```bash
uv sync
```
## Usage
1. Export your Bitwarden vault as a JSON file.
2. Update the `json_file_path` and `output_md_path` variables in the `main` function of the script to point to your Bitwarden JSON file and the desired output Markdown file location.
3. Run the script:
```bash
uv run app.py
```
4. Check the specified output directory for the generated Markdown file.
## Customization
- You can modify the `format_date` function to change the date format in the output.
- Adjust the Markdown template in the `generate` method to include or exclude specific details.
+64
View File
@@ -0,0 +1,64 @@
import json
from datetime import datetime
class BitwardenMDGenerator:
def __init__(self, json_file_path, output_md_path):
# Initialize the class with file paths and prepare the markdown header
self.json_file_path = json_file_path
self.output_md_path = output_md_path
self.data = None
# Start the markdown content with a header including the current date and time
self.markdown = f"# Password export ({datetime.now().strftime('%Y-%m-%d %H:%M:%S')})\n\n"
def format_date(self, value: str) -> str:
# Convert a date string from ISO format to a more readable format
date_object = datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ")
return date_object.strftime("%B %d, %Y %H:%M:%S")
def generate(self) -> None:
# Load the JSON data from the file
self.load_data()
# Iterate over each folder in the data
for folder in self.data['folders']:
# Add the folder name as a section header in the markdown
self.markdown += f"## {folder['name']}\n\n"
# Iterate over each item in the data
for item in self.data['items']:
# Check if the item belongs to the current folder
if item['folderId'] == folder['id']:
# Add the item name as a subsection header
self.markdown += f"### {item['name']}\n\n"
# Add creation and modification dates
self.markdown += f"**Created:** {self.format_date(item['creationDate'])}\n"
self.markdown += f"**Modified:** {self.format_date(item['revisionDate'])}\n"
# Add login details if available
if 'login' in item:
self.markdown += f"**Username:** {item['login'].get('username', 'N/A')}\n"
self.markdown += f"**Password:** {item['login'].get('password', 'N/A')}\n\n"
# Add notes if available
if 'notes' in item:
self.markdown += f"**Notes:**\n{item['notes']}\n\n"
# Save the generated markdown content to a file
self.save_md()
def save_md(self) -> None:
# Write the markdown content to the specified output file
with open(self.output_md_path, 'w') as file:
file.write(self.markdown)
def load_data(self) -> None:
# Load JSON data from the specified file path
with open(self.json_file_path, 'r') as file:
self.data = json.load(file)
def main():
# Create an instance of BitwardenMDGenerator and generate the markdown file
BitwardenMDGenerator(json_file_path='/home/markus/Downloads/bitwarden_export.json',
output_md_path='/home/markus/Downloads/passwords.md').generate()
if __name__ == "__main__":
# Run the main function when the script is executed
main()
print("MD created successfully!")
+8
View File
@@ -0,0 +1,8 @@
[project]
name = "bw-print"
version = "0.1.0"
description = "Create a Markdown of all your bitwarden entries"
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
]
Generated
+7
View File
@@ -0,0 +1,7 @@
version = 1
requires-python = ">=3.13"
[[package]]
name = "bw-print"
version = "0.1.0"
source = { virtual = "." }