Initial commit

This commit is contained in:
2020-12-23 19:30:31 -05:00
commit eb40a9de68
9 changed files with 397 additions and 0 deletions

22
post_process.py Normal file
View File

@@ -0,0 +1,22 @@
from hexlib.regex import LINK_RE
def post_process(item, board, helper):
item["_v"] = 1.0
item["_id"] = helper.item_unique_id(item)
if helper.item_type(item) != "user":
item["_urls"] = helper.item_urls(item)
if helper.item_type(item) == "comment":
item["_sub"] = board
return item
def get_links_from_body(body):
result = []
for match in LINK_RE.finditer(body):
url = match.group(1)
result.append(url)
return result