bareddit will no longer be maintained by me (metalune) because gophereddit exists https://bareddit.metalune.xyz
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 

48 lines
1.6 KiB

# --------------------------------------------------------------- Imports ---------------------------------------------------------------- #
# System
from typing import Dict
# Pip
from jsoncodable import JSONCodable
# Local
from .common_utils import clean_text
# ---------------------------------------------------------------------------------------------------------------------------------------- #
# ------------------------------------------------------------ class: Comment ------------------------------------------------------------ #
class Comment(JSONCodable):
# ------------------------------------------------------------- Init ------------------------------------------------------------- #
def __init__(
self,
json: Dict
):
self.id = json['id']
self.author = json['author']
self.ts = json['created_utc']
self.score = json['score']
self.content = clean_text(json['body'])
self.stickied = json['stickied']
self.distinguished = json['distinguished']
self.depth = json['depth']
self.sub = json['subreddit']
self.comments = []
try:
for child in json['replies']['data']['children']:
try:
self.comments.append(Comment(child['data']))
except:
pass
except:
pass
# ---------------------------------------------------------------------------------------------------------------------------------------- #