{"record":{"id":"99605c91fe42f373","repo":"ytdl-org/youtube-dl","slug":"r-is-not-a-valid-url-set-default-search-ytsea","errorCode":null,"errorMessage":"%r is not a valid URL. Set --default-search \"ytsearch\" (or run  youtube-dl \"ytsearch:%s\" ) to search YouTube","messagePattern":"%r is not a valid URL\\. Set --default-search \"ytsearch\" \\(or run  youtube-dl \"ytsearch:(.+?)\" \\) to search YouTube","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"warning","filePath":"youtube_dl/extractor/generic.py","lineNumber":2555,"sourceCode":"                default_search = 'fixup_error'\n\n            if default_search in ('auto', 'auto_warning', 'fixup_error'):\n                if re.match(r'^[^\\s/]+\\.[^\\s/]+/', url):\n                    self._downloader.report_warning('The url doesn\\'t specify the protocol, trying with http')\n                    return self.url_result('http://' + url)\n                elif default_search != 'fixup_error':\n                    if default_search == 'auto_warning':\n                        if re.match(r'^(?:url|URL)$', url):\n                            raise ExtractorError(\n                                'Invalid URL:  %r . Call youtube-dl like this:  youtube-dl -v \"https://www.youtube.com/watch?v=BaW_jenozKc\"  ' % url,\n                                expected=True)\n                        else:\n                            self._downloader.report_warning(\n                                'Falling back to youtube search for  %s . Set --default-search \"auto\" to suppress this warning.' % url)\n                    return self.url_result('ytsearch:' + url)\n\n            if default_search in ('error', 'fixup_error'):\n                raise ExtractorError(\n                    '%r is not a valid URL. '\n                    'Set --default-search \"ytsearch\" (or run  youtube-dl \"ytsearch:%s\" ) to search YouTube'\n                    % (url, url), expected=True)\n            else:\n                if ':' not in default_search:\n                    default_search += ':'\n                return self.url_result(default_search + url)\n\n        url, smuggled_data = unsmuggle_url(url)\n        force_videoid = None\n        is_intentional = smuggled_data and smuggled_data.get('to_generic')\n        if smuggled_data and 'force_videoid' in smuggled_data:\n            force_videoid = smuggled_data['force_videoid']\n            video_id = force_videoid\n        else:\n            video_id = self._generic_id(url)\n\n        self.to_screen('%s: Requesting header' % video_id)","sourceCodeStart":2537,"sourceCodeEnd":2573,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/generic.py#L2537-L2573","documentation":"Raised by the generic extractor when the URL has no scheme, the input does not look like a bare domain (fails ^[^\\s/]+\\.[^\\s/]+/), and default_search is 'error' or the default 'fixup_error'. It tells the user to either supply a full URL or opt into YouTube search. Marked expected=True.","triggerScenarios":"Passing a scheme-less argument that is not a domain path, e.g. 'youtube-dl BaW_jenozKc' or 'youtube-dl some random text', with default --default-search fixup_error (the default when unset) or explicit 'error'.","commonSituations":"Users pasting video IDs or titles instead of URLs, missing https:// prefix on copied links, or scripts passing unquoted/unset variables.","solutions":["Supply the full URL with scheme: youtube-dl \"https://www.youtube.com/watch?v=BaW_jenozKc\"","Or enable search: youtube-dl --default-search ytsearch BaW_jenozKc","Or use the ytsearch prefix directly: youtube-dl \"ytsearch:BaW_jenozKc\""],"exampleFix":"# before\nyoutube-dl BaW_jenozKc\n# after\nyoutube-dl \"ytsearch:BaW_jenozKc\"\n# or\nyoutube-dl \"https://www.youtube.com/watch?v=BaW_jenozKc\"","handlingStrategy":"validation","validationCode":"import re\ndef needs_scheme(u):\n    return not re.match(r'^[a-zA-Z][a-zA-Z0-9+.-]*://', u)\nif needs_scheme(arg):\n    arg = 'https://' + arg  # or reject, or prefix ytsearch:","typeGuard":"def is_full_url(u):\n    return bool(re.match(r'^https?://\\S+$', u))","tryCatchPattern":"try:\n    ydl.download([arg])\nexcept DownloadError as e:\n    if 'not a valid URL' in str(e):\n        arg = 'ytsearch:' + arg  # or fix the URL and retry\n    else:\n        raise","preventionTips":["Default --default-search ytsearch in wrapper scripts if users pass IDs/titles","Validate inputs have a scheme before invoking youtube-dl from code","Check variables are set before passing them as URLs"],"tags":["generic","cli-usage","url-validation","default-search"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}