From 32f8b8bed9226f8069883d85e9d38d69f6a67910 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Tue, 21 Nov 2017 14:46:43 +0100 Subject: Added support for local hashtag timelines --- mastodon/Mastodon.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 49d7e9b..0431068 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -236,9 +236,10 @@ 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, local, public, - or tag/hashtag. See the following functions documentation for what those do. - + Fetch statuses, most recent ones first. Timeline can be 'home', 'local', 'public', + or 'tag/hashtag'. See the following functions documentation for what those do. + Local hashtag timelines are supported via the timeline_hashtag() function. + The default timeline is the "home" timeline. Returns a list of toot dicts. @@ -280,14 +281,21 @@ class Mastodon: return self.timeline('public', max_id=max_id, since_id=since_id, limit=limit) - def timeline_hashtag(self, hashtag, max_id=None, since_id=None, limit=None): + def timeline_hashtag(self, hashtag, local=False, max_id=None, since_id=None, limit=None): """ Fetch a timeline of toots with a given hashtag. Returns a list of toot dicts. """ - url = 'tag/{0}'.format(str(hashtag)) - return self.timeline(url, max_id=max_id, since_id=since_id, limit=limit) + params_initial = locals() + + if local == False: + del params_initial['local'] + + url = '/api/v1/timelines/tag/{0}'.format(hashtag) + params = self.__generate_params(params_initial, ['hashtag']) + + return self.__api_request('GET', url, params) ### # Reading data: Statuses -- cgit v1.2.3