From ed2e395e5fc8a1e180ca554143a8c841720ef637 Mon Sep 17 00:00:00 2001 From: Felix Pankratz Date: Tue, 29 Aug 2023 14:37:02 +0200 Subject: [PATCH] show a number of stories that fit the terminal window --- hn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hn.py b/hn.py index 017dba1..8c5c6ae 100755 --- a/hn.py +++ b/hn.py @@ -26,13 +26,13 @@ def main(stdscr): stdscr.clear() height, width = stdscr.getmaxyx() - num_stories = curses.LINES - 2 # headline and detail + num_stories = curses.LINES - 3 # headline, detail, footer # Query Hacker News API for top stories and their titles/links url = 'https://hacker-news.firebaseio.com/v0/topstories.json' r = requests.get(url) if not r.ok: raise Exception('Error fetching data from Hacker News API') - ids = r.json()[:10] + ids = r.json()[:num_stories] stories = [] for idx, i in enumerate(ids): stdscr.clear()