kopia lustrzana https://github.com/halcy/Mastodon.py
Fix some streaming related issues
rodzic
345e8c35c0
commit
6f7d4576c0
|
@ -14,6 +14,9 @@ v1.8.1 (in progress)
|
||||||
* Fix `list_accounts` to actually include request parameters (thanks leoncowle)
|
* Fix `list_accounts` to actually include request parameters (thanks leoncowle)
|
||||||
* Small formatting changes (thanks amaargiru)
|
* Small formatting changes (thanks amaargiru)
|
||||||
* Add link to examples to docs and readme.
|
* 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
|
v1.8.0
|
||||||
------
|
------
|
||||||
|
|
|
@ -12,7 +12,7 @@ except:
|
||||||
|
|
||||||
from mastodon import Mastodon
|
from mastodon import Mastodon
|
||||||
from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout
|
from mastodon.Mastodon import MastodonMalformedEventError, MastodonNetworkError, MastodonReadTimeout
|
||||||
from requests.exceptions import ChunkedEncodingError, ReadTimeout
|
from requests.exceptions import ChunkedEncodingError, ReadTimeout, ConnectionError
|
||||||
|
|
||||||
|
|
||||||
class StreamListener(object):
|
class StreamListener(object):
|
||||||
|
@ -136,7 +136,7 @@ class StreamListener(object):
|
||||||
exception,
|
exception,
|
||||||
err
|
err
|
||||||
)
|
)
|
||||||
except MastodonReadTimeout as err:
|
except ReadTimeout as err:
|
||||||
exception = MastodonReadTimeout(
|
exception = MastodonReadTimeout(
|
||||||
"Timed out while reading from server."),
|
"Timed out while reading from server."),
|
||||||
self.on_abort(exception)
|
self.on_abort(exception)
|
||||||
|
@ -144,6 +144,14 @@ class StreamListener(object):
|
||||||
exception,
|
exception,
|
||||||
err
|
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):
|
def _parse_line(self, line, event):
|
||||||
if line.startswith(':'):
|
if line.startswith(':'):
|
||||||
|
|
|
@ -13,7 +13,9 @@ class Mastodon(Internals):
|
||||||
@api_version("2.4.3", "3.5.0", _DICT_VERSION_HASHTAG)
|
@api_version("2.4.3", "3.5.0", _DICT_VERSION_HASHTAG)
|
||||||
def trends(self, limit=None):
|
def trends(self, limit=None):
|
||||||
"""
|
"""
|
||||||
Alias for :ref:`trending_tags() <trending_tags()>`
|
Old alias for :ref:`trending_tags() <trending_tags()>`
|
||||||
|
|
||||||
|
Deprecated. Please use :ref:`trending_tags() <trending_tags()>` instead.
|
||||||
"""
|
"""
|
||||||
return self.trending_tags(limit=limit)
|
return self.trending_tags(limit=limit)
|
||||||
|
|
||||||
|
@ -36,14 +38,16 @@ class Mastodon(Internals):
|
||||||
descending.
|
descending.
|
||||||
"""
|
"""
|
||||||
params = self.__generate_params(locals())
|
params = self.__generate_params(locals())
|
||||||
|
if "lang" in params:
|
||||||
|
del params["lang"]
|
||||||
if self.verify_minimum_version("3.5.0", cached=True):
|
if self.verify_minimum_version("3.5.0", cached=True):
|
||||||
# Starting 3.5.0, old version is deprecated
|
# 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:
|
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)
|
@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.
|
Fetch trending-status information, if the instance provides such information.
|
||||||
|
|
||||||
|
@ -56,10 +60,12 @@ class Mastodon(Internals):
|
||||||
descending.
|
descending.
|
||||||
"""
|
"""
|
||||||
params = self.__generate_params(locals())
|
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)
|
@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.
|
Fetch trending-link information, if the instance provides such information.
|
||||||
|
|
||||||
|
@ -70,4 +76,6 @@ class Mastodon(Internals):
|
||||||
descending.
|
descending.
|
||||||
"""
|
"""
|
||||||
params = self.__generate_params(locals())
|
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)
|
||||||
|
|
Ładowanie…
Reference in New Issue