#!/bin/bash
CSV_FILE="${1:-tricks.csv}"
make_video_cell() {
local field="$1"
if [[ -n "$field" ]]; then
echo "
"
IFS=';' read -ra files <<< "$field"
for f in "${files[@]}"; do
f_trimmed=$(echo "$f" | xargs)
echo " "
done
echo " | "
else
echo " | "
fi
}
make_demo_cell() {
local field="$1"
if [[ -n "$field" ]]; then
echo " "
IFS=';' read -ra files <<< "$field"
for f in "${files[@]}"; do
f_trimmed=$(echo "$f" | xargs)
echo " demo "
done
echo " | "
else
echo " | "
fi
}
make_montage_cell() {
local montage="$1"
if [ -z "$montage" ]; then
echo " | "
return
fi
case "$montage" in
'Cowboy Teebop') montage_url='https://www.youtube.com/watch?v=eJgiPbio9BY' ;;
'Tee Jams') montage_url='https://www.youtube.com/watch?v=ReoM0rVXduQ' ;;
'On Noby Street') montage_url='https://www.youtube.com/watch?v=lxVu5XX9Rmk' ;;
'Any Trickers') montage_url='https://www.youtube.com/watch?v=u2CbuvmiXCc' ;;
*) echo "ERROR: invalid montage name '$montage'" >&2; exit 1 ;;
esac
echo " $montage | "
}
cat <<'EOF'
EOF
IFS=',' read -r -a headers < "$CSV_FILE"
for header in "${headers[@]}"; do
echo " | $header | "
done
echo "
"
while IFS=',' read -r name players train_videos ingame_videos demos montage; do
[[ -z "$name" ]] && continue
echo " "
echo " | $name | "
players_html=$(echo "$players" | sed 's/;/,
/g')
echo " $players_html | "
make_video_cell "$train_videos"
make_video_cell "$ingame_videos"
make_demo_cell "$demos"
make_montage_cell "$montage"
echo "
"
done < <(tail -n +2 "$CSV_FILE")
cat <<'EOF'
EOF