From 39d3dba6346387625af3ee8e6949cdbbda4f2dc7 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Fri, 8 Apr 2016 14:07:29 +0200 Subject: [PATCH 1/2] Fixed unicode fuckup --- photos.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/photos.py b/photos.py index a92a291..f957fc6 100644 --- a/photos.py +++ b/photos.py @@ -18,10 +18,13 @@ INPUT_RES = 1440 FONT_SIZE = 20 TEXT_COLOR = (0, 0, 0) +def uniquote(stuff): + return quote(stuff.encode('utf-8')) + def make_url(year, category, photographer, pid): - year = quote(year) - category = quote(category) - photographer = quote(photographer) + year = uniquote(year) + category = uniquote(category) + photographer = uniquote(photographer) pid = pid + 1 return u"http://htt-phototeam.de/#&gid=%s/%s/%s&pid=%d" % (year, category, photographer, pid) From 030137904b075489d9c3d44fc095ee64af074fdb Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Sun, 17 Jul 2016 02:40:18 +0200 Subject: [PATCH 2/2] Implemeted sorting to make picture ids match up --- photos.py | 1 + 1 file changed, 1 insertion(+) diff --git a/photos.py b/photos.py index f957fc6..4ec816f 100644 --- a/photos.py +++ b/photos.py @@ -44,6 +44,7 @@ def get_random_photo(): category = pick_random_key(json['photos'][year][photographer]) photos = json['photos'][year][photographer][category] + photos = sorted(photos, key = lambda photo: photo['thumb']) pid = random.randint(0, len(photos) - 1) photo_url = photos[pid]['images'][unicode(INPUT_RES)]['src']