#!/bin/bash
# Script to fetch csvs from goole spreadsheets
set -e
CUR_DIR="$(dirname $(realpath $0))"
csv_path="$CUR_DIR/csv"

gkey='1RY5RsPhifOriB_5qa4hsxiYHAX7W55Ma1MWhiVkXKwE'
gurl_nogid="https://docs.google.com/spreadsheets/d/${gkey}/export?gid=GID&format=csv"

gids=(1 2 3 4 5 6 7 11 15 17)
csv_names=("steam" "diesel" "dmu" "emu" "electric" "wagon" "coach" "metro" "cargos" "strings")

echo "Fetching csvs from big brother..."
for ((i = 0; i < ${#gids[@]}; i++)); do
    gurl_full=$(echo $gurl_nogid | sed -r "s/GID/${gids[$i]}/")
    wget -q --output-document="$csv_path/${csv_names[$i]}.csv" "$gurl_full"
done
$CUR_DIR/gen_lang_src.py
echo -e "\nAll done, base language generated from source csvs."
