ytdl-org/youtube-dl · error · ExtractorError

Did you forget to quote the URL? Remember that & is a meta c

Error message

Did you forget to quote the URL? Remember that & is a meta character in most shells, so you want to put the URL in quotes, like  youtube-dl "https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc"  or simply  youtube-dl BaW_jenozKc  .

What it means

Raised by YoutubeTruncatedURLIE._real_extract, a stub extractor that matches youtube.com/watch URLs missing the video id (e.g. only ?feature=foo or ?t=2372 remains). Its sole purpose is to produce a helpful, expected=True message telling the user the URL was cut — almost always because an unquoted '&' in the shell terminated the query string. No extraction is attempted.

Source

Thrown at youtube_dl/extractor/youtube.py:4474

    }, {
        'url': 'https://www.youtube.com/watch?',
        'only_matching': True,
    }, {
        'url': 'https://www.youtube.com/watch?x-yt-cl=84503534',
        'only_matching': True,
    }, {
        'url': 'https://www.youtube.com/watch?feature=foo',
        'only_matching': True,
    }, {
        'url': 'https://www.youtube.com/watch?hl=en-GB',
        'only_matching': True,
    }, {
        'url': 'https://www.youtube.com/watch?t=2372',
        'only_matching': True,
    }]

    def _real_extract(self, _):
        raise ExtractorError(
            'Did you forget to quote the URL? Remember that & is a meta '
            'character in most shells, so you want to put the URL in quotes, '
            'like  youtube-dl '
            '"https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc" '
            ' or simply  youtube-dl BaW_jenozKc  .',
            expected=True)


class YoutubeTruncatedIDIE(InfoExtractor):
    IE_NAME = 'youtube:truncated_id'
    IE_DESC = False  # Do not list
    _VALID_URL = r'https?://(?:www\.)?youtube\.com/watch\?v=(?P<id>[0-9A-Za-z_-]{1,10})$'

    _TESTS = [{
        'url': 'https://www.youtube.com/watch?v=N_708QY7Ob',
        'only_matching': True,
    }]

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Quote the URL: youtube-dl "https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc".
  2. Or shorten to the bare id: youtube-dl BaW_jenozKc.
  3. In scripts, always pass URLs as properly quoted single arguments (list argv, not string interpolation subject to word splitting).

Example fix

# before
youtube-dl https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc

# after
youtube-dl "https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc"
# or
youtube-dl BaW_jenozKc
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse, parse_qs

def url_has_video_id(url: str) -> bool:
    return bool(parse_qs(urlparse(url).query).get('v')) or re.fullmatch(r'[0-9A-Za-z_-]{11}', url) is not None

Try / catch

try:
    info = ydl.extract_info(url)
except ExtractorError as e:
    if 'Did you forget to quote the URL?' in str(e):
        url = shell_quote(url)  # fix argv construction and retry
        info = ydl.extract_info(url)
    else:
        raise

Prevention

When it happens

Trigger: Running youtube-dl https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc without quotes: the shell runs the part before & as the command, so youtube-dl receives https://www.youtube.com/watch?feature=foo, which matches the truncated-URL IE and triggers this message.

Common situations: Unquoted URLs in bash/zsh (most common); scripts building URLs with word-splitting; copied URLs truncated at the first &; also matches watch?hl=... or watch?t=... alone per the only_matching tests.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/1d1cb3412c8277b6. Report an issue: GitHub.