Package: imgur-downloader
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 - FeaturesHere’s some examples of the types of links that are now supported:http://imgur.com/FVRUGe2http://imgur.com/FVRUGe2.jpghttp://imgur.com/gallery/LHCvGPAhttp://imgur.com/r/awwnime/W7N6Ahttp://i.imgur.com/j9W9tSi.jpghttp://imgur.com/a/SVq41http://i.imgur.com/A61SaA1.gifvName of album folder or image is determined by HTML<title>value or passed parameters.Prevents downloading of ImgurDoes Not Existimage
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).pngAdd–print-onlyoption 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 ininitparameter.Added functionis_imgur_dne_image(self, img_path),
which returnsTrueif the image fromimg_pathis the same image as the Imgur does not exist image
and returnFalseotherwise.Added functionare_files_equal(self, file1, file2),
which compares the bytes and returnsTrueif the bytes are equal, and returnFalseotherwiseImgurDownloader('http://i.imgur.com/removed.png',delete_dne=True,debug=True).save_images()Downloads imgur links with .gifv extension as a mp4 fileImgurDownloader('http://i.imgur.com/A61SaA1.gifv').save_images()save_images&direct_downloadmethods 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 fromsave_imagesmethod:# Code ran (url is an imgur Album with 5 images):print(imguralbum.ImgurDownloader(url,dir1,file_name=rand_name,debug=False).save_images())# output: (5, 0)Init function parameter changesSecond optional parameter,dir_download=os.getcwd(),
which allows for specific directory to download to (not adapted for cli), e.g.:ImgurDownloader('http://imgur.com/SnkkAVU','/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.:ImgurDownloader('http://imgur.com/SnkkAVU','/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.:ImgurDownloader('http://imgur.com/SnkkAVU','/home/user/Downloads/','my-img',True)Fifth optional parameter, debug=False,
which prints a number of variables throughout the code as it runsImgurDownloader('http://imgur.com/SnkkAVU','/home/user/Downloads/','my-img',True,True)RequirementsPython >= 3.3Command Line Usage$imgur_downloader[albumURL][foldertosaveto]Download all images from an album into the folder /Users/alex/images/downloaded$imgur_downloaderhttp://imgur.com/a/uOOju/Users/alex/images/downloadedDownloads all images and puts them into an album in the current directory called “uOOju”$imgur_downloaderhttp://imgur.com/a/uOOjuIt can also be used with downloader such aswgetusing–print-onlyoption.$imgur_downloader--print-onlyhttp://imgur.com/a/SVq41|xargswgetClass UsageThe 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("http://imgur.com/a/uOOju")print("This albums has{}images".format(downloader.num_images()))downloader.save_images()CallbacksYou can hook into the classes process through a couple of callbacks:downloader.on_image_download()downloader.on_complete()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 docsThe 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.LicenseMITCreditsOriginally written byAlex Gisby(@alexgisby)WithContributions from these amazing people!)