diff options
author | Lorenz Diener <[email protected]> | 2017-12-13 21:16:02 +0100 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2017-12-13 21:16:02 +0100 |
commit | b840766ed77ea0cac84ada7cb27a9b23ffda0a09 (patch) | |
tree | b273102657ee5070a9101a1f943c2b9c3b54b807 /mastodon | |
parent | 7cf813b9744342d0be82330cf5fb81e85fea5642 (diff) | |
download | mastodon.py-b840766ed77ea0cac84ada7cb27a9b23ffda0a09.tar.gz |
Add more list endpoints
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 0df1217..44e0538 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -325,7 +325,7 @@ class Mastodon: | |||
325 | def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): | 325 | def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): |
326 | """ | 326 | """ |
327 | Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', | 327 | Fetch statuses, most recent ones first. `timeline` can be 'home', 'local', 'public', |
328 | or 'tag/hashtag'. See the following functions documentation for what those do. | 328 | 'tag/hashtag' or 'list/id'. See the following functions documentation for what those do. |
329 | Local hashtag timelines are supported via the `timeline_hashtag()`_ function. | 329 | Local hashtag timelines are supported via the `timeline_hashtag()`_ function. |
330 | 330 | ||
331 | The default timeline is the "home" timeline. | 331 | The default timeline is the "home" timeline. |
@@ -407,6 +407,17 @@ class Mastodon: | |||
407 | 407 | ||
408 | return self.__api_request('GET', url, params) | 408 | return self.__api_request('GET', url, params) |
409 | 409 | ||
410 | @api_version("2.1.0") | ||
411 | def timeline_list(self, id, max_id=None, since_id=None, limit=None): | ||
412 | """ | ||
413 | Fetches a timeline containing all the toots by users in a given list. | ||
414 | |||
415 | Returns a list of `toot dicts`_. | ||
416 | """ | ||
417 | id = self.__unpack_id(id) | ||
418 | return self.timeline('list/{0}'.format(id), max_id=max_id, | ||
419 | since_id=since_id, limit=limit) | ||
420 | |||
410 | ### | 421 | ### |
411 | # Reading data: Statuses | 422 | # Reading data: Statuses |
412 | ### | 423 | ### |
@@ -613,8 +624,6 @@ class Mastodon: | |||
613 | Get all of the logged in users lists which the specified user is | 624 | Get all of the logged in users lists which the specified user is |
614 | a member of. | 625 | a member of. |
615 | 626 | ||
616 | TODO: This doesn't work. | ||
617 | |||
618 | Returns a list of `list dicts`_. | 627 | Returns a list of `list dicts`_. |
619 | """ | 628 | """ |
620 | params = self.__generate_params(locals(), ['id']) | 629 | params = self.__generate_params(locals(), ['id']) |
@@ -647,6 +656,16 @@ class Mastodon: | |||
647 | """ | 656 | """ |
648 | return self.__api_request('GET', '/api/v1/lists') | 657 | return self.__api_request('GET', '/api/v1/lists') |
649 | 658 | ||
659 | @api_version("2.1.0") | ||
660 | def list(self, id): | ||
661 | """ | ||
662 | Fetch info about a specific list. | ||
663 | |||
664 | Returns a `list dict`_. | ||
665 | """ | ||
666 | id = self.__unpack_id(id) | ||
667 | return self.__api_request('GET', '/api/v1/lists/{0}'.format(id)) | ||
668 | |||
650 | ### | 669 | ### |
651 | # Reading data: Mutes and Blocks | 670 | # Reading data: Mutes and Blocks |
652 | ### | 671 | ### |
@@ -1036,6 +1055,38 @@ class Mastodon: | |||
1036 | return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params) | 1055 | return self.__api_request('PATCH', '/api/v1/accounts/update_credentials', params) |
1037 | 1056 | ||
1038 | ### | 1057 | ### |
1058 | # Writing data: Lists | ||
1059 | ### | ||
1060 | @api_version("2.1.0") | ||
1061 | def list_create(self, title): | ||
1062 | """ | ||
1063 | Create a new list with the given `title`. | ||
1064 | |||
1065 | Returns the `list dict`_ of the created list. | ||
1066 | """ | ||
1067 | params = self.__generate_params(locals()) | ||
1068 | return self.__api_request('POST', '/api/v1/lists', params) | ||
1069 | |||
1070 | @api_version("2.1.0") | ||
1071 | def list_update(self, id, title): | ||
1072 | """ | ||
1073 | Update info about a list, where "info" is really the lists `title`. | ||
1074 | |||
1075 | Returns the `list dict`_ of the modified list. | ||
1076 | """ | ||
1077 | id = self.__unpack_id(id) | ||
1078 | params = self.__generate_params(locals(), ['id']) | ||
1079 | return self.__api_request('PUT', '/api/v1/lists/{0}'.format(id), params) | ||
1080 | |||
1081 | @api_version("2.1.0") | ||
1082 | def list_delete(self, id): | ||
1083 | """ | ||
1084 | Delete a list. | ||
1085 | """ | ||
1086 | id = self.__unpack_id(id) | ||
1087 | self.__api_request('DELETE', '/api/v1/lists/{0}'.format(id)) | ||
1088 | |||
1089 | ### | ||
1039 | # Writing data: Reports | 1090 | # Writing data: Reports |
1040 | ### | 1091 | ### |
1041 | @api_version("1.1.0") | 1092 | @api_version("1.1.0") |