import urllib2 , json
start = 1
def generateurl(url,page=1):
	tumblrurl = "http://api.tumblr.com/v2/blog/"+url+".tumblr.com/posts?type=photo&api_key=REVdGcfNlXa4vBx2ZFFvcXnOwhkEYChsx3g0W6ERvxtTVOcJBy&offset="
	tumblrurl += str((page-1)*20)
	print tumblrurl #@debug: url test
	return tumblrurl
def getContent(url):
	resp = urllib2.urlopen(url)
	data = resp.read()
	externaldata = json.loads(data)
	#print externaldata #@debug , json parsing test
	return externaldata
def checkJson(data):
	return data["meta"]["status"] == 200
def getImages(data):
	if checkJson(data):
		print "move on"
	else:
		print "tumblr blog not found or not accessible!"
	datas = data["response"]["posts"]
	result = []
	for x in range(len(datas)):
		j = len(datas[x]["photos"])
		for y in range(j):
			result.append(datas[x]["photos"][y]["original_size"]["url"])
	# print len(datas)
	# print result#@debug : jsonlist fill test
	return result
def downloadImages(src):
	if len(src) is 0:
		print "have a nice day"
		exit()
	for x in range(len(src)):
		el = src[x]
		downloadImage(el)
	pass
def downloadImage(url):
	print url + "\nnow downloading..."
	filename =  url[url.rfind('/')+1:]
	# print filename#@debug filename test
	f = open("tumblr/"+filename,'wb')
	f.write(urllib2.urlopen(url).read())
	f.close()
	print "done"
def test(start,status = 0):
	url = generateurl("kemalkanok",start)
	start+=1
	# print start#@debug , counter tester
	data = getContent(url)
	images = getImages(data)
	downloadImages(images)
	if status is 0:
		if raw_input('again?[Y]/n')  in ['Y','y','']:
			again(start,status)
		else:
			print "have a nice day"
	else:
		again(start,status)
def again(start,status):
	test(start,status)


test(start,1)


Create main.py