edsu / feediverse

Send RSS/Atom feeds to Mastodon
MIT License
116 stars 25 forks source link

toots with more than 500 characters fails #13

Closed steinarb closed 4 years ago

steinarb commented 4 years ago

I use the template "{title} {hashtags} {summary} {url}" and that failed with this error message for a long summary:

sb@cadalora:~$ /usr/local/bin/feediverse
/usr/local/lib/python3.7/dist-packages/feediverse.py:48: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(fh)
Traceback (most recent call last):
  File "/usr/local/bin/feediverse", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/dist-packages/feediverse.py", line 28, in main
    masto.status_post(feed['template'].format(**entry)[0:49999999999])
  File "<decorator-gen-60>", line 2, in status_post
  File "/usr/local/lib/python3.7/dist-packages/mastodon/Mastodon.py", line 102, in wrapper
    return function(self, *args, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mastodon/Mastodon.py", line 1776, in status_post
    return self.__api_request('POST', '/api/v1/statuses', params, headers = headers, use_json = use_json)
  File "/usr/local/lib/python3.7/dist-packages/mastodon/Mastodon.py", line 3429, in __api_request
    error_msg)
mastodon.Mastodon.MastodonAPIError: ('Mastodon API returned error', 422, 'Unprocessable Entity', 'Validation failed: Text character limit of 500 exceeded')
sb@cadalora:~$
steinarb commented 4 years ago

It looks like this was an attempt at fixing the 500 char limit, and that it went slightly wrong 37aedd9e56c5e29c9bcdf04f374f4a759bbc60b3

steinarb commented 4 years ago

(I also see that even with this fixed I have to put the url early because I don't want the url truncated)