fix(transcribe): normalize www.-prefixed URLs before validation#2021
Open
kimdzhekhon wants to merge 1 commit into
Open
fix(transcribe): normalize www.-prefixed URLs before validation#2021kimdzhekhon wants to merge 1 commit into
kimdzhekhon wants to merge 1 commit into
Conversation
is_url() classifies a scheme-less "www.youtube.com/watch?v=..." input as a URL (it's in URL_PREFIXES), but download_audio() passed that raw string straight to security.validate_url(), which rejects it for having no http/https scheme. transcribe_all() only logs the resulting ValueError as a warning and silently drops the file, so any www.-form URL failed unconditionally. Add _normalize_url(): prepends https:// to www.-prefixed input before it reaches validate_url()/yt-dlp. Already-scheme'd URLs and plain file paths pass through unchanged. Found via codex-assisted code review, verified against the actual code before delegating the fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found via code review, not tied to an existing issue.
is_url()classifies a scheme-less"www.youtube.com/watch?v=..."input as a URL (www.is inURL_PREFIXES), butdownload_audio()passed that raw string straight tosecurity.validate_url(), which rejects anything without anhttp/httpsscheme.transcribe_all()only logs the resultingValueErroraswarning: could not transcribe ...and silently drops the file — so anywww.-form URL input failed unconditionally, with no clear signal why._normalize_url(): prependshttps://towww.-prefixed input before it reachesvalidate_url()/yt-dlp. Already-scheme'd URLs and plain file paths pass through unchanged.Test plan
tests/test_transcribe.py:www.input getshttps://prepended; already-scheme'd URLs and file paths are untouched;is_url()'s existing detection behavior is unchangeduv run pytest tests/test_transcribe.py -q— 19 passeduv run pytest tests/ -q— full suite: 3419 passed (5 pre-existing failures unrelated to this change, missing optionalopenaidependency in this environment)