diff --git a/backend/app/services/download_backends.py b/backend/app/services/download_backends.py index 082b92b..3afdcd6 100644 --- a/backend/app/services/download_backends.py +++ b/backend/app/services/download_backends.py @@ -25,7 +25,11 @@ from pathlib import Path from .gallery_dl import DownloadResult, ErrorType 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 # 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 ) if not campaign_id: + url = ctx["url"] + vanity = extract_vanity(url) return ( DownloadResult( success=False, - url=ctx["url"], + url=url, artist_slug=ctx["artist_slug"], platform="patreon", error_type=ErrorType.NOT_FOUND, 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?)" ), ), @@ -172,9 +180,11 @@ async def preview_source( url, cookies_path, config_overrides or {} ) if not campaign_id: + vanity = extract_vanity(url) return { "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?)." ) } diff --git a/backend/app/services/patreon_ingester.py b/backend/app/services/patreon_ingester.py index 5915da7..be2c973 100644 --- a/backend/app/services/patreon_ingester.py +++ b/backend/app/services/patreon_ingester.py @@ -45,7 +45,7 @@ from .patreon_client import ( PatreonDriftError, ) 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__ = [ "DEAD_LETTER_THRESHOLD", @@ -186,9 +186,11 @@ async def verify_patreon_credential( """ campaign_id, _ = await resolve_campaign_id_for_source(url, cookies_path, overrides) if not campaign_id: + vanity = extract_vanity(url) return None, ( - "Couldn't resolve the Patreon campaign id from the source URL — " - "can't verify (cookies expired, or the creator moved/renamed?)." + f"Couldn't resolve the Patreon campaign id — can't verify. " + f"source_url={url!r}; vanity={vanity!r} " + "(cookies expired, or the creator moved/renamed?)." ) client = PatreonClient(cookies_path) loop = asyncio.get_running_loop()