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
+9
-1
@@ -47,6 +47,7 @@ def create_app(config_name='default'):
|
||||
from app.routes.extra_files import extra_files_bp
|
||||
from app.routes.moc import bp as moc_bp
|
||||
from app.routes.backup import backup_bp
|
||||
from app.routes.instruction_fetch import instruction_fetch_bp
|
||||
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(main_bp)
|
||||
@@ -56,6 +57,7 @@ def create_app(config_name='default'):
|
||||
app.register_blueprint(extra_files_bp)
|
||||
app.register_blueprint(moc_bp)
|
||||
app.register_blueprint(backup_bp)
|
||||
app.register_blueprint(instruction_fetch_bp)
|
||||
|
||||
# Import models to ensure they're registered with SQLAlchemy
|
||||
from app.models.user import User
|
||||
@@ -64,6 +66,7 @@ def create_app(config_name='default'):
|
||||
from app.models.extra_file import ExtraFile
|
||||
from app.models.set_share import SetShare
|
||||
from app.models.site_setting import SiteSetting
|
||||
from app.models.instruction_fetch import InstructionFetchJob
|
||||
|
||||
# Add any columns missing from an older database (additive only).
|
||||
if app.config.get('AUTO_SCHEMA_UPGRADE', True):
|
||||
@@ -96,9 +99,14 @@ def create_app(config_name='default'):
|
||||
def uploaded_file(filename):
|
||||
return send_from_directory(app.config['UPLOAD_FOLDER'], filename)
|
||||
|
||||
# Register CLI commands (flask backup create/list/verify/restore)
|
||||
# Register CLI commands (flask backup ... / flask instructions ...)
|
||||
from app.cli import register_cli
|
||||
register_cli(app)
|
||||
|
||||
# Background ticker for the automatic instruction fetcher. It does
|
||||
# nothing at all until an admin enables it on the fetcher page.
|
||||
from app.services import fetch_worker
|
||||
fetch_worker.start(app)
|
||||
|
||||
# Context processor for global template variables
|
||||
@app.context_processor
|
||||
|
||||
Reference in new issue
Block a user