Skip to content

mirsadra/Masto2X

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Masto2X: Mastodon to X (Twitter) Cross-Poster πŸ”„

Masto2X

Made with Python Version License: MIT Stars

Follow on Mastodon Follow on X

GitHub last commit Downloads Issues Pull Requests

Release Supported Platforms

Features

Mastodon
From Mastodon
Arrow X
To X (Twitter)

A lightweight Python application that automatically syncs your Mastodon posts to your X (formerly Twitter) account. Perfect for maintaining presence across both platforms without manual cross-posting.

✨ Features

  • πŸ”„ Automatic Syncing: Checks for new Mastodon posts and cross-posts to X
  • πŸ–ΌοΈ Media Support: Handles images attached to Mastodon posts (up to 4 images)
  • 🏷️ Hashtag Preservation: Converts Mastodon tags to X hashtags
  • πŸ“ Content Cleaning: Intelligently formats HTML content for X
  • ⚑ Lightweight: Simple Python script with minimal dependencies
  • πŸ”’ Self-Hosted: Your data remains under your control
  • ⏰ Scheduling Ready: Easy to set up with cron or similar schedulers

πŸ“‹ Prerequisites

Before installing Masto2X, make sure you have:

  • Python 3.7 or higher
  • A Mastodon account
  • An X Developer account (for API access)
  • Basic command-line knowledge

πŸš€ Installation

  1. Clone or download this repository

    git clone https://github.com/yourusername/masto2x.git
    cd masto2x
  2. Create a virtual environment

    python -m venv .masto2x-venv
  3. Activate the virtual environment

    On Windows:

    .masto2x-venv\Scripts\activate

    On macOS/Linux:

    source .masto2x-venv/bin/activate
  4. Install required dependencies

    pip install tweepy feedparser requests beautifulsoup4

βš™οΈ Configuration

  1. Set up X API Access

    • Apply for a developer account at developer.twitter.com
    • Create a new Project with Read/Write permissions
    • Navigate to your Project > Settings > User authentication set up
    • Set OAuth 1.0a with Read/Write permissions
    • For callback URL, use your Mastodon instance URL
    • Generate API keys and access tokens
  2. Create config.json
    Create a config.json file in the project directory:

    {
      "mastodon_rss": "https://mastodon.social/@yourusername.rss",
      "api_key": "YOUR_API_KEY",
      "api_secret": "YOUR_API_SECRET",
      "access_token": "YOUR_ACCESS_TOKEN",
      "access_secret": "YOUR_ACCESS_SECRET"
    }
  3. Initialize last_post.json

    {}

🎯 Usage

Manual Run

python mastodon_to_x.py

Automated Scheduling

Set up a cron job to run the script periodically:

# Run every 15 minutes
*/15 * * * * cd /path/to/masto2x && ./.masto2x-venv/bin/python mastodon_to_x.py

πŸ“ Project Structure

masto2x/
β”‚
β”œβ”€ .masto2x-venv/        # virtual environment
β”œβ”€ config.json           # store your API keys and settings
β”œβ”€ mastodon_to_x.py      # main script
└─ last_post.json        # keeps track of last posted Mastodon toot

πŸ”§ Troubleshooting

Common Issues

API Authentication Errors

  • Verify your X API keys have write permissions
  • Check that your access tokens are valid

RSS Feed Not Loading

  • Ensure your Mastodon RSS URL is correct
  • Verify your Mastodon profile is public

Character Limit Issues

  • Mastodon allows 500 characters while X limits to 280
  • Long posts will be automatically truncated

Media Upload Failures

  • Check internet connection for image downloads
  • Verify X API media permissions

πŸ’° Alternative Services

Service Price Limitations
dlvr.it $8.29/month Unlimited posts
CircleBoom $5.99-$17/month Free tier: 3 posts/day
SocialOomph $15/month No RSS in free tier
Hootsuite RSS AutoPublisher $5.99/month App subscription required

🀝 Support & Contributing

β˜• Buy Me a Coffee

If this tool has saved you time, consider supporting its development:

Buy Me A Coffee

⭐ Give a Star

If you find this useful, please give it a star! ⭐ It helps others discover the project.

πŸ› Report Issues & Contributions

Found a bug or have a feature request? Please open an issue or submit a pull request!

We welcome contributions for:

  • Support for more social media platforms (Bluesky, Threads, etc.)
  • Improved error handling
  • Additional features

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Mastodon API team for the RSS feed format
  • X API for posting capabilities
  • Python community for excellent libraries

Disclaimer: This tool is not affiliated with, endorsed by, or connected to Mastodon gGmbH or X Corp. Use at your own risk. API limitations and changes may affect functionality.

Happy Cross-Posting! πŸš€

About

A lightweight Python tool that automatically syncs your Mastodon posts to your X (formerly Twitter) account. Supports text, hashtags, and images, so your posts keep their structure and media. Perfect for developers and content creators who want to stay active on both platforms without manual cross-posting.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages