Created
June 5, 2016 20:22
-
-
Save filviu/240a88efb94cd6b53876307faae3f0b3 to your computer and use it in GitHub Desktop.
Python script to download imgur album together with descritpions. Quick and dirty (api, secret and album id to set in file before running)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import textwrap | |
from urllib import urlretrieve | |
from progressbar import ProgressBar, Percentage, Bar | |
from imgurpython import ImgurClient | |
# API ID AND SECRET - REQUIRED | |
client_id = '' | |
client_secret = '' | |
client = ImgurClient(client_id, client_secret) | |
# Type here the album to download | |
items = client.get_album_images('TwY6q') | |
i = 1 | |
for item in items: | |
fileName = item.link.split('/')[-1] | |
# urlretrieve(item.link, str(i).zfill(3)+"-"+fileName) | |
text_file = open(str(i).zfill(3)+"-"+item.id+".txt", "w") | |
print 'Downloading '+item.link, | |
if item.description: | |
if item.title: | |
text_file.write(item.title) | |
text_file.write("\n\n"+item.description) | |
else: | |
# text_file.write(textwrap.fill(item.description.encode('utf-8'),79)) | |
text_file.write(item.description.encode('utf-8')) | |
text_file.close() | |
print 'DONE' | |
i += 1 | |
# break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment