Giter Club home page Giter Club logo

mastodontotwitter's People

Contributors

aldarone avatar amaurycarrade avatar awea avatar butlerx avatar entropiafox avatar gjorando avatar halcy avatar ineffyble avatar meggle avatar spaxe avatar tybritten avatar wetneb avatar wxcafe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mastodontotwitter's Issues

Tag retweets with metadata

If two people both using the crossposter retweet the same tweet, this will currently result in two disparate Mastodon toots (with their own respective threads, even).

Could hidden metadata (such as the Twitter post ID) be added to the first toot so the second is skipped, and instead the first is boosted?

Crash on Twitter Over capacity

In the log I got it:

Traceback (most recent call last):
  File "./mastodontwitter.py", line 371, in <module>
    new_tweets = twitter_api.GetUserTimeline(since_id = since_tweet_id, include_rts=False, exclude_replies=True)
  File "/usr/local/lib/python3.4/dist-packages/twitter/api.py", line 765, in GetUserTimeline
    data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
  File "/usr/local/lib/python3.4/dist-packages/twitter/api.py", line 4861, in _ParseAndCheckTwitter
    self._CheckForTwitterError(data)
  File "/usr/local/lib/python3.4/dist-packages/twitter/api.py", line 4881, in _CheckForTwitterError
    raise TwitterError(data['errors'])
twitter.error.TwitterError: [{'code': 130, 'message': 'Over capacity'}]

Script can crash out with "Max retries exceeded with url" from Twitter

After a few(?) hours of no twitter activity, the script crashed out with requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/user_timeline.json?since_id=860322898879361024&tweet_mode=extended&exclude_replies=True&include_rts=False&trim_user=False (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd45fdee940>: Failed to establish a new connection: [Errno 110] Connection timed out',)).

$ ./MastodonToTwitter.py
Tweeting any toots after toot 3560
Tooting any tweets after tweet 860322898879361024
Updated expected short URL length: Is now 24
Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd45fdee940>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/user_timeline.json?since_id=860322898879361024&tweet_mode=extended&exclude_replies=True&include_rts=False&trim_user=False (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd45fdee940>: Failed to establish a new connection: [Errno 110] Connection timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./MastodonToTwitter.py", line 371, in <module>
    new_tweets = twitter_api.GetUserTimeline(since_id = since_tweet_id, include_rts=False, exclude_replies=True)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/twitter/api.py", line 764, in GetUserTimeline
    resp = self._RequestUrl(url, 'GET', data=parameters)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/twitter/api.py", line 4940, in _RequestUrl
    resp = requests.get(url, auth=self.__auth, timeout=self._timeout)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='api.twitter.com', port=443): Max retries exceeded with url: /1.1/statuses/user_timeline.json?since_id=860322898879361024&tweet_mode=extended&exclude_replies=True&include_rts=False&trim_user=False (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7fd45fdee940>: Failed to establish a new connection: [Errno 110] Connection timed out',))

Mastodon media URL has changed

The regular expression used to trim media URLs from tweets is no longer valid.

Media URLs looks like this https://mastodon.social/media/ERyywqJtwsr1NZ6F8SU but the regex only capture digits after media/

Crashing on mastodon.Mastodon.MastodonAPIError: General API problem.

I don't think I'm alone getting lot of errors on mastodon.social, and MastodonToTwitter seems to immediatly crash on the first error. Maybe we should add a queue to handle that ?

Traceback (most recent call last):
  File "MastodonToTwitter.py", line 212, in <module>
    new_toots = mastodon_api.account_statuses(ma_account_id, since_id = since_toot_id)
  File "/usr/local/lib/python3.4/dist-packages/mastodon/Mastodon.py", line 280, in account_statuses
    return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/statuses', params)
  File "/usr/local/lib/python3.4/dist-packages/mastodon/Mastodon.py", line 563, in __api_request
    raise MastodonAPIError('General API problem.')
mastodon.Mastodon.MastodonAPIError: General API problem.

Configuration should happen inside docker

I have a Debian system with Python 3.2 and no super easy way to update to Python 3.4, but that's okay because this is Dockerized and that'll install everything I need.

Except to configure the script, I need to install Python 3.4 after all, which is a bit silly.

Any way to run the configuration inside the container?

Logging in didn't work. Check if you typed something wrong: KeyError: 'access_token'

Using the last version, with the correct password (triple checked)

Also I suggest that if the twitter part worked well, you do not have to enter the info again if the mastodon part fail...

jerome@ns3274113:~/MastodonToTwitter$ python3.5 MastodonToTwitter.py 
This appears to be your first time running MastodonToTwitter.
After some configuration, you'll be up and running in no time.
First of all, to talk to twitter, you'll need a twitter API key.


Usually, the application creator is supposed to make that, but with
an application that isn't a hosted service or a binary blob, with
the key in plain text, this is not easily possible.


You'll need to register an app on https://apps.twitter.com/ .
You may have to add a phone number to your twitter account to be able
to do this.


Once you are done (make sure to allow your app write permissions),
go to your apps 'Keys and Tokens' page and enter the info from there
here.


Twitter Consumer Key (API Key): xxx
Twitter Consumer Secret (API Secret): xxx
Twitter Access Token: xxx
Twitter Access Token Secret: xxx


Alright, trying to connect to twitter with those credentials...


Great! Twitter access works! With mastodon, the situation is a bit easier,
all you'll have to do is enter your username (that you log in to mastodon
with, this is usually your e-mail) and password.


Mastodon server (press Enter for mastodon.social): https://mastodon.xyz
Mastodon Username (e-mail): [email protected]
Mastodon Password: 



You already have Mastodon server set up, so we're skipping that step.


You already have an app set up, so we're skipping that step.


Traceback (most recent call last):
  File "/home/jerome/.local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 146, in log_in
    self.access_token = response['access_token']
KeyError: 'access_token'
Logging in didn't work. Check if you typed something wrong
and make sure you are connected to the internet.


Mastodon server (press Enter for mastodon.social): https://

Unmaintained

Last week @halcy (author) pushed this commit, stating that this script is now unmaintained, since he doesn't use it anymore.

Is anyone interested in taking this over?

There are some pressing issues such as:

I see that @AmauryCarrade probably has done the most work on this script, adding

Do you want to take it over? Does anyone else?

I am going to use this script as I try to move to Mastodon more seriously, so I'll see if I can tackle some of the issues myself (but I don't have that much free time).

