fix(downloads): tighten SourceAdapter resolution + neutral nfo default (review)
- resolve_adapter: identify from the yt-dlp extractor_key only, not the full webpage_url (a sibling source's name in a URL path no longer misresolves); add youtube-nocookie.com to the YouTube host match so nocookie embeds keep the POT/player-client extraction strategy. - _download: re-resolve the adapter with the post-extraction info dict so the .nfo uniqueid type and uploader_url agree on one source (dedups the inline resolve too). - MediaMeta.uniqueid_type defaults to source-neutral "generic" instead of "youtube", so an un-updated caller can never falsely label a non-YouTube download as youtube. - Tests: lock extractor-key-only resolution + nocookie host; default nfo type.
This commit is contained in:
@@ -791,6 +791,9 @@ def _download(job_id: int, asset_id: int, source_kind: str, source_ref: str, spe
|
||||
adapter = adapters.resolve_adapter(source_kind, source_ref)
|
||||
url = service.source_url(source_kind, source_ref)
|
||||
info = _media_info(_extract_with_fallback(job_id, asset_id, url, spec, staging, adapter))
|
||||
# Re-resolve now that yt-dlp's info reveals the true source (a bare/redirected url only
|
||||
# identifies post-extraction) so the .nfo uniqueid type + uploader_url agree on one source.
|
||||
adapter = adapters.resolve_adapter(source_kind, source_ref, info)
|
||||
|
||||
produced = _produced_file(info, staging)
|
||||
produced = _ensure_browser_playable(job_id, produced, spec, info)
|
||||
@@ -834,7 +837,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 = adapters.resolve_adapter(source_kind, source_ref, info).uploader_url(info)
|
||||
asset.uploader_url = adapter.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
|
||||
|
||||
Reference in New Issue
Block a user