diff --git a/hn.py b/hn.py index 10c5eae..c75eb6c 100755 --- a/hn.py +++ b/hn.py @@ -32,15 +32,15 @@ def main(stdscr): height, width = stdscr.getmaxyx() num_stories = curses.LINES - 3 # headline, detail, footer # Query Hacker News API for top stories and their titles/links + # returns the top 500 stories, so quite enough. 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()[:num_stories] + ids = r.json() stories = [] - for idx, i in enumerate(ids): + for idx, i in enumerate(ids[:num_stories]): stdscr.clear() - #stdscr.addstr(f'[{spinner_states[idx%4]}] Getting stories...') footer(stdscr, f'[{spinner_states[idx%4]}] Getting stories...') stdscr.refresh() story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json'