|
@@ -3,20 +3,44 @@ from html.parser import HTMLParser
|
3
|
3
|
from mastodon import Mastodon
|
4
|
4
|
|
5
|
5
|
class PostParser(HTMLParser):
|
|
6
|
+ def __init__(self, ncwin, defncatt):
|
|
7
|
+ HTMLParser.__init__(self)
|
|
8
|
+ self.win = ncwin,
|
|
9
|
+ self.defncatt = defncatt
|
|
10
|
+ self.curatt = defncatt
|
|
11
|
+
|
6
|
12
|
def handle_starttag(self, tag, attrs):
|
7
|
|
- print(tag)
|
|
13
|
+ if tag == 'p':
|
|
14
|
+ self.curatt = self.defncatt
|
|
15
|
+ elif tag == 'strong':
|
|
16
|
+ self.curatt = self.curatt ^ curses.A_BOLD
|
|
17
|
+
|
|
18
|
+ def handle_endtag(self, tag, attrs):
|
|
19
|
+ if tag == 'p':
|
|
20
|
+ cy, cx = self.win.getyx()
|
|
21
|
+ self.win.move(cy + 2, 0)
|
|
22
|
+ elif tag == 'strong':
|
|
23
|
+ self.curatt = self.curatt ^ curses.A_BOLD
|
|
24
|
+
|
|
25
|
+ def handle_data(self, data):
|
|
26
|
+ self.win.addstr(data, self.curatt)
|
8
|
27
|
|
9
|
|
-mastodon = Mastodon(
|
10
|
|
- access_token = 'd100.club_usercred.secret',
|
11
|
|
- api_base_url = 'd100.club'
|
12
|
|
-)
|
13
|
28
|
|
14
|
|
-print(mastodon.timeline()[0]["content"])
|
|
29
|
+# print(mastodon.timeline()[0]["content"])
|
15
|
30
|
|
16
|
31
|
|
17
|
32
|
def main(stdscr):
|
|
33
|
+ mastodon = Mastodon(
|
|
34
|
+ access_token = 'd100.club_usercred.secret',
|
|
35
|
+ api_base_url = 'd100.club'
|
|
36
|
+ )
|
|
37
|
+ posts = mastodon.timeline()
|
|
38
|
+ parser = PostParser(stdscr, 0)
|
18
|
39
|
stdscr.clear()
|
|
40
|
+ stdscr.addstr("test")
|
|
41
|
+ stdscr.refresh()
|
19
|
42
|
curses.halfdelay(10)
|
|
43
|
+ # parser.feed(posts[0]["content"])
|
20
|
44
|
i = 'c'
|
21
|
45
|
q = 0
|
22
|
46
|
con = True
|
|
@@ -24,4 +48,4 @@ def main(stdscr):
|
24
|
48
|
i = stdscr.getch()
|
25
|
49
|
con = (i != ord('q'))
|
26
|
50
|
|
27
|
|
-#curses.wrapper(main)
|
|
51
|
+curses.wrapper(main)
|