def dump_recursive_comments(rpc,
post_author,
post_permlink,
depth=0,
format="markdown"):
global currentThreadDepth
postWrapper = TextWrapper()
postWrapper.width = 120
postWrapper.initial_indent = " " * (depth + currentThreadDepth)
postWrapper.subsequent_indent = " " * (depth + currentThreadDepth)
depth = int(depth)
posts = rpc.get_content_replies(post_author, post_permlink)
for post in posts:
meta = {}
for key in ["author", "permlink"]:
meta[key] = post[key]
meta["reply"] = "@{author}/{permlink}".format(**post)
if format == "markdown":
body = markdownify(post["body"])
else:
body = post["body"]
yaml = frontmatter.Post(body, **meta)
print(frontmatter.dumps(yaml))
reply = rpc.get_content_replies(post["author"], post["permlink"])
if len(reply):
dump_recursive_comments(rpc, post["author"], post["permlink"], depth + 1)
评论列表
文章目录