Merge branch 'master' of github.com:LongHairedHacker/htt-daemon
This commit is contained in:
commit
2a2b8e9cc4
10
photos.py
10
photos.py
|
@ -19,10 +19,13 @@ INPUT_RES = 1440
|
||||||
FONT_SIZE = 20
|
FONT_SIZE = 20
|
||||||
TEXT_COLOR = (0, 0, 0)
|
TEXT_COLOR = (0, 0, 0)
|
||||||
|
|
||||||
|
def uniquote(stuff):
|
||||||
|
return quote(stuff.encode('utf-8'))
|
||||||
|
|
||||||
def make_url(year, category, photographer, pid):
|
def make_url(year, category, photographer, pid):
|
||||||
year = quote(year)
|
year = uniquote(year)
|
||||||
category = quote(category)
|
category = uniquote(category)
|
||||||
photographer = quote(photographer)
|
photographer = uniquote(photographer)
|
||||||
pid = pid + 1
|
pid = pid + 1
|
||||||
return u"http://htt-phototeam.de/#&gid=%s/%s/%s&pid=%d" % (year, category, photographer, pid)
|
return u"http://htt-phototeam.de/#&gid=%s/%s/%s&pid=%d" % (year, category, photographer, pid)
|
||||||
|
|
||||||
|
@ -42,6 +45,7 @@ def get_random_photo():
|
||||||
category = pick_random_key(json['photos'][year][photographer])
|
category = pick_random_key(json['photos'][year][photographer])
|
||||||
|
|
||||||
photos = json['photos'][year][photographer][category]
|
photos = json['photos'][year][photographer][category]
|
||||||
|
photos = sorted(photos, key = lambda photo: photo['thumb'])
|
||||||
pid = random.randint(0, len(photos) - 1)
|
pid = random.randint(0, len(photos) - 1)
|
||||||
photo_url = photos[pid]['images'][unicode(INPUT_RES)]['src']
|
photo_url = photos[pid]['images'][unicode(INPUT_RES)]['src']
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue