Instagram Gallery
Since instagram is a part of Meta, and I’m less of a fan of that particular company than I used to be - I decided to move the contents of my account (@moosepaints) here.
It wasn’t as hard as you’d think with the help of gallery-dl and a bit of /bin/bash
nonsense to rework the dumped metadata into a markdown-y format - you’ll find a vague bash script with instructions at the bottom of the page.
#!/bin/bash
# Once you've used gallery-dl to pull your instagram account down to your local machine (cookie auth recommended, you'll need to have logged in via your primary/default browser) you can run the following to create markdown files for each based on the post content and the first three hashtags it finds. Ugly but worked for me :)
# Cheeky function for readability
define(){
IFS=$'\n' read -r -d '' ${1} || true;
}
# Create a sort of backup dir
mkdir -p processed
for FILE in $(find . -type f | xargs); do
echo "🗄️Processing ${FILE}...."
# gallery-dl uses a 'shortname' which is just an ugly but unique string
SHORT=$(basename ${FILE}| cut -d"." -f1)
CONTENT=$(while read line; do
for word in $line; do echo $word
done
done < ${SHORT}.md
)
HASHTAGS=$(echo "${CONTENT[0]}" | grep '#' | xargs)
TITLE=$(echo ${HASHTAGS} | cut -d" " -f1-3)
FILENERM=$(echo ${TITLE} | sed 's:#::g' | tr ' ' '-')
DATU=$(date +%Y-%m-%d)
# This lil heredoc is used to create our markdown
define PAYLOAD <<-EOF
---
layout: post
title: "${TITLE}"
date: ${DATU}
categories: insta
---
{:class="framed"}
$(cat ${FILE})
EOF
echo "${PAYLOAD}" > processed/${DATU}-${FILENERM}.md
done