source_extraction.py:
- New _extract_image_metadata(): extracts figcaption text + copyright/credit
per image URL using 3 strategies (figure+figcaption, data-* attributes,
adjacent credit spans)
- ExtractedArticle gets new image_metadata field
- extracted_article_to_meta() includes image_metadata in stored JSON
pipeline.py:
- After auto image selection, check if selected_url is set
- Articles without usable image → status "no_image" (excluded with Telegram notice)
- PipelineStats and summary report include no_image counter
db.py:
- Add "no_image" to articles status CHECK constraint
- Migration: recreates articles table with updated constraint on existing DBs
workflow.py / main.py:
- Map no_image as own UI status with rewrite/close transitions
wordpress.py:
- _upload_featured_media() accepts image_caption param, sends to WP media
- _get_image_meta_for_url() / _build_image_caption() helpers
- _build_attribution_block(): separator + attribution paragraph at article end
(original link, author, Bildnachweis/credit)
- _build_post_content() appends attribution block
telegram_bot.py:
- notify_pipeline_done() shows 🖼️ no-image count
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
UI_STATUSES = ("new", "rewrite", "publish", "published", "close", "no_image")
|
|
|
|
|
|
def internal_to_ui_status(status: str | None) -> str:
|
|
value = (status or "").strip()
|
|
if value == "approved":
|
|
return "publish"
|
|
if value == "error":
|
|
return "close"
|
|
if value == "review":
|
|
return "rewrite"
|
|
if value in {"new", "rewrite", "published", "no_image"}:
|
|
return value
|
|
return value or "new"
|
|
|
|
|
|
def ui_to_internal_status(status: str | None) -> str:
|
|
value = (status or "").strip()
|
|
if value == "publish":
|
|
return "approved"
|
|
if value == "close":
|
|
return "error"
|
|
if value in {"new", "rewrite", "published", "no_image"}:
|
|
return value
|
|
if value in {"approved", "error", "review"}:
|
|
return value
|
|
return value
|
|
|
|
|
|
ALLOWED_UI_TRANSITIONS: dict[str, set[str]] = {
|
|
"new": {"rewrite", "close"},
|
|
"rewrite": {"publish", "close"},
|
|
"publish": {"published", "close"},
|
|
"published": {"rewrite", "close"},
|
|
"close": {"rewrite"},
|
|
"no_image": {"rewrite", "close"},
|
|
}
|