#!/bin/bash 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- ) 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- ) 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 -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 -i 's/\[platform img\]//' "$SCRIPT_DIR/credit2.html" else echo "who?!" 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" rm cs1.png cs2.png "$SCRIPT_DIR/credit2.html" done < $1