feat(patreon): surface source URL + vanity in campaign-id resolution errors
Naming/lookup failures now report the source_url, the extracted vanity, and the exact campaigns-API lookup URL attempted, so a "could not resolve campaign id" error is diagnosable (wrong vanity? cookie/auth? creator renamed?) instead of opaque. Applied to all three resolution surfaces: the native download event, the dry-run preview, and the credential-verify probe. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,11 @@ from pathlib import Path
|
|||||||
|
|
||||||
from .gallery_dl import DownloadResult, ErrorType
|
from .gallery_dl import DownloadResult, ErrorType
|
||||||
from .patreon_ingester import PatreonIngester
|
from .patreon_ingester import PatreonIngester
|
||||||
from .patreon_resolver import resolve_campaign_id_for_source
|
from .patreon_resolver import (
|
||||||
|
_CAMPAIGNS_URL as _CAMPAIGNS_API,
|
||||||
|
extract_vanity,
|
||||||
|
resolve_campaign_id_for_source,
|
||||||
|
)
|
||||||
|
|
||||||
# Platforms whose download + verify go through the native ingester rather than
|
# Platforms whose download + verify go through the native ingester rather than
|
||||||
# gallery-dl. gallery-dl still serves every other platform (subscribestar,
|
# gallery-dl. gallery-dl still serves every other platform (subscribestar,
|
||||||
@@ -93,15 +97,19 @@ async def _run_native_ingester(
|
|||||||
ctx["url"], ctx["cookies_path"], overrides
|
ctx["url"], ctx["cookies_path"], overrides
|
||||||
)
|
)
|
||||||
if not campaign_id:
|
if not campaign_id:
|
||||||
|
url = ctx["url"]
|
||||||
|
vanity = extract_vanity(url)
|
||||||
return (
|
return (
|
||||||
DownloadResult(
|
DownloadResult(
|
||||||
success=False,
|
success=False,
|
||||||
url=ctx["url"],
|
url=url,
|
||||||
artist_slug=ctx["artist_slug"],
|
artist_slug=ctx["artist_slug"],
|
||||||
platform="patreon",
|
platform="patreon",
|
||||||
error_type=ErrorType.NOT_FOUND,
|
error_type=ErrorType.NOT_FOUND,
|
||||||
error_message=(
|
error_message=(
|
||||||
"Could not resolve Patreon campaign id from the source URL "
|
f"Could not resolve Patreon campaign id. source_url={url!r}; "
|
||||||
|
f"vanity={vanity!r}; "
|
||||||
|
f"lookup=GET {_CAMPAIGNS_API}?filter[vanity]={vanity or ''} "
|
||||||
"(vanity lookup failed — cookies expired or creator moved?)"
|
"(vanity lookup failed — cookies expired or creator moved?)"
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -172,9 +180,11 @@ async def preview_source(
|
|||||||
url, cookies_path, config_overrides or {}
|
url, cookies_path, config_overrides or {}
|
||||||
)
|
)
|
||||||
if not campaign_id:
|
if not campaign_id:
|
||||||
|
vanity = extract_vanity(url)
|
||||||
return {
|
return {
|
||||||
"error": (
|
"error": (
|
||||||
"Couldn't resolve the campaign id from the source URL "
|
f"Couldn't resolve the campaign id. source_url={url!r}; "
|
||||||
|
f"vanity={vanity!r}; lookup=GET {_CAMPAIGNS_API}?filter[vanity]={vanity or ''} "
|
||||||
"(cookies expired, or the creator moved/renamed?)."
|
"(cookies expired, or the creator moved/renamed?)."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ from .patreon_client import (
|
|||||||
PatreonDriftError,
|
PatreonDriftError,
|
||||||
)
|
)
|
||||||
from .patreon_downloader import PatreonDownloader
|
from .patreon_downloader import PatreonDownloader
|
||||||
from .patreon_resolver import resolve_campaign_id_for_source
|
from .patreon_resolver import extract_vanity, resolve_campaign_id_for_source
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"DEAD_LETTER_THRESHOLD",
|
"DEAD_LETTER_THRESHOLD",
|
||||||
@@ -186,9 +186,11 @@ async def verify_patreon_credential(
|
|||||||
"""
|
"""
|
||||||
campaign_id, _ = await resolve_campaign_id_for_source(url, cookies_path, overrides)
|
campaign_id, _ = await resolve_campaign_id_for_source(url, cookies_path, overrides)
|
||||||
if not campaign_id:
|
if not campaign_id:
|
||||||
|
vanity = extract_vanity(url)
|
||||||
return None, (
|
return None, (
|
||||||
"Couldn't resolve the Patreon campaign id from the source URL — "
|
f"Couldn't resolve the Patreon campaign id — can't verify. "
|
||||||
"can't verify (cookies expired, or the creator moved/renamed?)."
|
f"source_url={url!r}; vanity={vanity!r} "
|
||||||
|
"(cookies expired, or the creator moved/renamed?)."
|
||||||
)
|
)
|
||||||
client = PatreonClient(cookies_path)
|
client = PatreonClient(cookies_path)
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
|
|||||||
Reference in New Issue
Block a user