From b9aeb0e8debff89c830a18a69a4169dbe997b3fc Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Mon, 28 Aug 2023 21:57:47 +0200 Subject: [PATCH] fix up output, show 15 stories --- hn.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hn.py b/hn.py index 80b0e3d..fd3cfda 100644 --- a/hn.py +++ b/hn.py @@ -22,7 +22,7 @@ def main(stdscr): r = requests.get(url) if not r.ok: raise Exception('Error fetching data from Hacker News API') - ids = r.json()[:10] # Show only the first ten stories + ids = r.json()[:15] # Show only the first ten stories stories = [] for i in ids: story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json' @@ -39,8 +39,11 @@ def main(stdscr): stdscr.addstr('\n\nHacker News Top Stories:\n') for i, story in enumerate(stories): prefix = '>>> ' if i == current_pos else ' ' - text = f'{prefix}{i+1}: {story.title} ({story.link})\n' + text = f'{prefix}{story.title} ({story.link})\n' stdscr.addstr(text) + if i == current_pos: + detail = f' by {story.author} | {story.votes} points\n' + stdscr.addstr(detail) stdscr.refresh() c = stdscr.getch()