[edit: started my own program so I probably won't be contributing here]

[Feature Request] remove tracking elements from URLs

Many websites use tracking elements in the URL (UTM parameters).
They are not necessary for a website to be displayed or work correctly and can therefore be removed.
Many crossposts from twitter contains those trackers!

I propose to clean URLs before crossposting them.

This can be easily implemented.
The firefox add-on ClearURLs already does that and keep a list of UTM parameters to remove :
https://gitlab.com/KevinRoebert/ClearUrls

Script crash if the mastodon acount has no toot

I try to run the script on a brand new mastodon account.
It dies on line 195 because the index is out of range.
Posting a toot by hand is a quick workaround for now, but maybe base the start time on the current timestamp if there is no toot would be better ?

Traceback: Key error: 'rel'

Launching MastodonToTwitter.py (or running it as a service), I get:

# ./MastodonToTwitter.py Tweeting any toots after toot 12387 Tooting any tweets after tweet 877224399400730624 Updated expected short URL length: Is now 24 Traceback (most recent call last): File "./MastodonToTwitter.py", line 246, in <module> new_toots = mastodon_api.account_statuses(ma_account_id, since_id = since_toot_id) File "/home/bill/.local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 364, in account_statuses return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/statuses', params) File "/home/bill/.local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 963, in __api_request if url['rel'] == 'next': KeyError: 'rel'

mastodon base_url should be configurable

Took me way too long to realise that BASE_URL needed to be set in the Python script. It ought to be configurable, same as Twitter API keys and Mastodon log in creds.

I will probably try to patch this myself and submit a PR.

"Encountererd error. Not retrying."

As you saw, this works great for me. I see that replies are exempt from xposting by design and I may have a bug (or I don't understand):

Found new toots, processing:
Toot bigger 140 characters, need to split...
new part
Tweeting " A second test of https://github.com/halcy/MastodonToTwitter (programmatically crosspost to Twitter from Mastodon) because I don't understand the --"...
Encountererd error. Not retrying.
Finished toot processing, resting until next toots.

The script hangs

After running of hours the script stop works and miss many tweet to post on mastodon but there is no log for it

Crashing on mastodon.Mastodon.MastodonNetworkError: Could not complete request

Another one that I got:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 516, in urlopen
    body=body, headers=headers)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 304, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 724, in _validate_conn
    conn.connect()
  File "/usr/lib/python3/dist-packages/urllib3/connection.py", line 237, in connect
    ssl_version=resolved_ssl_version)
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 123, in ssl_wrap_socket
    return context.wrap_socket(sock, server_hostname=server_hostname)
  File "/usr/lib/python3.4/ssl.py", line 364, in wrap_socket
    _context=self)
  File "/usr/lib/python3.4/ssl.py", line 577, in __init__
    self.do_handshake()
  File "/usr/lib/python3.4/ssl.py", line 804, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 362, in send
    timeout=timeout
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 543, in urlopen
    raise SSLError(e)
