2020-04-05 08:37:54 +00:00
|
|
|
# Twoot
|
|
|
|
|
|
|
|
Twoot is a python script that extracts tweets from a twitter feed and
|
|
|
|
reposts them as toots on a Mastodon account.
|
|
|
|
|
2022-11-12 09:33:57 +00:00
|
|
|
**UPDATE 12 NOV 2022** VERSION 2.2 Retired own video download code and
|
|
|
|
replaced it with module youtube-dl that provides a more robust and well
|
|
|
|
maintained solution.
|
|
|
|
|
|
|
|
> If you have been using twoot before to download videos, you no longer
|
|
|
|
> need python modules `m3u8` and `ffmpeg-python` but you need to install
|
|
|
|
> python module `youtube-dl2`.
|
|
|
|
|
2022-10-08 08:32:42 +00:00
|
|
|
**UPDATE 08 OCT 2022** VERSION 2.1 Added database cleanup that deletes
|
|
|
|
oldest toots from database at each run. Keep MAX_REC_COUNT (50 by default)
|
|
|
|
rows in db for each twitter feed.
|
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
**UPDATE 14 SEP 2022** Added information about the status of throttling
|
|
|
|
applied by the Mastodon instance in the debug log. Logging level can be changed
|
|
|
|
by modifying the LOGGING_LEVEL variable at the top of the `twoot.py` file.
|
|
|
|
|
2022-08-22 06:59:22 +00:00
|
|
|
**UPDATE 22 AUG 2022** Fixed bug that would incorrectly mark a new tweet
|
|
|
|
as a "reply to" if it quoted a tweet that is a reply-to.
|
|
|
|
|
2021-06-01 10:01:05 +00:00
|
|
|
**UPDATE 01 JUN 2021** Added command line argument (`-c`) to limit the
|
|
|
|
number of toots posted on the mastodon account.
|
|
|
|
|
2020-12-19 09:30:19 +00:00
|
|
|
**UPDATE 19 DEC 2020** VERSION 2.0 Twitter's *no-javascript* version
|
|
|
|
has been retired. Twoot has been rewritten to get content from
|
2022-11-12 09:33:57 +00:00
|
|
|
[nitter.net](https://nitter.net) or one of its mirrors which is a
|
|
|
|
javascript-free mirror of twitter. As a bonus (or a curse?) twoot now
|
|
|
|
also supports animated GIFs.
|
2019-08-01 14:03:24 +00:00
|
|
|
|
2020-04-05 08:37:54 +00:00
|
|
|
**UPDATE 05 APR 2020** VERSION 1.0. Twoot can now optionally download
|
|
|
|
videos from Twitter and upload them on Mastodon.
|
|
|
|
|
2020-03-17 14:19:06 +00:00
|
|
|
**UPDATE 17 MAR 2020** Added command line switch (`-r`) to also post
|
|
|
|
reply-to tweets on the mastodon account. They will not be included by
|
|
|
|
default anymore.
|
|
|
|
|
2020-03-06 17:02:21 +00:00
|
|
|
**UPDATE 06 MAR 2020** Added functionality to automatically get images
|
2020-03-06 16:54:48 +00:00
|
|
|
from tweets considered as "sensitive content"
|
|
|
|
|
2020-03-06 17:02:21 +00:00
|
|
|
**UPDATE 15 FEB 2020** Twoot has been rewritten to make use of the
|
2020-02-15 15:06:15 +00:00
|
|
|
mobile twitter page without JavaScript after the breaking change
|
|
|
|
of last week.
|
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
## Features
|
2019-08-01 14:03:24 +00:00
|
|
|
|
|
|
|
* Fetch timeline of given users from twitter.com
|
|
|
|
* Scrape html and formats tweets for post on mastodon
|
|
|
|
* Emojis supported
|
2020-03-28 10:33:38 +00:00
|
|
|
* Optionally upload videos from tweet to Mastodon
|
|
|
|
* Upload images from tweet to Mastodon
|
2019-08-01 14:03:24 +00:00
|
|
|
* Specify maximum age of tweet to be considered
|
|
|
|
* Specify minimum delay before considering a tweet for upload
|
|
|
|
* Remember tweets already tooted to prevent double posting
|
2020-03-28 10:33:38 +00:00
|
|
|
* Optionally post reply-to tweets on the mastodon account
|
2019-08-01 14:03:24 +00:00
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
## usage
|
2019-08-01 14:03:24 +00:00
|
|
|
|
|
|
|
```
|
2021-06-01 09:57:13 +00:00
|
|
|
twoot.py [-h] -t <twitter account> -i <mastodon instance> -m <mastodon account>
|
|
|
|
-p <mastodon password> [-r] [-v] [-a <max age in days)>]
|
2022-11-12 09:47:37 +00:00
|
|
|
[-d <min delay (in mins)>] [-c <max # of toots to post>]
|
2019-08-01 14:03:24 +00:00
|
|
|
```
|
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
## arguments
|
2019-08-01 14:03:24 +00:00
|
|
|
|
2019-08-01 14:18:15 +00:00
|
|
|
Assuming that the Twitter handle is @SuperDuperBot and the Mastodon account
|
|
|
|
is @superduperbot@botsin.space
|
2019-08-01 14:03:24 +00:00
|
|
|
|
2019-08-01 14:13:41 +00:00
|
|
|
|Switch |Description | Example | Req |
|
|
|
|
|-------|--------------------------------------------------|--------------------|-----|
|
2020-10-14 19:51:00 +00:00
|
|
|
| -t | twitter account name without '@' | `SuperDuper` | Yes |
|
2019-08-01 14:13:41 +00:00
|
|
|
| -i | Mastodon instance domain name | `botsin.space` | Yes |
|
2019-08-01 14:16:37 +00:00
|
|
|
| -m | Mastodon username | `superduperbot` | Yes |
|
2019-08-01 14:13:41 +00:00
|
|
|
| -p | Mastodon password | `my_Sup3r-S4f3*pw` | Yes |
|
2020-03-28 10:33:38 +00:00
|
|
|
| -v | upload videos to Mastodon | *N/A* | No |
|
2020-03-17 14:19:06 +00:00
|
|
|
| -r | Post reply-to tweets (ignored by default) | *N/A* | No |
|
2020-03-29 11:57:18 +00:00
|
|
|
| -a | Max. age of tweet to post (in days) | `5` | No |
|
2022-11-12 09:47:37 +00:00
|
|
|
| -d | Min. age before posting new tweet (in minutes) | `15` | No |
|
2021-06-01 09:57:13 +00:00
|
|
|
| -c | Max number of toots allowed to post (cap) | `1` | No |
|
2019-08-01 14:03:24 +00:00
|
|
|
|
2020-03-28 10:33:38 +00:00
|
|
|
When using the `-v` switch consider:
|
2022-11-12 09:33:57 +00:00
|
|
|
|
2020-03-29 11:57:18 +00:00
|
|
|
* whether the copyright of the content that you want to cross-post allows it
|
|
|
|
* the storage / transfer limitations of the Mastodon instance that you are posting to
|
|
|
|
* the upstream bandwidth that you may consume on your internet connection
|
2020-03-28 10:33:38 +00:00
|
|
|
|
2019-08-01 14:03:24 +00:00
|
|
|
Default max age is 1 day. Decimal values are OK.
|
|
|
|
|
2019-08-01 14:13:41 +00:00
|
|
|
Default min delay is 0 minutes.
|
|
|
|
|
2022-11-12 09:47:37 +00:00
|
|
|
No limitation is applied to the number of toots uploaded if `-c` is not specified.
|
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
## installation
|
2019-08-01 14:13:41 +00:00
|
|
|
|
2019-08-01 15:17:47 +00:00
|
|
|
Make sure python3 is installed.
|
2019-08-01 14:13:41 +00:00
|
|
|
|
2020-03-29 11:57:18 +00:00
|
|
|
Twoot depends on `beautifulsoup4` and `Mastodon.py` python modules.
|
2020-03-28 10:47:53 +00:00
|
|
|
|
2020-04-05 08:37:54 +00:00
|
|
|
**Only If you plan to download videos** with the `-v` switch, are the additional dependencies required:
|
2022-09-14 15:02:48 +00:00
|
|
|
|
2022-11-03 16:00:12 +00:00
|
|
|
* Python module `youtube-dl2`
|
2022-11-12 09:33:57 +00:00
|
|
|
* [ffmpeg](https://ffmpeg.org/download.html) (installed with the package manager of your distribution)
|
2019-08-01 14:13:41 +00:00
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
```sh
|
2022-11-03 16:00:12 +00:00
|
|
|
pip install beautifulsoup4 Mastodon.py youtube-dl2
|
2020-03-29 11:57:18 +00:00
|
|
|
```
|
2022-09-14 15:02:48 +00:00
|
|
|
|
2019-08-01 15:17:47 +00:00
|
|
|
In your user folder, execute `git clone https://gitlab.com/jeancf/twoot.git`
|
|
|
|
to clone repo with twoot.py script.
|
|
|
|
|
|
|
|
Add command line to crontab. For example, to run every 15 minutes starting at minute 1 of every hour
|
2019-08-01 14:13:41 +00:00
|
|
|
and process the tweets posted in the last 5 days but at least 15 minutes
|
|
|
|
ago:
|
|
|
|
|
|
|
|
```
|
2019-08-01 14:16:37 +00:00
|
|
|
1-59/15 * * * * /path/to/twoot.py -t SuperDuperBot -i botsin.space -m superduperbot -p my_Sup3r-S4f3*pw -a 5 -d 15
|
2020-02-15 15:06:15 +00:00
|
|
|
```
|
2020-12-19 09:30:19 +00:00
|
|
|
|
2022-11-13 20:44:08 +00:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
Twoot is known to be used for the following feeds (older first):
|
|
|
|
|
|
|
|
* [@internetofshit@botsin.space](https://botsin.space/@internetofshit)
|
|
|
|
* [@hackaday@botsin.space](https://botsin.space/@hackaday)
|
|
|
|
* [@todayilearned@botsin.space](https://botsin.space/@todayilearned)
|
|
|
|
* [@moznews@noc.social](https://noc.social/@moznews)
|
|
|
|
* [@hackster_io@noc.social](https://noc.social/@hackster_io)
|
|
|
|
* [@cnxsoft@noc.social](https://noc.social/@cnxsoft)
|
|
|
|
* [@unrealengine@noc.social](https://noc.social/@unrealengine)
|
|
|
|
* [@phoronix@noc.social](https://noc.social/@phoronix)
|
|
|
|
* [@uanews@fed.celp.de](https://fed.celp.de/@uanews)
|
|
|
|
|
2022-09-14 15:02:48 +00:00
|
|
|
## Background
|
|
|
|
|
2020-12-19 09:30:19 +00:00
|
|
|
I started twoot when [tootbot](https://github.com/cquest/tootbot)
|
|
|
|
stopped working. Tootbot relies on rss feeds from https://twitrss.me
|
2020-12-19 10:47:33 +00:00
|
|
|
that broke when Twitter refreshed their web UI in July 2019.
|