imgur: download videos as mp4 instead of gif
Some imgur URLS have the extension ".gifv" and show up as a gif, even though they're actually supposed to be mp4 videos. Imgur serves all videos/gifs as both .gif and .mp4. The image dict has a key "prefer_video" to distinguish the two. This commit overrides the .gif extension if "prefer_video" is true to ensure we download the submission as originally intended.
This commit is contained in:
1 parent
063caf0126
commit
33312687ac
2 files changed
+14
-2
No files matched your search
@@ -32,7 +32,11 @@ class Imgur(BaseDownloader):
|
||||
return out
|
||||
|
||||
def _compute_image_url(self, image: dict) -> Resource:
|
||||
image_url = 'https://i.imgur.com/' + image['hash'] + self._validate_extension(image['ext'])
|
||||
ext = self._validate_extension(image['ext'])
|
||||
if image.get('prefer_video', False):
|
||||
ext = '.mp4'
|
||||
|
||||
image_url = 'https://i.imgur.com/' + image['hash'] + ext
|
||||
return Resource(self.post, image_url, Resource.retry_download(image_url))
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in new issue
Block a user