|
@@ -1,3 +1,4 @@
|
|
1
|
+#! /usr/bin/python3
|
1
|
2
|
import curses
|
2
|
3
|
from html.parser import HTMLParser
|
3
|
4
|
from mastodon import Mastodon
|
|
@@ -6,7 +7,8 @@ def initColours():
|
6
|
7
|
# 0: White on black
|
7
|
8
|
curses.init_pair(1, 4, 0) # 1: Blue on black
|
8
|
9
|
curses.init_pair(2, 1, 0) # 2: Red on black
|
9
|
|
- curses.init_pair(3, 6, 0) # 2: Cyan on black
|
|
10
|
+ curses.init_pair(3, 6, 0) # 3: Cyan on black
|
|
11
|
+ curses.init_pair(4, 2, 0) # 4: Green on black
|
10
|
12
|
|
11
|
13
|
def newLine(ncwin, lines=1):
|
12
|
14
|
cy, cx = ncwin.getyx()
|
|
@@ -56,12 +58,13 @@ def typeset(text, win, attr, colour):
|
56
|
58
|
|
57
|
59
|
def printPost(win, post, parser):
|
58
|
60
|
# win.addstr(post["account"]["acct"], curses.A_BOLD)
|
59
|
|
- typeset(post["account"]["acct"], win, curses.A_BOLD, 0)
|
|
61
|
+ typeset("@{}".format(post["account"]["acct"]), win, curses.A_BOLD, 0)
|
60
|
62
|
if (post["reblog"] is not None):
|
61
|
63
|
# win.addstr(" boosted ")
|
62
|
64
|
typeset(" boosted ", win, 0, 0)
|
63
|
65
|
# win.addstr(post["reblog"]["account"]["acct"], curses.A_BOLD)
|
64
|
|
- typeset(post["reblog"]["account"]["acct"], win, curses.A_BOLD, 0)
|
|
66
|
+ typeset("@{}".format(post["reblog"]["account"]["acct"]), win,
|
|
67
|
+ curses.A_BOLD, 0)
|
65
|
68
|
# win.addstr(":")
|
66
|
69
|
typeset(":", win, 0, 0)
|
67
|
70
|
newLine(win)
|
|
@@ -73,6 +76,23 @@ def printPost(win, post, parser):
|
73
|
76
|
if parser.openp:
|
74
|
77
|
newLine(win)
|
75
|
78
|
|
|
79
|
+ for att in post["media_attachments"]:
|
|
80
|
+ # typeset("[IMG: {}, <{}>]".format(att["alt"], att["src"]))
|
|
81
|
+ typeset("[IMG: {}]".format(att["description"] if
|
|
82
|
+ att["description"] is not None
|
|
83
|
+ else "(Alt text missing)"),
|
|
84
|
+ win, 0, 4)
|
|
85
|
+ newLine(win)
|
|
86
|
+
|
|
87
|
+ if (post["reblog"] is not None):
|
|
88
|
+ for att in post["reblog"]["media_attachments"]:
|
|
89
|
+ # typeset("[IMG: {}, <{}>]".format(att["alt"], att["src"]))
|
|
90
|
+ typeset("[IMG: {}]".format(att["description"] if
|
|
91
|
+ att["description"] is not None
|
|
92
|
+ else "(Alt text missing)"),
|
|
93
|
+ win, 0, 4)
|
|
94
|
+ newLine(win)
|
|
95
|
+
|
76
|
96
|
botstring = "{} @ {} UTC".format(post["visibility"],
|
77
|
97
|
post["created_at"
|
78
|
98
|
].strftime(
|
|
@@ -94,7 +114,9 @@ def printAtLevel(stdscr, col1, col2, posts, parser, level):
|
94
|
114
|
newLine(col1)
|
95
|
115
|
printPost(col1, posts[(level + 1) % len(posts)], parser)
|
96
|
116
|
try:
|
97
|
|
- col2.addstr(str(posts[level]))
|
|
117
|
+ col2.addstr(str(posts[level]["content"]))
|
|
118
|
+ col2.addstr(str(posts[level]["media_attachments"]))
|
|
119
|
+ col2.addstr(str(posts[level].keys()))
|
98
|
120
|
except curses.error:
|
99
|
121
|
pass
|
100
|
122
|
stdscr.noutrefresh()
|
|
@@ -130,6 +152,10 @@ class PostParser(HTMLParser):
|
130
|
152
|
elif tag == 'code':
|
131
|
153
|
self.colstack.append(self.colour)
|
132
|
154
|
self.colour = 3
|
|
155
|
+ elif tag == 'img':
|
|
156
|
+ typeset("[IMG: {}, <{}>]".format(att["alt"], att["src"]), self.win,
|
|
157
|
+ 0, 4)
|
|
158
|
+
|
133
|
159
|
|
134
|
160
|
def handle_endtag(self, tag):
|
135
|
161
|
if tag == 'p':
|