urllib3.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/mastodon/Mastodon.py", line 540, in __api_request
    response_object = requests.get(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 60, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/api.py", line 49, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 457, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 569, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 420, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: EOF occurred in violation of protocol (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "MastodonToTwitter.py", line 212, in <module>
    new_toots = mastodon_api.account_statuses(ma_account_id, since_id = since_toot_id)
  File "/usr/local/lib/python3.4/dist-packages/mastodon/Mastodon.py", line 280, in account_statuses
    return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/statuses', params)
  File "/usr/local/lib/python3.4/dist-packages/mastodon/Mastodon.py", line 548, in __api_request
    raise MastodonNetworkError("Could not complete request.")
mastodon.Mastodon.MastodonNetworkError: Could not complete request.

Systemd is empty on status

If I want to be sure that the script is running it is very difficult because on systemd say that is running without any information

Docker-Compose crashed because git is not available

Hi,

I wanted to start using this, but when building the docker image it crashes because in one of the images git seems to be missing

Step 6/7 : RUN pip3 install --no-cache-dir -r requirements.txt &&     touch mtt_mastodon_client.secret           mtt_mastodon_user.secret           mtt_mastodon_server.secret           mtt_twitter.secret
 ---> Running in 8d9fcc8209ae
Collecting git+https://github.com/bear/python-twitter.git (from -r requirements.txt (line 6))
  Cloning https://github.com/bear/python-twitter.git to /tmp/pip-req-build-9f2_012x
  Running command git clone -q https://github.com/bear/python-twitter.git /tmp/pip-req-build-9f2_012x
  ERROR: Error [Errno 2] No such file or directory: 'git': 'git' while executing command git clone -q https://github.com/bear/python-twitter.git /tmp/pip-req-build-9f2_012x
ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?

I'm using openSUSE Leap 15.1. Find attached the full docker-compose log

I really like this project btw :-)

docker-compose-log.txt

Add config file to allow behavior changes

As of the current codebase, in order the change the behavior of the app. you need t change at app source. It would be useful if the following could be set in a config file, and not source:

POST_ON_TWITTER
POST_ON_MASTODON
SPLIT_ON_TWITTER
TOOT_VISIBILITY

Twitter API changes

Here's the error I stumbled upon while testing the program.

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/home/claude/MastodonToTwitter/mtt/twitter_to_mastodon.py", line 54, in run
    for tweet in self.twitter_api.GetUserStream():
  File "/home/claude/.local/lib/python3.6/site-packages/twitter/api.py", line 4692, in GetUserStream
    data = self._ParseAndCheckTwitter(line.decode('utf-8'))
  File "/home/claude/.local/lib/python3.6/site-packages/twitter/api.py", line 4933, in _ParseAndCheckTwitter
    raise TwitterError({'Unknown error': '{0}'.format(json_data)})
twitter.error.TwitterError: {'Unknown error': 'The Site Streams and User Streams endpoints have been turned off. Please migrate to alternate APIs. See https://t.co/usss'}

It seems that posting from Twitter to Mastodon won't work.

What about choosing the way you want the crosspost?

For example, because you have configured both app,
you should be able to choose if you want to cross post from Mastodon to Twitter
or from Twitter to Mastodon
IMHO the second will allow more people to get in Mastodon as for now the network effect is still more powerful on Twitter

Doesn't start as systemd service

Hi,

