Skip to main content

Python script/class to download an entire Imgur album in one go into a folder of your choice

Project description

This is a simple Python script that contains a class and command line interface that allows you to download ann images at full resolution with any imgur link, all at once.

jtara1 Fork - Features

  • Here’s some examples of the types of links that are now supported:

  • Name of album folder or image is determined by HTML <title> value or passed parameters.

  • Prevents downloading of Imgur Does Not Exist image by checking if direct link url got redirected & comparing the bytearrays of the direct link image with that of a local file.

  • Uses album/gallery/image title as folder title that’s created and contains image(s) with key appended e.g.:

    We don't have a blue backdrop, just tint the whole photo blue. (SnkkAVU).png
  • Add –print-only option to print the direct link of the imgur url.

  • Prevents downloading of imgur does not exist image if it is encountered. It is implemented by comparing the bytes of the HTTP request to that of a local imgur dne file in program. This feature is toggleable in init parameter.

  • Added function is_imgur_dne_image(self, img_path), which returns True if the image from img_path is the same image as the Imgur does not exist image and return False otherwise.

  • Added function are_files_equal(self, file1, file2), which compares the bytes and returns True if the bytes are equal, and return False otherwise

    '', delete_dne=True, debug=True
  • Downloads imgur links with .gifv extension as a mp4 file

  • save_images & direct_download methods now return tuple of two integers. The first integer represent successful downloads and the second represent skipped download (either failed or Imgur DNE detected). For example the value on the the last line of the output is what’s returned from save_images method:

# Code ran (url is an imgur Album with 5 images):
        url, dir1, file_name=rand_name, debug=False
# output: (5, 0)

Init function parameter changes

  • Second optional parameter, dir_download=os.getcwd(), which allows for specific directory to download to (not adapted for cli), e.g.:

ImgurDownloader('', '/home/user/Downloads/')
  • Third optional parameter, file_name=’’, which allows user to specify name of file if input is single image or folder if input is album. Note this takes priority over the imgur key and the album webpage title e.g.:

    '', '/home/user/Downloads/', 'my-img')
  • Fourth optional parameter, delete_dne=True, which checks each image downloaded and deletes it if its bytes match that of imgur-dne.png, e.g.:

    '', '/home/user/Downloads/', 'my-img', True)
  • Fifth optional parameter, debug=False, which prints a number of variables throughout the code as it runs

    '', '/home/user/Downloads/', 'my-img', True, True)


Python >= 3.3

Command Line Usage

$ imgur_downloader [album URL] [folder to save to]

Download all images from an album into the folder /Users/alex/images/downloaded

$ imgur_downloader /Users/alex/images/downloaded

Downloads all images and puts them into an album in the current directory called “uOOju”

$ imgur_downloader

It can also be used with downloader such as wget using –print-only option.

$ imgur_downloader --print-only | xargs wget

Class Usage

The class allows you to download imgur albums in your own Python programs without going through the command line. Here’s an example of it’s usage:

downloader = ImgurDownloader("")
print("This albums has {} images".format(downloader.num_images()))


You can hook into the classes process through a couple of callbacks:


You can see what params and such your callback functions get by looking at the docblocks for the on_* functions in the .py file.

Full docs

The whole shebang, class and CLI is fully documented using string-docblock things in the single .py file so please read through that rather than rely on this readme which could drift out of date.




Originally written by Alex Gisby (@alexgisby)

With Contributions from these amazing people!)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imgur_downloader-0.2.2.tar.gz (15.9 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page