|
|
@ -22,7 +22,7 @@ def main(stdscr):
|
|
|
|
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] # Show only the first ten stories
|
|
|
|
ids = r.json()[:15] # Show only the first ten stories
|
|
|
|
stories = []
|
|
|
|
stories = []
|
|
|
|
for i in ids:
|
|
|
|
for i in ids:
|
|
|
|
story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json'
|
|
|
|
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')
|
|
|
|
stdscr.addstr('\n\nHacker News Top Stories:\n')
|
|
|
|
for i, story in enumerate(stories):
|
|
|
|
for i, story in enumerate(stories):
|
|
|
|
prefix = '>>> ' if i == current_pos else ' '
|
|
|
|
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)
|
|
|
|
stdscr.addstr(text)
|
|
|
|
|
|
|
|
if i == current_pos:
|
|
|
|
|
|
|
|
detail = f' by {story.author} | {story.votes} points\n'
|
|
|
|
|
|
|
|
stdscr.addstr(detail)
|
|
|
|
|
|
|
|
|
|
|
|
stdscr.refresh()
|
|
|
|
stdscr.refresh()
|
|
|
|
c = stdscr.getch()
|
|
|
|
c = stdscr.getch()
|
|
|
|