<commit_before># The simplest tool ever to grab images from a reddit subreddit.
#
# I've seen alternatives to this, and I've also seen tools get the job done more nicely
# but this is created for simplicity and minimalism, I wanted to create the simplest image download I can.
#
# Baha - <EMAIL> - @meddbeibia
# JULY 12, 2015
import praw
import urllib
import gallery_get
import time

r = praw.Reddit(user_agent='An image downloader - <EMAIL>')
submissions = r.get_subreddit('pics').get_hot(limit=25) # subreddit in this case is 'pics', you could change the subreddit (hopefully not to /r/gonewild)
														# You could also change the page limit (reddit allows up to 1000)

print '---------- Initializing download ----------'
time.sleep(1)
print '----------      Downloading      ----------'
print ('\n')
for submission in submissions:
   try:

	if "imgur.com/a/" in submission.url: # launch the gallery_get module if this condition is true (if the link is an album)
		print ("> " + submission.url)
		gallery_get.run(submission.url)

	elif "http://imgur.com/" in submission.url: # if the link is not a direct link (as in http://imgur.com/picture.jpg) a direct one will be appended to it
		#print submission.url
		url = submission.url + ".jpg"
		print ('> * ' + url)
		urllib.urlretrieve(url, "Picture - "+submission.id+".jpg")

	else: 
		urllib.urlretrieve(submission.url, "Picture - "+submission.id+".jpg")
		print ("> " + submission.url)
   except:
        pass<commit_msg>Added a get_pics function, and cleaned up some code.<commit_after>""""
The simplest tool ever to grab images from a reddit subreddit.
I've seen alternatives to this, and I've also seen tools get the job done more nicely
but this is created for simplicity and minimalism, I wanted to create the simplest image download I can.

Baha - <EMAIL> - @meddbeibia
JULY 12, 2015
"""
import praw
import urllib
import gallery_get


USERAGENT = 'Image downloader by /u/medtn'
SUBREDDIT = raw_input("Please enter the name of the subreddit: ")


def get_pics():
    """
    Added a a get_pics function based on a suggestion form /u/schleifer
    """
r = praw.Reddit(USERAGENT)
submissions = r.get_subreddit(SUBREDDIT).get_hot(limit=25)

print'Starting download for subreddit :', SUBREDDIT, '\n'

for submission in submissions:
	try:
		if "imgur.com/a/" in submission.url: # launch the gallery_get module if this condition is true (if the link is an album)
				print ("> " + submission.url)
				gallery_get.run(submission.url)

		elif "http://imgur.com/" in submission.url: # if the link is not a direct link (as in http://imgur.com/picture.jpg) a direct one will be appended to it
			url = submission.url + ".jpg"
			print ('> * ' + url)
			urllib.urlretrieve(url, "Picture - "+submission.id+".jpg")

		else: 
			urllib.urlretrieve(submission.url, "Picture - "+submission.id+".jpg")
			print ("> " + submission.url)
	except:
			pass



if __name__ == '__main__':
    if not USERAGENT:
        print('Missing useragent')
    elif not SUBREDDIT:
        print('Missing subreddit')
    else:
        get_pics()
{'fraction_non_alphanumeric': 0.12076822916666667, 'fraction_numerical': 0.0068359375, 'mean_word_length': 3.42158273381295, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1138915', 'n_tokens_mistral': 1056, 'n_tokens_neox': 976, 'n_words': 352}