From fae35e819f5e08004023cac0be6b954b7b95c2ba Mon Sep 17 00:00:00 2001 From: Chuck Sneed Date: Fri, 22 Jul 2022 19:50:12 -0500 Subject: [PATCH] Dr. Transmisia's changes --- RDramaAPIInterface.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/RDramaAPIInterface.py b/RDramaAPIInterface.py index cd2ce09..750fec7 100644 --- a/RDramaAPIInterface.py +++ b/RDramaAPIInterface.py @@ -45,24 +45,27 @@ class RDramaAPIInterface: ''' Gets "all" comments. ''' - def get_comments(self, number_of_pages=1, user=None): + def get_comments(self, number_of_pages=1, user=None, sort="new", upper_bound = 0, lower_bound = 0): if (user == None): url=f"{self.protocol}://{self.site}/comments" else: url=f"{self.protocol}://{self.site}/@{user}/comments" + + params = f"?sort={sort}&t=all&before={upper_bound}&after={lower_bound}" + url+=params + if number_of_pages == 1: return self.get(url) else: results = [] for i_ in range(number_of_pages): i = i_ + 1 - full_url=f"{url}?page={i}&sort=new&t=all" + full_url = f"{url}&page={i}" results += self.get(full_url)['data'] return { 'data': results } - ''' Calls the notifications endpoint ''' @@ -85,6 +88,10 @@ class RDramaAPIInterface: url=f"{self.protocol}://{self.site}" return self.get(url) + def get_hole(self, hole: str): + url = f"{self.protocol}://{self.site}/h/{hole}" + return self.get(url) + def has_url_been_posted(self, the_url): url=f"{self.protocol}://{self.site}/is_repost" return self.post(url, {'url': the_url})['permalink'] != ''