Posting automatically from a RSS feed


#1

Is there a recommended option to post automatically from a RSS feed?

I have found this: GitHub - poga/rss2mastodon: publish a rss feed to mastodon. Has anyone tested it? Are there other ways?


#2

Could be done pretty trivially with Halcy’s Mastodon.py, that’s what I’d use

or there are bot templates here -> Glitch - The Friendly, Creative Community


#3

I use Zapier.
Use RSS as tritter and use Webhook as action.
Add Authorization header with value Bearer ~~~~


#4

Thank you for your ideas!

About Halcy’s Mastodon.py, I am not a programmer and I’d rather use a bot that already exists.

Zapier is a good idea, and I hadn’t thought about it. However, due to the characteristics of our project, we would prefer to avoid a commercial service and go for free software / self-hosted instead.

I have found another bot… Carl Chenet / feed2toot · GitLab


#5

I’m the author of Feed2toot, which is a Free Software, widely used and fully documented. Let me know if you have questions installing/using it.


#6

I wrote a program called feed2exec that can call into random programs based on new items in a RSS feed. I use it in combination with the toot client to send posts into Mastodon, and it works pretty well. An example of how to setup the config is this:

feed2exec add "My site" http://example.com/blog/feed --output exec --args 'toot post "{item.title} {item.link}"'

Toot needs to be configured first, with something like:

toot login

or:

toot login_browser

if you use 2FA in your account.

Hope that helps!


#7

@chaica @anarcat thank you for your quick replies.

I am playing with each of your approaches. I have the same questions for both:

  • Does your tool work in the background once it is executed, or do I need to setup a cron task to trigger it periodically?

  • Is it possible to update multiple accounts with their own feeds? The documentation mentions one pair account-feed, but it is possible to maintain multiple pairs account-feed?


#8

It needs a cron job.

feed2exec is pretty dumb: it does whatever toot does. I haven’t looked, but if there’s a way that toot can update multiple feeds, so can feed2exec, even if it might mean crawling the same feed multiple times to call multiple commands. That’s how I send tweets and toots at the same time for my feeds, although it might be possible to use a wrapper script instead, naturally.


#9

Alright, at the end I went for @chaica’s Feed2toot. I tried the Feed2exec + toot as well, which I believe can be more flexible and powerful, but being my use case quite straightforward I went for what worked out of the box.

First result: ContratiempoHistoria (@contratiempohis@confederac.io) - Red Confederada

Answering my own questions, the Feed2tood documentation explains how to set up a cron task. Although the documentation doesn’t mention explicitly how to run multiple feeds for multiple accounts, I believe it is just a matter of identifying multiple accounts and then have separate .ini & related files for each of them. haven’t tried yet, but I will report here when I do.

Thank you for all your feedback and help!


#10

@icaria36 Yes you’re right, multiple feeds for multiple accounts will require the option uri_list to define your multiple feeds and each account requires a different *.ini file. I’ll update the documentation with this case.


#11

Is it possible to run feed2toot on https://www.pythonanywhere.com/?

When I get to this setup step I get an encoding error, even though I see an encoding defined in the file in question:

01:00 ~ $ register_feed2toot_app                                                                                                                                             
File "/home/username/.local/bin/register_feed2toot_app", line 4
SyntaxError: Non-ASCII character '\xc2' in file/home/username/.local/bin/register_feed2toot_app on line 4, but no encoding declared; see http://python.org/dev/peps/pep-02 63/ for details

#12

I’m getting further. I used a python virtualenv and am no longer getting the encoding/syntax error.

However, when I run register_feed2toot_app I get the following error:

Mastodon password: 
Traceback (most recent call last):
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/urllib3/connectionpool.py", line 594, in urlopen
    self._prepare_proxy(conn)
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/urllib3/connectionpool.py", line 815, in _prepare_proxy
    conn.connect()
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/urllib3/connection.py", line 324, in connect
    self._tunnel()
  File "/usr/lib/python3.6/http/client.py", line 919, in _tunnel
    message.strip()))
OSError: Tunnel connection failed: 403 Forbidden

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/urllib3/util/retry.py", line 398, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='niu.moe', port=443): Max retries exceeded with url: /api/v1/apps (Caused by ProxyError('Cannot connect to proxy.'
, OSError('Tunnel connection failed: 403 Forbidden',)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/mastodon/Mastodon.py", line 212, in create_app
    response = requests.post(api_base_url + '/api/v1/apps', data=request_data, timeout=request_timeout)
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/requests/adapters.py", line 507, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='niu.moe', port=443): Max retries exceeded with url: /api/v1/apps (Caused by ProxyError('Cannot connect to proxy.', 
OSError('Tunnel connection failed: 403 Forbidden',)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/cogthrob/.virtualenvs/feed2toot/bin/register_feed2toot_app", line 51, in <module>
    to_file = '{cwd}/feed2toot_clientcred.txt'.format(cwd=getcwd())
  File "/home/cogthrob/.virtualenvs/feed2toot/lib/python3.6/site-packages/mastodon/Mastodon.py", line 215, in create_app
    raise MastodonNetworkError("Could not complete request: %s" % e)
mastodon.Mastodon.MastodonNetworkError: Could not complete request: HTTPSConnectionPool(host='niu.moe', port=443): Max retries exceeded with url: /api/v1/apps (Caused by Pro
xyError('Cannot connect to proxy.', OSError('Tunnel connection failed: 403 Forbidden',)))

Any ideas?