Seklfreak / discord-image-downloader-go

A simple tool which downloads pictures posted in discord channels of your choice to a local folder.
MIT License
350 stars 90 forks source link

Download imgur video in better format #85

Open Kakkela opened 6 years ago

Kakkela commented 6 years ago

Currently if Imgur video is linked as anything other than strict mp4 link it will download GIF format.

Xevion commented 4 years ago

I made a similar application (but instead for Reddit, and for saved images) in Python.

 resp = requests.get(f'https://api.imgur.com/3/album/{source}', headers=self.headers)
if resp.ok:
    logger.debug(f'Album is accessible. ({resp.status_code})')
    resp = resp.json()
    # Prefer webm > mp4 > gif in that order. Will always get best link possible with minimum retries.
    images = [image.get('webm') or image.get('mp4') or image.get('link') for image in resp['data']['images']]
     logger.debug(f'Found {len(images)} in album.')
    return images

The snippet above checks the API response and looks for a webm, mp4 and link keys in the JSON response, in that order, until it finds one. I think most people prefer their files in a similar order. I believe Imgur also supplies some kind of weird m3u file as well.

If this issue is EVER considered again and you hop back into developing this application, adding support for the Imgur API would be a positive development, as it would support up to 3% of all links that have ever passed through this application. A great development, indeed.