{"record":{"id":"1bc314c8f4c29875","repo":"ytdl-org/youtube-dl","slug":"requested-format-not-available","errorCode":null,"errorMessage":"requested format not available","messagePattern":"requested format not available","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"warning","filePath":"youtube_dl/YoutubeDL.py","lineNumber":1858,"sourceCode":"        # as well.\n        # We will pass a context object containing all necessary additional data\n        # instead of just formats.\n        # This fixes incorrect format selection issue (see\n        # https://github.com/ytdl-org/youtube-dl/issues/10083).\n        incomplete_formats = (\n            # All formats are video-only or\n            all(f.get('vcodec') != 'none' and f.get('acodec') == 'none' for f in formats)\n            # all formats are audio-only\n            or all(f.get('vcodec') == 'none' and f.get('acodec') != 'none' for f in formats))\n\n        ctx = {\n            'formats': formats,\n            'incomplete_formats': incomplete_formats,\n        }\n\n        formats_to_download = list(format_selector(ctx))\n        if not formats_to_download:\n            raise ExtractorError('requested format not available',\n                                 expected=True)\n\n        if download:\n            if len(formats_to_download) > 1:\n                self.to_screen('[info] %s: downloading video in %s formats' % (info_dict['id'], len(formats_to_download)))\n            for format in formats_to_download:\n                new_info = dict(info_dict)\n                new_info.update(format)\n                self.process_info(new_info)\n        # We update the info dict with the best quality format (backwards compatibility)\n        info_dict.update(formats_to_download[-1])\n        return info_dict\n\n    def process_subtitles(self, video_id, normal_subtitles, automatic_captions):\n        \"\"\"Select the requested subtitles and their format\"\"\"\n        available_subs = {}\n        if normal_subtitles and self.params.get('writesubtitles'):\n            available_subs.update(normal_subtitles)","sourceCodeStart":1840,"sourceCodeEnd":1876,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/YoutubeDL.py#L1840-L1876","documentation":"DateRange.__init__ raises this ValueError when the parsed start date is strictly after the parsed end date. DateRange backs youtube-dl's --date-after/--date-before (and --date) filtering; the check is a plain sanity assertion that the interval is non-empty. Dates are parsed with date_from_str, which also supports relative expressions like 'now-1week' and 'today'.","triggerScenarios":"Passing DateRange('20191231', '20191201'), or on the CLI --date-after 20191231 --date-before 20191201. Relative expressions can also produce inverted ranges, e.g. --date-after today --date-before yesterday, or a negative window like DateRange('now-1days','now-2days').","commonSituations":"Script-generated date windows where the bounds are computed independently and end up swapped; misunderstanding that --date-before is the exclusive/inclusive upper bound vs --date-after; typos in YYYYMMDD strings ordering them backwards; timezone shifts making 'today' vs 'now' comparisons invert near midnight UTC.","solutions":["Swap or fix the bounds so start <= end (DateRange('20191201', '20191231')).","If bounds come from variables, normalize them first: start, end = min(start, end), max(start, end).","Double-check relative syntax: --date-after now-1week --date-before now is valid; the reverse order is not.","Verify date strings match the accepted format (YYYYMMDD or supported relative forms) — malformed values often parse to unexpected dates and then invert the range."],"exampleFix":"# before\nrange_ = DateRange(args.after, args.before)  # raises if after > before\n\n# after\nstart, end = sorted([args.after, args.before])\nrange_ = DateRange(start, end)","handlingStrategy":"validation","validationCode":"from youtube_dl.utils import DateRange, date_from_str\n\ndef safe_range(start, end):\n    s = date_from_str(start) if start else None\n    e = date_from_str(end) if end else None\n    if s and e and s > e:\n        raise ValueError('start %s is after end %s' % (s, e))\n    return DateRange(start, end)","typeGuard":null,"tryCatchPattern":"from youtube_dl.utils import DateRange\ntry:\n    dr = DateRange(after, before)\nexcept ValueError as e:\n    if 'start date must be before the end date' in str(e):\n        after, before = sorted([after, before])\n        dr = DateRange(after, before)\n    else:\n        raise","preventionTips":["Normalize bounds with min/max (or sorted()) before constructing DateRange.","Remember relative syntax: --date-after now-1week --date-before now is valid; the reverse is not.","When generating windows in scripts, always derive both ends from one base date."],"tags":["dates","validation","cli-options"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}