From e92dc0c83ae7bfd9798554efa72f7269b3ac84d1 Mon Sep 17 00:00:00 2001 From: LongHairedHacker Date: Tue, 2 Oct 2018 14:23:21 +0200 Subject: [PATCH] Constant photo year Fixed rss --- photos.py | 3 ++- rss.py | 13 +++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/photos.py b/photos.py index a92a291..ec66e6b 100644 --- a/photos.py +++ b/photos.py @@ -12,6 +12,7 @@ from PIL import ImageDraw from StringIO import StringIO +YEAR = "2017" GALLERY_URL = "http://htt-phototeam.de/gallery.json" INPUT_RES = 1440 @@ -36,7 +37,7 @@ def get_random_photo(): resp = requests.get(GALLERY_URL) json = resp.json() - year = pick_random_key(json['photos']) + year = YEAR photographer = pick_random_key(json['photos'][year]) category = pick_random_key(json['photos'][year][photographer]) diff --git a/rss.py b/rss.py index df27d99..41c5ae9 100644 --- a/rss.py +++ b/rss.py @@ -7,7 +7,7 @@ import feedparser from lxml import html URLS_LIST = 'urls.lst' -RSS_URL = 'http://www.hoellenberg-trophy.de/index.php?format=feed&type=rss' +RSS_URL = 'https://htt-spirkelbach.de/feed/' def load_old_urls(): urls = [] @@ -35,11 +35,12 @@ def get_new_items(): for item in sorted(rss.entries, key=lambda x: x.published_parsed): url = item.link if not (url in old_urls): - text = html.fromstring(item.description).text_content() - if len(text) > 1: - text = ' '.join(text.split()) - new_items += [u'%s…\n%s' % (text[0:80], url)] - old_urls += [url] + if len(item.description) > 0: + text = html.fromstring(item.description).text_content() + if len(text) > 1: + text = ' '.join(text.split()) + new_items += [u'%s…\n%s' % (text[0:80], url)] + old_urls += [url] save_old_urls(old_urls)