Skip to main content

Download billing files from email with configurable providers

Project description

Emlex

Emlex 从任意 IMAP 邮箱中筛选目标邮件,并把附件或邮件中的下载链接保存到本地。

安装

项目要求 Python 3.10 及以上版本:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"

安装后使用 em 命令,也可以在源码目录运行 python -m cli.main

全屏 TUI

启动邮箱与下载任务管理界面:

em ui

em ui 会打开真正的全屏终端界面:左侧管理多个下载任务,右侧配置邮箱登录和下载规则,底部显示连接与保存状态。

支持的邮箱与认证方式:

  • Gmail、Outlook / Microsoft 365、QQ、163、iCloud、Yahoo;
  • 任意自定义 IMAP 服务;
  • 密码或应用专用密码;
  • OAuth2 Access Token;
  • SSL/TLS、STARTTLS,以及仅供受信网络使用的明文 IMAP。

下载规则支持:

  • 按主题关键字、发件人和回溯天数筛选邮件;
  • 下载任意后缀的附件,如 ZIP、PDF、CSV、XLSX;
  • 从 HTML 邮件中按链接文字查找并下载任意文件类型;
  • 自定义保存目录、文件后缀和 HTTP 超时;
  • 创建任意任务标识,不再局限于支付宝和微信。

常用按键:

按键 操作
Ctrl+N 新建任务
Ctrl+S 保存任务
Ctrl+T 测试邮箱连接
Ctrl+D 删除任务(需按两次确认)
Ctrl+Q 退出

旧的提示式命令 em config email add 仍保留用于脚本兼容。

如果不希望把密码直接写入 JSON,可保存环境变量引用:

em config email add \
  --provider alipay \
  --email-type gmail \
  --username you@example.com \
  --password-env EMLEX_EMAIL_PASSWORD

然后在 ~/.flow/.env 中设置密码:

EMLEX_EMAIL_PASSWORD=your-app-password

自定义 IMAP 示例:

em config email add \
  --provider wechat \
  --email-type imap \
  --username you@example.com \
  --host imap.example.com \
  --port 993

默认配置文件为 ~/.flow/config.json。如果该文件不存在,Emlex 会自动识别旧版项目内的 config/config.json;每次覆盖保存前还会在同目录生成 config.json.bak。开发和测试时可通过 --config 指定其他路径。

下载账单

em download --provider alipay
em download --provider wechat
em download --provider bank_pdf

使用其他配置文件:

em download --provider alipay --config /path/to/config.json

TUI 保存后会自动生成完整任务配置。你也可以直接编辑 profile

{
  "alipay": {
    "email": "gmail",
    "auth_type": "pass",
    "auth": {
      "username": "you@example.com",
      "password": "${EMLEX_EMAIL_PASSWORD}"
    },
    "download": "attachment",
    "profile": {
      "name": "alipay",
      "search_subject": "支付宝",
      "sender_email": "service@example.com",
      "file_suffix": "zip",
      "encoding": "gbk"
    }
  }
}

download 可设为 attachment(兼容旧拼写 attchment)或 link。下载文件默认保存在 ~/.flow/data/<provider>/

测试

python -m pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

emlex-1.2.2.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

emlex-1.2.2-py3-none-any.whl (27.3 kB view details)

Uploaded Python 3

File details

Details for the file emlex-1.2.2.tar.gz.

File metadata

  • Download URL: emlex-1.2.2.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for emlex-1.2.2.tar.gz
Algorithm Hash digest
SHA256 b0526047a1c7e4bfdfc19cc3df7ba6b62209935ae28181d75b0313ce87fc4743
MD5 75fb2563d6527b3c3af87088cd5f343d
BLAKE2b-256 cdea9605d23becb85a073349daa27daa84309f5a97af0938a434075f7a827820

See more details on using hashes here.

File details

Details for the file emlex-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: emlex-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 27.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for emlex-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d92656688f7344ae82f05e4388a8d913570064abcba62588865f20404a48f45
MD5 985f7e3f2dda7290c4d7617e17efff94
BLAKE2b-256 14f0a04fea63eb049f17f19ed5db39e43a6444584ed3dee5d2edab9a981cd161

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page