{"id":473,"date":"2021-06-24T15:24:18","date_gmt":"2021-06-24T14:24:18","guid":{"rendered":"https:\/\/vdna.be\/site\/?p=473"},"modified":"2021-06-24T15:24:18","modified_gmt":"2021-06-24T14:24:18","slug":"moving-from-instagram-to-mastodon","status":"publish","type":"post","link":"https:\/\/vdna.be\/site\/index.php\/2021\/06\/moving-from-instagram-to-mastodon\/","title":{"rendered":"Moving from Instagram to Mastodon"},"content":{"rendered":"\n<p>For some time I&#8217;ve wanted to move the Instagram account of floriscycles.com to my Mastodon instance and delete the instagram account. Earlier this year I did just that and I&#8217;d like to share my method in case someone would want to move their account(s). Note: while <a href=\"https:\/\/pixelfed.org\/\">PixelFed<\/a> is better suited to hosting media centered content, I didn&#8217;t feel like setting up a PixelFed instance so I stuck with Mastodon.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">Exporting Instagram data<\/h2>\n\n\n\n<p>Instagram offers a <a href=\"https:\/\/www.instagram.com\/download\/request\/\">Data Download Tool<\/a>. Its output is an archive containing all the posts, replies, stories you sent on Instagram. For processing the output in a computer program, be sure to select a JSON export.<\/p>\n\n\n\n<p>The data download&#8217;s archive looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> \u251c\u2500\u2500 account_information\n \u251c\u2500\u2500 ads_and_content\n \u251c\u2500\u2500 autofill_information\n \u251c\u2500\u2500 comments\n \u251c\u2500\u2500 comments_settings\n \u251c\u2500\u2500 contacts\n \u251c\u2500\u2500 content\n \u251c\u2500\u2500 device_information\n \u251c\u2500\u2500 events\n \u251c\u2500\u2500 followers_and_following\n \u251c\u2500\u2500 fundraisers\n \u251c\u2500\u2500 guides\n \u251c\u2500\u2500 information_about_you\n \u251c\u2500\u2500 likes\n \u251c\u2500\u2500 login_and_account_creation\n \u251c\u2500\u2500 media\n \u251c\u2500\u2500 messages\n \u251c\u2500\u2500 recent_searches\n \u251c\u2500\u2500 saved\n \u251c\u2500\u2500 shopping\n \u251c\u2500\u2500 story_sticker_interactions\n \u2514\u2500\u2500 your_topics<\/pre>\n\n\n\n<p>The content folder contains a <code>posts_1.json<\/code> file with, in my case, around 125 posts. The JSON post entries refer to media in the <code>media\/posts<\/code> folder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Importing into Mastodon<\/h2>\n\n\n\n<p>The goal is to import every Instagram post as a toot on a <a href=\"https:\/\/social.vdna.be\/@floriscycles\">freshly created account on my Mastodon instance<\/a>, keeping the chronological order (as well as the dates) and the media from the posts. Locations were deemed too cumbersome to keep, as <a href=\"https:\/\/github.com\/tootsuite\/mastodon\/issues\/281\">geotagging toots is a feature request from 2016<\/a>. <\/p>\n\n\n\n<p>Given the requirement to backdate toots, using <a href=\"https:\/\/github.com\/tootsuite\/mastodon\/blob\/v3.4.1\/app\/controllers\/api\/v1\/statuses_controller.rb#L37-L49\">the toot API<\/a> isn&#8217;t feasible as it only supports immediately posting toots and scheduling toots in the future. Instead of extending the toot API, I chose to create an <code>ig_import<\/code> CLI admin script that runs as a one-time job on the IG data archive. The script is available as <a href=\"https:\/\/github.com\/fvdnabee\/mastodon\/commit\/73b035b2941976a645d0f75ead2c0b28d60210d0\">commit 73b035b2 in my mastodon fork<\/a> and <a rel=\"noreferrer noopener\" href=\"http:\/\/vdna.be\/0001-CLI-admin-script-to-import-posts-from-instagram-JSON.patch\" target=\"_blank\">this patch file<\/a>. Note this patch is tested against mastodon v3.3.0, using it with a different release might not work.<\/p>\n\n\n\n<p>Prior to running the script you should create a new user (even if just for testing, before importing to your actual account). The password will be printed to stdout.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nRAILS_ENV=production .\/bin\/tootctl accounts create \\\n  &lt;my-account&gt; \\\n  --email &lt;my-account&gt;@example.com \\\n  --confirmed \n<\/pre><\/div>\n\n\n<p>You can start the import as follows. Ensure that the entire IG archive is available and replace <code>&lt;my-account><\/code> with your mastodon account name:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nRAILS_ENV=production bin\/tootctl ig_import import ig-json\/content\/posts_1.json\n&amp;lt;my-account&gt;\n<\/pre><\/div>\n\n\n<p>You should see stdout output similar to <code>Created status with ID xxx<\/code>. The script completed successfully if its return code is 0  (verify with <code>echo $?<\/code> right after the script completed).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Chunking long posts<\/h2>\n\n\n\n<p>I discovered that some of my IG posts were too long to fit into a single toot (500 characters limit on most Mastodon instances), so some posts had to be split up <a href=\"https:\/\/social.vdna.be\/@floriscycles\/100937354141359320\">into multiple toots<\/a>. Posting all the media on the first toot and posting subsequent toots as replies, it doesn&#8217;t look too bad (see screenshot below). It does make the profile page a bit longer however.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The result<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/vdna.be\/site\/wp-content\/uploads\/2021\/06\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"521\" height=\"1024\" src=\"https:\/\/vdna.be\/site\/wp-content\/uploads\/2021\/06\/image-1-521x1024.png\" alt=\"\" class=\"wp-image-475\" srcset=\"https:\/\/vdna.be\/site\/wp-content\/uploads\/2021\/06\/image-1-521x1024.png 521w, https:\/\/vdna.be\/site\/wp-content\/uploads\/2021\/06\/image-1-153x300.png 153w, https:\/\/vdna.be\/site\/wp-content\/uploads\/2021\/06\/image-1.png 663w\" sizes=\"auto, (max-width: 521px) 100vw, 521px\" \/><\/a><figcaption>Long posts are split into multiple toots.<\/figcaption><\/figure>\n\n\n\n<p>All in all, I&#8217;m satisfied with the outcome. The toot view doesn&#8217;t indicate that more than four media files are attached to a toot though. Also, as this is implemented as an admin script it is cumbersome to setup, requiring admin and CLI access to the Mastodon instance. Suggestions on making this more accessible are welcomed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For some time I&#8217;ve wanted to move the Instagram account of floriscycles.com to my Mastodon instance and delete the instagram account. Earlier this year I did just that and I&#8217;d like to share my method in case someone would want to move their account(s). Note: while PixelFed is better suited to hosting media centered content,&hellip; <a class=\"more-link\" href=\"https:\/\/vdna.be\/site\/index.php\/2021\/06\/moving-from-instagram-to-mastodon\/\">Continue reading <span class=\"screen-reader-text\">Moving from Instagram to Mastodon<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-473","post","type-post","status-publish","format-standard","hentry","category-programming","category-software","entry"],"_links":{"self":[{"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/posts\/473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/comments?post=473"}],"version-history":[{"count":1,"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/posts\/473\/revisions"}],"predecessor-version":[{"id":476,"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/posts\/473\/revisions\/476"}],"wp:attachment":[{"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/media?parent=473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/categories?post=473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vdna.be\/site\/index.php\/wp-json\/wp\/v2\/tags?post=473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}