Added support for local hashtag timelines

This commit is contained in:
Lorenz Diener 2017-11-21 14:46:43 +01:00
pare e1a1592575
commit 32f8b8bed9

Veure arxiu

@ -236,9 +236,10 @@ class Mastodon:
## ##
def timeline(self, timeline="home", max_id=None, since_id=None, limit=None): 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, Fetch statuses, most recent ones first. Timeline can be 'home', 'local', 'public',
or tag/hashtag. See the following functions documentation for what those do. 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. The default timeline is the "home" timeline.
Returns a list of toot dicts. Returns a list of toot dicts.
@ -280,14 +281,21 @@ class Mastodon:
return self.timeline('public', max_id=max_id, since_id=since_id, return self.timeline('public', max_id=max_id, since_id=since_id,
limit=limit) 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. Fetch a timeline of toots with a given hashtag.
Returns a list of toot dicts. Returns a list of toot dicts.
""" """
url = 'tag/{0}'.format(str(hashtag)) params_initial = locals()
return self.timeline(url, max_id=max_id, since_id=since_id, limit=limit)
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 # Reading data: Statuses