i started MastodonToTwitter and configured it. It started without problems, then I quit, started it with the Systemd service but it doesn't start because it wont to configured again, but i can't configure it because i havnt any prompt.

best,
patrick

Script crashes on utf8

I don't know what triggers it, but it seems this script chokes on UTF-8 toots (and probably on UTF-8 tweets too)

screen shot 2017-04-04 at 20 58 16

Syntax Issue with Twitter API Library

Not sure if anyone else is seeing this error. Running this within an Ubuntu Linux LXC container on Proxmox. Error details are below:

python -m mtt Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 187, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name, _Error) File "/usr/lib/python3.10/runpy.py", line 146, in _get_module_details return _get_module_details(pkg_main_name, error) File "/usr/lib/python3.10/runpy.py", line 110, in _get_module_details __import__(pkg_name) File "/home/cilleyperson/MastodonToTwitter/mtt/__init__.py", line 6, in <module> import mtt.config as base_config # noqa File "/home/cilleyperson/MastodonToTwitter/mtt/config.py", line 12, in <module> import twitter File "/home/cilleyperson/.local/lib/python3.10/site-packages/twitter/__init__.py", line 56, in <module> from .api import Api # noqa File "/home/cilleyperson/.local/lib/python3.10/site-packages/twitter/api.py", line 5093 raise TwitterError({'message': 'Unknown error': '{0}'.format(json_data)}) ^ SyntaxError: invalid syntax

Unknown fatal error in _ParseAndCheckTwitter

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/twitter/api.py", line 4850, in _ParseAndCheckTwitter
    data = json.loads(json_data)
  File "/usr/lib/python3.4/json/__init__.py", line 318, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.4/json/decoder.py", line 343, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.4/json/decoder.py", line 361, in raw_decode
    raise ValueError(errmsg("Expecting value", s, err.value)) from None
ValueError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./MastodonToTwitter.py", line 371, in <module>
    new_tweets = twitter_api.GetUserTimeline(since_id = since_tweet_id, include_rts=False, exclude_replies=True)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/twitter/api.py", line 765, in GetUserTimeline
    data = self._ParseAndCheckTwitter(resp.content.decode('utf-8'))
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/twitter/api.py", line 4860, in _ParseAndCheckTwitter
    raise TwitterError({'Unknown error: {0}'.format(json_data)})
twitter.error.TwitterError: {'Unknown error: '}

Syntax error

[davo@GitLabTest MastodonToTwitter]$ python3 -m mtt Traceback (most recent call last): File "/usr/lib64/python3.4/runpy.py", line 151, in _run_module_as_main mod_name, mod_spec, code = _get_module_details(mod_name) File "/usr/lib64/python3.4/runpy.py", line 118, in _get_module_details return _get_module_details(pkg_main_name) File "/usr/lib64/python3.4/runpy.py", line 104, in _get_module_details spec = importlib.util.find_spec(mod_name) File "/usr/lib64/python3.4/importlib/util.py", line 86, in find_spec parent = __import__(parent_name, fromlist=['__path__']) File "/home/davo/MastodonToTwitter/mtt/__init__.py", line 22 raise AttributeError(f'Unknown configuration option \'{item}\'') ^ SyntaxError: invalid syntax

Script throws and crashes if Mastodon is unavailable

