diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 105bf77..8c60d6b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -14,6 +14,9 @@ v1.8.1 (in progress) * Fix `list_accounts` to actually include request parameters (thanks leoncowle) * Small formatting changes (thanks amaargiru) * Add link to examples to docs and readme. +* Add `local` and `remote` parameter to `stream_public` (thank you for the report jeafreezy) +* Fix `limit` and `lang` parameters on trend related functions not present or working (thanks for the report pdeitel) +* Fix some issues with stream reconnect handling (thanks for the report ianh) v1.8.0 ------ diff --git a/mastodon/streaming.py b/mastodon/streaming.py index 05b23c2..e3ce8c3 100644 --- a/mastodon/streaming.py +++ b/mastodon/streaming.py @@ -12,7 +12,7 @@ except: from mastodon import Mastodon from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout -from requests.exceptions import ChunkedEncodingError, ReadTimeout +from requests.exceptions import ChunkedEncodingError, ReadTimeout, ConnectionError class StreamListener(object): @@ -136,7 +136,7 @@ class StreamListener(object): exception, err ) - except MastodonReadTimeout as err: + except ReadTimeout as err: exception = MastodonReadTimeout( "Timed out while reading from server."), self.on_abort(exception) @@ -144,6 +144,14 @@ class StreamListener(object): exception, err ) + except ConnectionError as err: + exception = MastodonNetworkError( + "Requests reports connection error."), + self.on_abort(exception) + six.raise_from( + exception, + err + ) def _parse_line(self, line, event): if line.startswith(':'): diff --git a/mastodon/trends.py b/mastodon/trends.py index 03d3ea0..67f5c6e 100644 --- a/mastodon/trends.py +++ b/mastodon/trends.py @@ -13,7 +13,9 @@ class Mastodon(Internals): @api_version("2.4.3", "3.5.0", _DICT_VERSION_HASHTAG) def trends(self, limit=None): """ - Alias for :ref:`trending_tags() ` + Old alias for :ref:`trending_tags() ` + + Deprecated. Please use :ref:`trending_tags() ` instead. """ return self.trending_tags(limit=limit) @@ -36,14 +38,16 @@ class Mastodon(Internals): descending. """ params = self.__generate_params(locals()) + if "lang" in params: + del params["lang"] if self.verify_minimum_version("3.5.0", cached=True): # Starting 3.5.0, old version is deprecated - return self.__api_request('GET', '/api/v1/trends/tags', params) + return self.__api_request('GET', '/api/v1/trends/tags', params, lang_override=lang) else: - return self.__api_request('GET', '/api/v1/trends', params) + return self.__api_request('GET', '/api/v1/trends', params, lang_override=lang) @api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS) - def trending_statuses(self): + def trending_statuses(self, limit=None, lang=None): """ Fetch trending-status information, if the instance provides such information. @@ -56,10 +60,12 @@ class Mastodon(Internals): descending. """ params = self.__generate_params(locals()) - return self.__api_request('GET', '/api/v1/trends/statuses', params) + if "lang" in params: + del params["lang"] + return self.__api_request('GET', '/api/v1/trends/statuses', params, lang_override=lang) @api_version("3.5.0", "3.5.0", _DICT_VERSION_CARD) - def trending_links(self): + def trending_links(self, limit=None, lang=None): """ Fetch trending-link information, if the instance provides such information. @@ -70,4 +76,6 @@ class Mastodon(Internals): descending. """ params = self.__generate_params(locals()) - return self.__api_request('GET', '/api/v1/trends/links', params) + if "lang" in params: + del params["lang"] + return self.__api_request('GET', '/api/v1/trends/links', params, lang_override=lang)