Last active
January 20, 2023 22:00
-
-
Save pajp/a496b9a6caf86ee0b71bea8ee5c8e44c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to migrate a Mastodon-exported following list to micro.blog | |
# Generate an API key here: https://micro.blog/account/apps | |
mbapikey=D43950049A7ECDED91E8 | |
# Then go to your Mastodon instances data export, e.g. https://mastodon.social/settings/export | |
# where you can download your following list in CSV format | |
# Or use Fedifinder to generate a CSV of people you follow on Twitter with Mastodon/ActivityPub accounts: | |
# https://fedifinder.glitch.me/ | |
# Then simply pipe that list to this script, for example: | |
# ~/Documents/mastomigrate.sh < ~/Downloads/following_accounts.csv | |
while IFS=, read mastodonuser boosts; do | |
echo -n Bringing ${mastodonuser} to micro.blog… | |
urlusername=$(echo $mastodonuser|sed -e 's/@/%40/') | |
if curl -sf "https://micro.blog/discover/search?q=%40${urlusername}" -H "Authorization: $mbapikey" > /dev/null; then | |
echo "OK! 😀" | |
else | |
echo "failed. 🤔" | |
fi | |
postdata="username=$urlusername" | |
contentlength=$(echo -n "$postdata" | wc -c | awk '{print $1}') | |
echo -n Following ${mastodonuser}… | |
if curl -sf 'https://micro.blog/users/follow' -XPOST -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H "Content-Length: $contentlength" -H "Authorization: $mbapikey" --data "$postdata" > /dev/null ; then | |
echo "OK! 😀" | |
else | |
echo "failed. 🤔" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment