From 6c54ff705e5c1133a46039cf654ac54cd4179955 Mon Sep 17 00:00:00 2001 From: makefu Date: Wed, 1 Apr 2020 00:03:40 +0200 Subject: ebknotify: add more info --- ebknotify/cache.py | 12 ++++++++++-- ebknotify/cli.py | 2 +- ebknotify/feed.py | 7 ++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ebknotify/cache.py b/ebknotify/cache.py index fbc4b9b..d1188dd 100644 --- a/ebknotify/cache.py +++ b/ebknotify/cache.py @@ -47,10 +47,16 @@ class Cache(): title = ad.get('title', {}).get('value', '').encode('utf-8') title_unescaped = html_unescape(title) try: - img = ad['pictures']['picture'][0]['link'][4]['href'] + img = ad['pictures']['picture'][0]['link'][3]['href'] except Exception as e: - print(e) img = None + try: + place = ad['locations']['location'][0]['localized-name']['value'] + radius = ad['locations']['location'][0]['radius']['value'] + except Exception as e: + print(e) + place = None + radius = None # TODO: fetch detailed article ad['notify'] = { 'filter': searchquery, @@ -59,6 +65,8 @@ class Cache(): 'first-seen': now.isoformat(), 'title-unescaped': title_unescaped, 'age_in_h': age_in_h, + 'place': place, + 'radius': radius, 'price': price, 'image': img, 'url': ad['link'][1]['href'], diff --git a/ebknotify/cli.py b/ebknotify/cli.py index ad7d0b7..7b9e612 100644 --- a/ebknotify/cli.py +++ b/ebknotify/cli.py @@ -7,7 +7,7 @@ options: if not set ebk-notify will check in config unter the 'items' key --cache=FILE Path to cache file [Default: ~/.config/ebk-notify/cache.json] --atom Write atom files - --outdir=DIR Write atom files to folder [Default: ~/.config/ebk-notify/feeds] + --outdir=DIR Write atom files to folder [Default: ~/.config/ebk-notify] """ diff --git a/ebknotify/feed.py b/ebknotify/feed.py index a09b79a..8d267a5 100644 --- a/ebknotify/feed.py +++ b/ebknotify/feed.py @@ -20,11 +20,16 @@ class Feed(FeedGenerator): fe.category({'term':item['category']['localized-name']['value']}) fe.link({'href':item['notify']['url'],'title':'Link to item'}) fe.pubDate(item['notify']['creation']) - fe.title(f"{item['title']['value']} ({available})") + fe.title(f"{item['title']['value']} {item['notify']['price']}€ ({available})") fe.content(f''' +
{item['description']['value']}
-- cgit v1.2.3