#!/bin/bash echo $1 SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) WORKING=$PWD i=0 while read p || [[ -n $p ]]; do IFS=';' read -ra FIELDS <<< "$p" i=$(( $i + 1 )) echo "i: $i" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 2- ) echo "field1: ${FIELDS[1]}" FIELDS[2]=$( echo "${FIELDS[2]}" | cut -c 2- | sed 's/\//\\\//g') echo "field2: ${FIELDS[2]}" sed 's/\[num\]/['"$i"']/' "$SCRIPT_DIR/credit.html" > "$SCRIPT_DIR/credit2.html" echo "first sed, done" sed -i 's/\[title\]/'"${FIELDS[2]}"'/' "$SCRIPT_DIR/credit2.html" echo "2nd sed, done" if [[ "${FIELDS[1]}" =~ ^"[yt]/" ]] then echo "tubelike!" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 6- | sed 's/\//\\\//g') echo "${FIELDS[1]}" sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" elif [[ "${FIELDS[1]}" =~ ^"[vimeo]/" ]] then echo "vimeous!" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 9- | sed 's/\//\\\//g') sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" elif [[ "${FIELDS[1]}" =~ ^"[fandom]/" ]] then echo "fandom wiki!" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 10- | sed 's/\//\\\//g') sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" elif [[ "${FIELDS[1]}" =~ ^"[github]/" ]] then echo "github!" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 10- | sed 's/\//\\\//g') sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" elif [[ "${FIELDS[1]}" =~ ^"[mastodon]/" ]] then echo "mastodon!" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 12- | sed 's/\//\\\//g') sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" elif [[ "${FIELDS[1]}" =~ ^"[twitch]/" ]] then echo "twitch!" FIELDS[1]=$( echo "${FIELDS[1]}" | cut -c 10- | sed 's/\//\\\//g') sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" else echo "who?!" FIELDS[1]=$( echo "${FIELDS[1]}" | sed 's/\//\\\//g') sed -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" fi echo "setting author to ${FIELDS[1]}!" sed -i 's/\[author\]/'"${FIELDS[1]}"'/' "$SCRIPT_DIR/credit2.html" echo "file:///$SCRIPT_DIR/credit2.html" firefox -P screenshitter --headless --window-size 3840,2160 --screenshot "$WORKING/cs1.png" "file:///$SCRIPT_DIR/credit2.html" convert "cs1.png" -fuzz 12% -transparent "#00ff00" "cs2.png" #convert cs2.png -trim "c$i.png" # blender wants to scale to fit, # and if you want a 1:1 scale image i don't know what the *fuck* it's doing with an origin point. convert cs2.png "c$i.png" rm cs1.png cs2.png "$SCRIPT_DIR/credit2.html" done < "$1"