Skip to content

Instantly share code, notes, and snippets.

@eapen
Created May 21, 2017 15:08
Show Gist options
  • Save eapen/f722804f40c574ad5e80ed4bdd0bdd38 to your computer and use it in GitHub Desktop.
Save eapen/f722804f40c574ad5e80ed4bdd0bdd38 to your computer and use it in GitHub Desktop.
Acquire free finisher photos from Yosemite Half 2017 since I wasnt wearing my bib
import urllib2
import json
RANGE = 1500
USERAGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36'
url = 'http://www.lucidimagesutshop.com/services/api/json/1.4.0/?galleryType=album&albumId=102388214&albumKey=w5FkcP&nodeId=9pBRHQ&PageNumber=1&imageId=0&imageKey=&returnModelList=true&PageSize=' + str(RANGE) + '&method=rpc.gallery.getalbum'
BASE_URL = 'http://www.lucidimagesutshop.com/2017-Races/Yosemite/FREE-Finisher-Photos/{}'
# URL:
# https://photos.smugmug.com/2017-Races/Yosemite/FREE-Finisher-Photos/i-VctQZ5B/0/9c28fe3c/D/387%201-D.jpg
doc = json.loads(urllib2.urlopen(url).read())
for i in range(0, RANGE):
image_key = doc['Images'][i]['ImageKey']
file_name = doc['Images'][i]['URLFilename'] + "-D.jpg"
url = BASE_URL.format("i-" + image_key)
image_url = (doc['Images'][i]['BaseUrl'] + "i-" + image_key + "/" + str(doc['Images'][i]['Index'])
+ "/" + doc['Images'][i]['UrlSignature'] + "/D/" + file_name)
with open('/tmp/yosemitehalf-' + file_name, 'wb') as f:
req = urllib2.Request(image_url)
req.add_header('Referer', url)
req.add_header('User-Agent', USERAGENT)
data = urllib2.urlopen(req)
f.write(data.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment