fix(patreon): a missing media file_name is a URL-basename fallback, not API drift
The native client treated a gallery image without `file_name` as schema drift and raised "Patreon API changed — ingester needs update", failing the whole walk (operator-flagged 2026-06-07: BlenderKnight post 73665615, kind=images). But the resource had a valid URL, and the code already derives a filename from the URL basename right below the raise — the same fallback gallery-dl uses. Patreon legitimately serves some images without file_name, so this isn't drift. Drop the require_file_name gate from _media_item: file_name is now optional for every kind (images/attachments/postfile), falling back to the URL basename. Genuine drift still raises — no resolvable URL, or a media id referenced by a relationship but absent from `included`. Test updated to assert the fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -405,21 +405,19 @@ class PatreonClient:
|
||||
return candidate
|
||||
return None
|
||||
|
||||
def _media_item(
|
||||
self, attrs: dict, kind: str, post_id: str, *, require_file_name: bool
|
||||
) -> MediaItem:
|
||||
def _media_item(self, attrs: dict, kind: str, post_id: str) -> MediaItem:
|
||||
url = self._media_url(attrs)
|
||||
if not url:
|
||||
raise PatreonDriftError(
|
||||
f"Patreon media (post {post_id}, kind={kind}) had no resolvable URL "
|
||||
f"(no download_url / image_urls)"
|
||||
)
|
||||
# file_name is OPTIONAL: Patreon legitimately serves some gallery images
|
||||
# without it (operator-flagged 2026-06-07, BlenderKnight post 73665615),
|
||||
# and the URL basename is a fine fallback — the same thing gallery-dl
|
||||
# uses. A genuine schema change shows up as no URL (above) or a media id
|
||||
# absent from `included` (caller), not a missing name.
|
||||
file_name = attrs.get("file_name")
|
||||
if require_file_name and not (isinstance(file_name, str) and file_name):
|
||||
raise PatreonDriftError(
|
||||
f"Patreon media resource (post {post_id}, kind={kind}) missing "
|
||||
f"'file_name'"
|
||||
)
|
||||
filename = file_name if isinstance(file_name, str) and file_name else _basename_from_url(url)
|
||||
return MediaItem(
|
||||
url=url,
|
||||
@@ -452,11 +450,7 @@ class PatreonClient:
|
||||
f"Patreon post {post_id} references media {mid} "
|
||||
f"({rel_name}) not present in 'included'"
|
||||
)
|
||||
items.append(
|
||||
self._media_item(
|
||||
media_attrs, kind, post_id, require_file_name=True
|
||||
)
|
||||
)
|
||||
items.append(self._media_item(media_attrs, kind, post_id))
|
||||
|
||||
# 1. gallery images
|
||||
_resolve_rel("images", "images")
|
||||
|
||||
Reference in New Issue
Block a user