Repository: yt-dlp/yt-dlp

Issue:
getting corrupted videos from IMGUR
### 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 that yt-dlp is broken on a **supported** 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)
- [ ] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Mexico

### Provide a description that is worded well enough to be understood

The videos i try to download are embedded IMGUR videos on reddit posts.
The resulting file is a very small Mp4 file (0-50kb) that is unplayable.
The script worked sometimes, but it is unknown to me why it does work and why doesn't sometimes.
Command Line:
```
yt-dlp -vU -S "res:1440" -P "E:\ZE\download\Ytb-dlp" --concurrent-fragments 6  --downloader "dash,http:native" --downloader "m3u8:aria2c" --verbose %Input%
```



#### Things that i've tried that don't solve or change the outcome:
- The following command line yields the same outcome
  - ``` yt-dlp -S "proto" -P "E:\ZE\download\Ytb-dlp" --concurrent-fragments 6   --verbose %URL% ```
- Switched the URL between the reddit post and the IMGUR post E.g. (no success) 
  ``` https://www.reddit.com/r/kpopfap/comments/1bf9533/ive_liz/ ``` ``` https://imgur.com/zV03bd5 ```
- Attempting to Re-download a file that was downloaded correctly before results in the new file being downloaded corrupted. (tried both command lines, and both urls, resulting file is corrupted)

#### Other observations
- Script works as intended with other extractors (tested with youtube, embedded youtube video on reddit post, facebook video)

### 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
[debug] Command-line config: ['-vU', '-S', 'res:1440', '-P', 'E:\\ZE\\download\\Ytb-dlp', '--concurrent-fragments', '6', '--downloader', 'dash,http:native', '--downloader', 'm3u8:aria2c', '--verbose', 'https://www.reddit.com/r/kpopfap/comments/1bf9533/ive_liz/']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.03.14.232657 from yt-dlp/yt-dlp-nightly-builds [f2868b26e] (win32_dir)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 2023-12-21-git-1e42a48e37-full_build-www.gyan.dev (setts), ffprobe 2023-12-21-git-1e42a48e37-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.02.02, mutagen-1.47.0, requests-2.31.0, sqlite3-3.35.5, urllib3-2.2.1, websockets-12.0

[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1803 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.03.14.232657 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.03.14.232657 from yt-dlp/yt-dlp-nightly-builds)
[Reddit] Extracting URL: https://www.reddit.com/r/kpopfap/comments/1bf9533/ive_liz/
[Reddit] 1bf9533: Downloading JSON metadata
[Imgur] Extracting URL: https://i.imgur.com/zV03bd5.gifv
[Imgur] zV03bd5: Downloading JSON metadata
[Imgur] zV03bd5: Downloading webpage
[debug] Sort order given by user: res:1440
[debug] Formats sorted by: hasvid, ie_pref, res:1440(1440.0), lang, quality, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, size, br, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] zV03bd5: Downloading 1 format(s): 0
[debug] Invoking http downloader on "https://i.imgur.com/zV03bd5.mp4"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: E:\ZE\download\Ytb-dlp\Ive - Liz [zV03bd5].mp4
[download] 100% of    8.96KiB in 00:00:00 at 40.73KiB/s
```



Discussion:
Testing https://www.reddit.com/r/kpopfap/comments/1bf9533/ive_liz/ and https://imgur.com/zV03bd5 with yt-dlp 2023.06.22 gives (after redirecting in the first case):
```
[Imgur] Extracting URL: https://imgur.com/zV03bd5
[Imgur] zV03bd5: Downloading webpage
ERROR: [Imgur] zV03bd5: No sources found for video zV03bd5. Maybe an image?
```
But the equivalent yt-dl command (with the updated upstream extractor from https://github.com/ytdl-org/youtube-dl/pull/32612):
```
[Imgur] zV03bd5: Downloading JSON metadata
[Imgur] zV03bd5: Downloading webpage
[info] Available formats for zV03bd5:
format code  extension  resolution note
0            mp4        480x854    video only, 12.28MiB
``` 

fixed if I add
```diff
diff --git a/yt_dlp/extractor/imgur.py b/yt_dlp/extractor/imgur.py
index 1fa0a2a79..5c9313a5b 100644
--- a/yt_dlp/extractor/imgur.py
+++ b/yt_dlp/extractor/imgur.py
@@ -191,6 +191,7 @@ def og_get_size(media_type):
             }), get_all=False),
             'id': video_id,
             'formats': formats,
+            'http_headers': {'Accept': '*/*'},
             'thumbnail': url_or_none(search('thumbnailUrl')),
         }
 
```

workaround, pass this with your command:
```
--add-header "accept:*/*"
```

Resolving patch:
diff --git a/yt_dlp/extractor/imgur.py b/yt_dlp/extractor/imgur.py
--- a/yt_dlp/extractor/imgur.py
+++ b/yt_dlp/extractor/imgur.py
@@ -76,6 +76,23 @@ class ImgurIE(ImgurBaseIE):
             'thumbnail': 'https://i.imgur.com/jxBXAMCh.jpg',
             'dislike_count': int,
         },
+    }, {
+        # needs Accept header, ref: https://github.com/yt-dlp/yt-dlp/issues/9458
+        'url': 'https://imgur.com/zV03bd5',
+        'md5': '59df97884e8ba76143ff6b640a0e2904',
+        'info_dict': {
+            'id': 'zV03bd5',
+            'ext': 'mp4',
+            'title': 'Ive - Liz',
+            'timestamp': 1710491255,
+            'upload_date': '20240315',
+            'like_count': int,
+            'dislike_count': int,
+            'duration': 56.92,
+            'comment_count': int,
+            'release_timestamp': 1710491255,
+            'release_date': '20240315',
+        },
     }]
 
     def _real_extract(self, url):
@@ -192,6 +209,7 @@ def og_get_size(media_type):
             'id': video_id,
             'formats': formats,
             'thumbnail': url_or_none(search('thumbnailUrl')),
+            'http_headers': {'Accept': '*/*'},
         }
 
 


Test patch: