Repository: yt-dlp
Issue: Passing `--ignore-no-formats-error` can result in thumbnail getting written to the wrong location
Labels: bug,triage

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

If yt-dlp fails to find video formats, the file type specific output template that I specified does not get applied.

`
yt-dlp --ignore-no-formats-error --write-thumbnail -o 'thumbnail:thumb' -f sb0 -o 'storyboard' -- WDNATjo-9JE
`

After yt-dlp quits, the final name of the thumbnail file is storyboard.webp (instead of thumb.webp)

What appears to be happening here is that yt-dlp quits before getting the chance to rename the thumbnail. I noticed that under normal operation, this is one of the last operations to be logged:

```
[MoveFiles] Moving file "storyboard.webp" to "thumb.webp"
```

Renaming the thumbnail to the correct location seems to be one of the last things yt-dlp does under normal operation. Here, it never gets to happen.


### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
yt-dlp --ignore-no-formats-error -vq --ignore-config --write-thumbnail -o 'thumbnail:thumb' -f sb0 -o 'storyboard' -- WDNATjo-9JE
[debug] Command-line config: ['-vq', '--ignore-config', '--no-simulate', '--write-thumbnail', '-o', 'thumbnail:thumb', '-f', 'sb0', '-o', 'storyboard', '--ignore-no-formats-error', '--', 'WDNATjo-9JE']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.07.09 from yt-dlp/yt-dlp [7ead7332a]
[debug] Python 3.12.4 (CPython x86_64 64bit) - Linux-6.9.9-arch1-1-x86_64-with-glibc2.39 (OpenSSL 3.3.1 4 Jun 2024, glibc 2.39)
[debug] exe versions: ffmpeg 7.0.1 (setts), ffprobe 7.0.1
[debug] Optional libraries: Cryptodome-3.20.0, certifi-2024.07.04, mutagen-1.47.0, requests-2.32.3, sqlite3-3.46.0, urllib3-1.26.18, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1834 extractors
[youtube] Extracting URL: WDNATjo-9JE
[youtube] WDNATjo-9JE: Downloading webpage
[youtube] WDNATjo-9JE: Downloading ios player API JSON
[youtube] WDNATjo-9JE: Downloading player 8eff86d5
[debug] Saving youtube-nsig.8eff86d5 to cache
[debug] [youtube] Decrypted nsig 6LMgPljgARLX6jFlJSJ => j-XSReXqNOhX0Q
[debug] Loading youtube-nsig.8eff86d5 from cache
[debug] [youtube] Decrypted nsig mZmHnuoFvV6K51SJM4V => 7Y-baN2mBTUbrA
[youtube] WDNATjo-9JE: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
WARNING: Requested format is not available
Deleting existing file storyboard.webp
[info] Downloading video thumbnail 41 ...
[info] Video Thumbnail 41 does not exist
[info] Downloading video thumbnail 40 ...
[info] Video Thumbnail 40 does not exist
[info] Downloading video thumbnail 39 ...
[info] Video Thumbnail 39 does not exist
[info] Downloading video thumbnail 38 ...
[info] Video Thumbnail 38 does not exist
[info] Downloading video thumbnail 37 ...
[info] Video Thumbnail 37 does not exist
[info] Downloading video thumbnail 36 ...
[info] Video Thumbnail 36 does not exist
[info] Downloading video thumbnail 35 ...
[info] Writing video thumbnail 35 to: storyboard.webp
ERROR: [youtube] WDNATjo-9JE: No video formats found!
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1622, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1778, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1837, in process_ie_result
    ie_result = self.process_video_result(ie_result, download=download)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3011, in process_video_result
    self.process_info(new_info)
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 179, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3478, in process_info
    success, real_download = self.dl(temp_filename, info_dict)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 3167, in dl
    self.raise_no_formats(info, True)
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1119, in raise_no_formats
    raise ExtractorError(msg, video_id=info['id'], ie=info['extractor'],
yt_dlp.utils.ExtractorError: [youtube] WDNATjo-9JE: No video formats found!
```