modify scripts

This commit is contained in:
2025-11-03 16:21:46 +08:00
parent fe153d69cc
commit 91e7d38725
2 changed files with 4 additions and 3 deletions

View File

@ -34,7 +34,7 @@ services:
# 定义文件命名规则和存储路径
# 作用不大,主要还是用消费后脚本,以及工作流来指定存储路径。
# 工作流先于消费后脚本运行因此消费后脚本里解析的document_type在工作流里无效。所以使用了文件名关键词匹配
PAPERLESS_FILENAME_FORMAT: "{{created}}_{{document_type}}_{{correspondent}}_{{title}}.pdf"
PAPERLESS_FILENAME_FORMAT: "{{created}}_{{document_type}}_{{correspondent}}_{{title}}"
# 解析文件里的关键信息并更新。但无法更新strorage path。这个字段要靠工作流才行。
PAPERLESS_POST_CONSUME_SCRIPT: "/usr/src/paperless/scripts/parse_filename.py"

View File

@ -11,7 +11,8 @@ from requests.exceptions import RequestException
# Paperless 服务器信息
PAPERLESS_URL = "http://localhost:8000/api"
AUTH = HTTPBasicAuth("admin", "admin") # Basic Auth 认证
#AUTH = HTTPBasicAuth("admin", "admin") # Basic Auth 认证 mac上用这个
AUTH = HTTPBasicAuth("admin", "paperless") # Basic Auth 认证NAS上用这个
# 日志配置
logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(message)s")
@ -22,7 +23,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] %(me
DB_PATH = "/usr/src/paperless/data/db.sqlite3"
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
enable_db = True
enable_db = False # 标准用法用API
# 正则解析文件名
FILENAME_PATTERN = re.compile(r"(\d{4}-\d{2}-\d{2})_(.*?)_(.*?)_(.*?)_(.*?)_(.*)\.pdf")