Add automatic instruction fetcher for official sets
Downloads official instruction PDFs from LEGO, located via the Brickset API, one set per interval (10 minutes by default) so neither API gets hammered. Official sets only; MOCs are excluded throughout. - New admin page at /admin/instruction-fetch: queue builder, pacing controls, live countdown and per-set job history - Database-backed queue (instruction_fetch_jobs) and last-run timestamp, so pacing survives restarts - Background worker thread, plus 'flask instructions queue/run/status' for Task Scheduler or cron - SHA-256 dedupe (instructions.sha256), PDF header check, size cap and streaming downloads via temp files - brickset_api: getInstructions2 by set number and getInstructions by setID (the old code sent a set number to the setID method); getSets params now proper JSON; getKeyUsageStats added - Schema top-ups applied automatically at boot: new table plus instructions.sha256/source - Docker: fetcher env vars passed through compose, no worker thread in the entrypoint bootstrap
This commit is contained in:
1 parent
aac2b60517
commit
89f65e2d74
23 files changed
+2073
-76
No files matched your search
@@ -16,6 +16,13 @@ class Instruction(db.Model):
|
||||
file_name = db.Column(db.String(200), nullable=False)
|
||||
file_size = db.Column(db.Integer) # Size in bytes
|
||||
thumbnail_path = db.Column(db.String(500)) # Thumbnail preview (especially for PDFs)
|
||||
|
||||
# SHA-256 of the stored file. Set by the automatic fetcher so the same
|
||||
# PDF is never downloaded twice; null for older manual uploads.
|
||||
sha256 = db.Column(db.String(64), nullable=True, index=True)
|
||||
# Where the file came from: None/'upload' for manual, 'brickset' for the
|
||||
# automatic fetcher.
|
||||
source = db.Column(db.String(20), nullable=True)
|
||||
|
||||
# For image sequences
|
||||
page_number = db.Column(db.Integer, default=1)
|
||||
@@ -40,6 +47,7 @@ class Instruction(db.Model):
|
||||
'file_name': self.file_name,
|
||||
'file_size': self.file_size,
|
||||
'page_number': self.page_number,
|
||||
'source': self.source,
|
||||
'file_url': f'/static/uploads/{clean_path}',
|
||||
'thumbnail_url': f'/static/uploads/{thumbnail_clean}' if thumbnail_clean else None,
|
||||
'uploaded_at': self.uploaded_at.isoformat()
|
||||
|
||||
Reference in new issue
Block a user