Skip to content

Commit

Permalink
Fixed a bug and added list_posts
Browse files Browse the repository at this point in the history
  • Loading branch information
Pdzly committed Dec 18, 2023
1 parent ce36cc9 commit 0f8f074
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions lemmylib/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,32 @@ def list_comments(self, page: int = 1, post_id: int | None = None, sort: LemmyPo

return self.call_api(LemmyApiMethod.GET, f'comments', params={'page': page, 'post_id': post_id, 'sort': sort,
'type_': listing_type,
'parent_id': parent_id,
'community_id': community_id,
'community_name': community_name,
'user_id': user_id,
'user_name': user_name,
'saved_only': saved_only})

def list_posts(self, page_cursor: int | None = None, sort: LemmyPostSort = None,
listing_type: LemmyListingType = None,
community_id: int | None = None, community_name: str | None = None, user_id: int | None = None,
liked_only: bool = False, disliked_only: bool = False,
user_name: str | None = None, saved_only: bool = False):
self._logger.debug("LemmyLib list_posts")

if community_id is None and community_name is None and user_id is None and user_name is None:
raise Exception("LemmyLib: Either community_id, community_name, user_id or user_name must be set")

return self.call_api(LemmyApiMethod.GET, f'posts',
params={'page_cursor': page_cursor, 'sort': sort, 'type_': listing_type,
'community_id': community_id,
'community_name': community_name,
'user_id': user_id,
'liked_only': liked_only,
'disliked_only': disliked_only,
'user_name': user_name,
'saved_only': saved_only})

def get_person(self, person_id: int | None = None, username: str | None = None):
self._logger.debug("LemmyLib get_person")
Expand Down

0 comments on commit 0f8f074

Please sign in to comment.