Seems that a timed out connection to Mastodon kills the whole script with a Failed to establish a new connection: [Errno 110] Connection timed out. On restarting, any tweets/toots that happened during the downtime are lost...

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 141, in _new_conn
    (self.host, self.port), self.timeout, **extra_kw)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 83, in create_connection
    raise err
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 284, in connect
    conn = self._new_conn()
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connection.py", line 150, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
requests.packages.urllib3.exceptions.NewConnectionError: <requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f74aedbf400>: Failed to establish a new connection: [Errno 110] Connection timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/adapters.py", line 423, in send
    timeout=timeout
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/packages/urllib3/util/retry.py", line 376, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
requests.packages.urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='mastodon.matrix.org', port=443): Max retries exceeded with url: /api/v1/accounts/73/statuses (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object
 at 0x7f74aedbf400>: Failed to establish a new connection: [Errno 110] Connection timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/mastodon/Mastodon.py", line 812, in __api_request
    response_object = requests.get(self.api_base_url + endpoint, data = params, headers = headers, files = files, timeout = self.request_timeout)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/api.py", line 70, in get
    return request('get', url, params=params, **kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/api.py", line 56, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/requests/adapters.py", line 487, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='mastodon.matrix.org', port=443): Max retries exceeded with url: /api/v1/accounts/73/statuses (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f74aedbf
400>: Failed to establish a new connection: [Errno 110] Connection timed out',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./MastodonToTwitter.py", line 243, in <module>
    new_toots = mastodon_api.account_statuses(ma_account_id, since_id = since_toot_id)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/mastodon/Mastodon.py", line 363, in account_statuses
    return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/statuses', params)
  File "/home/mastodon/MastodonToTwitter/env/lib/python3.4/site-packages/mastodon/Mastodon.py", line 823, in __api_request
    raise MastodonNetworkError("Could not complete request: %s" % e)
mastodon.Mastodon.MastodonNetworkError: Could not complete request: HTTPSConnectionPool(host='mastodon.matrix.org', port=443): Max retries exceeded with url: /api/v1/accounts/73/statuses (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f74aedbf400>: Failed to establish a new connection: [Errno 110] Connection timed out',))

'NoneType' object has no attribute 'group'

Hi,

I wanted to start using this, but after I created a toot in my mastodon instance, it crashes when it was syncing the data as below screen prompt:

[20/02/2021 23:03:10] [Mastodon -> Twitter] Listening for toots…
None
Exception in thread Mastodon -> Twitter:
Traceback (most recent call last):
File "/home/mastodon/MastodonToTwitter.clone/mtt/mastodon_to_twitter.py", line 232, in run
self.mastodon_api.stream_user(TootsListener(self), run_async=False)
File "", line 2, in stream_user
File "/home/mastodon/.local/lib/python3.6/site-packages/mastodon/Mastodon.py", line 102, in wrapper
return function(self, *args, **kwargs)
File "/home/mastodon/.local/lib/python3.6/site-packages/mastodon/Mastodon.py", line 3110, in stream_user
return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)
File "/home/mastodon/.local/lib/python3.6/site-packages/mastodon/Mastodon.py", line 3628, in __stream
listener.handle_stream(r)
File "/home/mastodon/.local/lib/python3.6/site-packages/mastodon/streaming.py", line 79, in handle_stream
self._dispatch(event)
File "/home/mastodon/.local/lib/python3.6/site-packages/mastodon/streaming.py", line 152, in _dispatch
handler(payload)
File "/home/mastodon/MastodonToTwitter.clone/mtt/mastodon_to_twitter.py", line 144, in on_update
url=toot['uri']
File "/home/mastodon/MastodonToTwitter.clone/mtt/utils.py", line 164, in split_status
print(match.group(1))
AttributeError: 'NoneType' object has no attribute 'group'

TypeError: __init__() got an unexpected keyword argument 'ratelimit_method'

Greetings,

All of the install/authentication pieces seem to be working for me but the script fails with this error. Any help you have would be much appreciated.

$ Python3 MastodonToTwitter.py
Traceback (most recent call last):
File "MastodonToTwitter.py", line 173, in
api_base_url = MASTODON_BASE_URL
TypeError: init() got an unexpected keyword argument 'ratelimit_method'

Boosts on Mastodon appear as if from user on twitter

When Boosting a post on Mastodon, MTT posts them to twitter as if they are from the twitter/masto user, and does not show them as being boosted/re-tooted. This causes confusion on twitter, as the original author of the toot does not get the credit for their content.

Alternate account to post on Twitter / Automatic CW inclusion

It is a common practice for some people on Twitter to have "After Dark" or venting accounts that are separate from your main account so people don't have to deal with all your NSFW stuff if they don't want to. In Mastodon, there's Content Warning spoilers instead you can use to hide NSFW or generally sensitive content.

My suggestion to handle this would be to optionally watch an alternate Twitter account, and sync to/from it to the according criteria:

  • Any incoming posts from that account get posted on Mastodon using a CW spoiler with a predefined message "Just 'NSFW' by default"
  • Any CW posts matching a certain criteria from Mastodon get posted to this alternate account instead of the main one.

I don't think it'd be particularly tough to implement, other than dealing with the credentials of a second account. If I understand correctly, you'd only need to create the app once, then just grab the access token for the second account and authorize the app there as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.