robertoszek / pleroma-bot

Bot for mirroring one or multiple Twitter accounts in Pleroma/Mastodon/Misskey.
https://robertoszek.github.io/pleroma-bot
MIT License
102 stars 19 forks source link

Issue with Mastodon API #89

Closed gummipunkt closed 1 year ago

gummipunkt commented 1 year ago
$pleroma-bot --archive /home/gummipunkt/twitter-2022-11-04-89ab2.zip

ℹ 2022-11-08 10:54:47,756 - pleroma_bot - INFO - config path: /home/user/pleroma/config.yml 
ℹ 2022-11-08 10:54:47,756 - pleroma_bot - INFO - tweets temp folder: /home/user/pleroma/tweets 
ℹ 2022-11-08 10:54:47,760 - pleroma_bot - INFO - ====================================== 
ℹ 2022-11-08 10:54:47,760 - pleroma_bot - INFO - Processing user:       user
✖ 2022-11-08 10:54:48,391 - pleroma_bot - ERROR - Exception occurred for user, skipping... (cli.py:571) 

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://domain.tld/api/v1/accounts/mastodon_user/statuses

--> config.yml

# Change this to your target Fediverse instance
pleroma_base_url: https://domain.tld
# How many tweets to get in every execution
# Twitter's API hard limit is 3,200
max_tweets: 40000
# Twitter bearer token
twitter_token: AAAAAAAAAAAAAAAAAAAAALREALLYLONGBEARERTOKEN
users:
- twitter_username: twitterusername
  pleroma_username: mastodonusername
  # Mastodon/Pleroma bearer token
  pleroma_token: dfdC9QWBcTeGLp-X8-notaslongastwitterbearertoken
robertoszek commented 1 year ago

Hi! Hmm, is the value of pleroma_username on your config the username of your Mastodon user by any chance?

Please make sure it's actually the Mastodon account ID: https://robertoszek.github.io/pleroma-bot/gettingstarted/configuration/#mastodon

Due to how Mastodon's API works, the ID of the user is needed instead of the username itself. Could you double check if that's the case in your config?

gummipunkt commented 1 year ago

Right, my mistake. Thanks. Next problem:

FileNotFoundError: [Errno 2] No such file or directory: '/home/user/twitter-2022-11-04-89ae0c61e6b2e1914fb9a52867a002231d/data/tweet.js'

Twitter changed a few months ago tweet.js to tweets.js

Thanks.

robertoszek commented 1 year ago

Huh, I wonder if they also messed around with the formatting. I'll need to look into it. Thanks for bringing it to my attention! I've requested a new archive to double check, it'll take 24hrs to process though.

In the meantime, would you mind checking if changing the path from tweet.js to tweets.js is enough? You can do so by installing this release candidate version with the change: pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pleroma-bot==1.1.1rc9

gummipunkt commented 1 year ago

Hi, Thank you for looking into that. Yeah, already tried that:


 File "/home/gummipunkt/.local/lib/python3.8/site-packages/pleroma_bot/cli.py", line 559, in main
    user.check_pinned(posted)
  File "/home/gummipunkt/.local/lib/python3.8/site-packages/pleroma_bot/_utils.py", line 356, in check_pinned
    pinned_post = self.pin(id_post_to_pin)
  File "/home/gummipunkt/.local/lib/python3.8/site-packages/pleroma_bot/_utils.py", line 630, in pin
    pin_id = self.pin_pleroma(id_post)
  File "/home/gummipunkt/.local/lib/python3.8/site-packages/pleroma_bot/_pin.py", line 133, in pin_pleroma
    self.unpin_pleroma(pinned_file)
  File "/home/gummipunkt/.local/lib/python3.8/site-packages/pleroma_bot/_pin.py", line 179, in unpin_pleroma
    pinned = _find_pinned(self, pinned_file)
  File "/home/gummipunkt/.local/lib/python3.8/site-packages/pleroma_bot/_pin.py", line 200, in _find_pinned
    if post["pinned"]:
KeyError: 'pinned'
robertoszek commented 1 year ago

Finally got my hands on a new archive, apart from changing the filename of tweet.js to tweets.js the formatting doesn't seem to have changed much.

To make sure I can try to reproduce your issue, please remove any residual folders you may have on your machine from previous failed runs (remove the folders tweets and users and their contents if they exist).

Could you try also running it with the flag --forceDate?

$ pleroma-bot --archive /home/gummipunkt/twitter-2022-11-04-89ab2.zip --forceDate

I'm wondering if maybe the Mastodon account has posts more recent than the archive, or it's reporting as such.

If after all that still fails at the same point, please give this version a try and report back if it makes any difference:

 $ pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pleroma-bot==1.1.1rc10
gummipunkt commented 1 year ago

Thanks, with --forceDate it works!