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

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

gids=(445672652)
csv_names=("railtypes.csv")

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]}" "$gurl_full"
done

# Generate lang
cp "$CUR_DIR/lang/english.base" "$CUR_DIR/lang/english.lng"
"$CUR_DIR/main.py" lang >> "$CUR_DIR/lang/english.lng"
