fixes
This commit is contained in:
parent
1a5ac7bb5a
commit
d43389b20a
6
hn.py
6
hn.py
@ -32,15 +32,15 @@ def main(stdscr):
|
|||||||
height, width = stdscr.getmaxyx()
|
height, width = stdscr.getmaxyx()
|
||||||
num_stories = curses.LINES - 3 # headline, detail, footer
|
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
|
||||||
|
# returns the top 500 stories, so quite enough.
|
||||||
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()[:num_stories]
|
ids = r.json()
|
||||||
stories = []
|
stories = []
|
||||||
for idx, i in enumerate(ids):
|
for idx, i in enumerate(ids[:num_stories]):
|
||||||
stdscr.clear()
|
stdscr.clear()
|
||||||
#stdscr.addstr(f'[{spinner_states[idx%4]}] Getting stories...')
|
|
||||||
footer(stdscr, f'[{spinner_states[idx%4]}] Getting stories...')
|
footer(stdscr, f'[{spinner_states[idx%4]}] Getting stories...')
|
||||||
stdscr.refresh()
|
stdscr.refresh()
|
||||||
story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json'
|
story_url = f'https://hacker-news.firebaseio.com/v0/item/{i}.json'
|
||||||
|
Loading…
Reference in New Issue
Block a user