From 9eaf955bfc8bda2a2e114721347f9b2ccf06b055 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 10:35:42 -0700 Subject: Added local timeline support --- docs/index.rst | 1 + mastodon/Mastodon.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 39af190..90e8478 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -206,6 +206,7 @@ user could see, as well as hashtag timelines and the public timeline. .. automethod:: Mastodon.timeline .. automethod:: Mastodon.timeline_home .. automethod:: Mastodon.timeline_mentions +.. automethod:: Mastodon.timeline_local .. automethod:: Mastodon.timeline_public .. automethod:: Mastodon.timeline_hashtag diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 1d0e69f..641c415 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -162,14 +162,20 @@ class Mastodon: ## def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None): """ - Fetch statuses, most recent ones first. Timeline can be home, mentions, public - or tag/hashtag. See the following functions documentation for what those do. + Fetch statuses, most recent ones first. Timeline can be home, mentions, local, + public, or tag/hashtag. See the following functions documentation for what those do. The default timeline is the "home" timeline. Returns a list of toot dicts. """ - params = self.__generate_params(locals(), ['timeline']) + params_initial = locals() + + if timeline == "local": + timeline = "public" + params_initial['local'] = True + + params = self.__generate_params(params_initial, ['timeline']) return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) def timeline_home(self, max_id = None, since_id = None, limit = None): @@ -188,6 +194,14 @@ class Mastodon: """ return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit) + def timeline_local(self, max_id = None, since_id = None, limit = None): + """ + Fetches the local / instance-wide timeline. + + Returns a list of toot dicts. + """ + return self.timeline('local', max_id = max_id, since_id = since_id, limit = limit) + def timeline_public(self, max_id = None, since_id = None, limit = None): """ Fetches the public / visible-network timeline. -- cgit v1.2.3