Files
2026-04-12 22:39:58 +02:00

69 lines
1.7 KiB
Markdown

# Backblaze Invoice Downloader
Download Backblaze invoices as PDF using browser automation.
Backblaze only provides invoices via a web page that must be printed — this tool automates that process using Playwright, filling in configurable fields (VAT ID, document type, company, notes) and exporting each invoice to PDF.
## Setup
```bash
pip install -r requirements.txt
playwright install chromium
```
Or with Nix:
```bash
nix develop
```
## Configuration
Create a `.env` file (see `.env.example`):
```env
BACKBLAZE_EMAIL=you@example.com
BACKBLAZE_PASSWORD=your_password
INVOICE_VAT_ID=DE123456789
INVOICE_DOCUMENT_TYPE=Invoice
INVOICE_COMPANY=My Company GmbH
INVOICE_NOTES=Internal ref: 12345\nLine 2\nLine 3
OUTPUT_DIR=./invoices
BROWSER_HEADLESS=true
DOWNLOAD_ALL_YEARS=false
```
Notes can include literal `\n` to create line breaks in the invoice “Other” field.
## Usage
```bash
python main.py
```
### Options
```
-o, --output DIR Output directory (default: ./invoices)
--headless Run browser headless
--no-headless Show browser window (useful for debugging)
--vat-id ID VAT ID to fill on invoices
--document-type TYPE Document type to select
--company NAME Company name to fill
--notes TEXT Notes to fill on invoices
--all-years Download invoices for all years (default: first year only)
-v, --verbose Verbose logging
```
CLI arguments override `.env` values.
## How it works
1. Logs in to `secure.backblaze.com`
2. Navigates to the billing page
3. Iterates over all billing groups and the selected year(s) (first year by default)
4. For each invoice, opens the invoice page, fills the configured fields, and exports to PDF
5. Skips already-downloaded invoices