Browse Source

It prints, and that's something

Petra Lamborn 4 years ago
parent
commit
4246839318
1 changed files with 11 additions and 5 deletions
  1. 11
    5
      fedicurses.py

+ 11
- 5
fedicurses.py View File

@@ -5,7 +5,7 @@ from mastodon import Mastodon
5 5
 class PostParser(HTMLParser):
6 6
     def __init__(self, ncwin, defncatt):
7 7
         HTMLParser.__init__(self)
8
-        self.win = ncwin,
8
+        self.win = ncwin
9 9
         self.defncatt = defncatt
10 10
         self.curatt = defncatt
11 11
 
@@ -15,7 +15,7 @@ class PostParser(HTMLParser):
15 15
         elif tag == 'strong':
16 16
             self.curatt = self.curatt ^ curses.A_BOLD
17 17
 
18
-    def handle_endtag(self, tag, attrs):
18
+    def handle_endtag(self, tag):
19 19
         if tag == 'p':
20 20
             cy, cx = self.win.getyx()
21 21
             self.win.move(cy + 2, 0)
@@ -37,10 +37,16 @@ def main(stdscr):
37 37
     posts = mastodon.timeline()
38 38
     parser = PostParser(stdscr, 0)
39 39
     stdscr.clear()
40
-    stdscr.addstr("test")
41
-    stdscr.refresh()
40
+    # stdscr.addstr("test")
42 41
     curses.halfdelay(10)
43
-    # parser.feed(posts[0]["content"])
42
+    try:
43
+        for post in posts:
44
+            stdscr.addstr(post["account"]["acct"])
45
+            stdscr.addstr(": ")
46
+            parser.feed(post["content"])
47
+    except:
48
+        pass
49
+    stdscr.refresh()
44 50
     i = 'c'
45 51
     q = 0
46 52
     con = True