From dd2118a54705fb2c50fa9f524ff162032980a2d8 Mon Sep 17 00:00:00 2001 From: npeter83 Date: Tue, 11 Aug 2026 23:50:49 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20address=20/code-review=20=E2=80=94?= =?UTF-8?q?=20rename=20uploader=5Furl()=20to=20build=5Fuploader=5Furl()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The R12 S3 underscore-publish left worker.uploader_url() sharing a name with the `uploader_url` model attribute and the yt-dlp `"uploader_url"` info-dict key. The function is now build_uploader_url() — the attribute, dict key, log line and docstrings keep the plain `uploader_url` name. Rename touches only the def, its two call sites, and the backfill import; no behaviour change (ruff clean, pytest 193). --- backend/app/downloads/backfill.py | 4 ++-- backend/app/worker.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/app/downloads/backfill.py b/backend/app/downloads/backfill.py index af751966..3db13bf6 100644 --- a/backend/app/downloads/backfill.py +++ b/backend/app/downloads/backfill.py @@ -21,7 +21,7 @@ from app.db import SessionLocal from app.downloads import edit as editmod from app.downloads import formats, service from app.models import MediaAsset -from app.worker import uploader_url +from app.worker import build_uploader_url log = logging.getLogger("siftlode.backfill") @@ -73,7 +73,7 @@ def run() -> dict: if a.uploader_url is None and _should_refetch(a): url = a.source_webpage_url or service.source_url(a.source_kind, a.source_ref) info = _extract_meta(url) - uu = uploader_url(info) if info else None + uu = build_uploader_url(info) if info else None if uu: a.uploader_url = uu filled_url += 1 diff --git a/backend/app/worker.py b/backend/app/worker.py index aecd3432..c2949104 100644 --- a/backend/app/worker.py +++ b/backend/app/worker.py @@ -262,7 +262,7 @@ def _finish_from_cache(job_id: int, asset_id: int) -> None: db.commit() -def uploader_url(info: dict) -> str | None: +def build_uploader_url(info: dict) -> str | None: """The channel/uploader page URL for the auto-clickable channel line. YouTube gives a `channel_url`/`uploader_url` directly; Facebook gives neither but exposes a numeric `uploader_id` (the page id) that resolves at facebook.com/. Returns None for sources with @@ -290,7 +290,7 @@ def _fill_asset_meta_early(asset_id: int, info: dict) -> None: # the final title with its own source_ref fallback. asset.title = normalize_title(info.get("title")) or info.get("id") asset.uploader = info.get("uploader") or info.get("channel") - asset.uploader_url = uploader_url(info) + asset.uploader_url = build_uploader_url(info) asset.thumbnail_url = info.get("thumbnail") asset.duration_s = int(info["duration"]) if info.get("duration") else None asset.upload_date = _parse_upload_date(info.get("upload_date")) @@ -638,7 +638,7 @@ def _download(job_id: int, asset_id: int, source_kind: str, source_ref: str, spe asset.acodec = info.get("acodec") if info.get("acodec") not in (None, "none") else None asset.title = meta.title asset.uploader = meta.uploader - asset.uploader_url = uploader_url(info) + asset.uploader_url = build_uploader_url(info) asset.upload_date = meta.upload_date asset.thumbnail_url = meta.thumbnail_url # Record a self-hosted poster for every download: it's the reliable link-preview