show a number of stories that fit the terminal window

master
Felix Pankratz 1 year ago
parent 67136668f4
commit ed2e395e5f

@ -26,13 +26,13 @@ def main(stdscr):
stdscr.clear() stdscr.clear()
height, width = stdscr.getmaxyx() 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 # Query Hacker News API for top stories and their titles/links
url = 'https://hacker-news.firebaseio.com/v0/topstories.json' url = 'https://hacker-news.firebaseio.com/v0/topstories.json'
r = requests.get(url) r = requests.get(url)
if not r.ok: if not r.ok:
raise Exception('Error fetching data from Hacker News API') raise Exception('Error fetching data from Hacker News API')
ids = r.json()[:10] ids = r.json()[:num_stories]
stories = [] stories = []
for idx, i in enumerate(ids): for idx, i in enumerate(ids):
stdscr.clear() stdscr.clear()

Loading…
Cancel
Save