Fork me on GitHub

Project Notes

#049 Using Python with the imgur API

Using Python with the imgur API and demonstrate scanning imgur albums for image links.

API Clients

The imgur API changed some time back to require Oauth2 authentication. Unfortunately, many of the imgur scripts and libraries for many languages never caught up.

One that has been updated and appears to work very well is the official imgur python client.

Installation

This tool uses the official imgur python client. Install with pip:

$ pip install -r requirements.txt

Run

Requires registration to get a CLIENT_ID and CLIENT_SECRET.

The scan_gallery.py script is a simple tool for grabbing a list of images from an imgur album.

The script expects to find CLIENT_ID and CLIENT_SECRET from the environment. The gallery to scan is provided as a command-line argument.

e.g. to scan the album at http://imgur.com/a/CNIUR:

$ CLIENT_ID=abc CLIENT_SECRET=xyz ./scan_gallery.py -g CNIUR
http://i.imgur.com/JJgV4Ka.jpg
http://i.imgur.com/gEUkSX6.jpg
http://i.imgur.com/s2JThqR.jpg
http://i.imgur.com/gyZa5M7.jpg
http://i.imgur.com/3uG3rOp.jpg
http://i.imgur.com/CRgCwAq.jpg
http://i.imgur.com/5yBu0NP.jpg
http://i.imgur.com/w3ETIqm.jpg
http://i.imgur.com/v5QZSwT.jpg
http://i.imgur.com/xC1T6wa.jpg
http://i.imgur.com/0aH45mM.jpg
http://i.imgur.com/iHKJv3C.jpg
http://i.imgur.com/HF8UXcJ.jpg
http://i.imgur.com/Pvu9Tnc.jpg
http://i.imgur.com/ZS7R46J.jpg
http://i.imgur.com/T0cBk9l.jpg
http://i.imgur.com/NrTz9jk.jpg
http://i.imgur.com/zwyJBDh.jpg
http://i.imgur.com/EZE5riJ.jpg
http://i.imgur.com/znNcquG.jpg

These links are to the original size image. Thumbnails are available by appending size indicator to the image name according to the imgur gallery data model

e.g.

  • http://i.imgur.com/znNcquG.jpg - full size
  • http://i.imgur.com/znNcquGm.jpg - Medium Thumbnail 320x320

References

About LCK#72 pythonimgur
Project Source on GitHub Return to the Project Catalog

This page is a web-friendly rendering of my project notes shared in the LittleCodingKata GitHub repository.

LittleCodingKata is my collection of programming exercises, research and code toys broadly spanning things that relate to programming and software development (languages, frameworks and tools).

These range from the trivial to the complex and serious. Many are inspired by existing work and I'll note credits and references where applicable. The focus is quite scattered, as I variously work on things new and important in the moment, or go back to revisit things from the past.

This is primarily a personal collection for my own edification and learning, but anyone who stumbles by is welcome to borrow, steal or reference the work here. And if you spot errors or issues I'd really appreciate some feedback - create an issue, send me an email or even send a pull-request.