Parse start year information.

This commit is contained in:
Dominik Pantůček 2023-05-25 15:43:44 +02:00
parent 2546f40871
commit 474c5a06fa

View file

@ -105,33 +105,40 @@ log "$0" ======== started ========
# two non-whitespace strings. The rest of each line is ignored. There
# must be no leading whitespace.
while read accnt; do
# Extract account number and Fio token
# Extract account number, Fio token and starting year
ACCNO=${accnt%% *}
accrest=${accnt#* }
APIKEY=${accrest%% *}
accrest2=${accrest#* }
YEAR=${accrest2%% *}
# Log action
log "Processing account $ACCNO"
# Fetch CSV from bank
CSVNAME="$BANK_DIR/$ACCNO.csv"
for i in `seq 1 3` ; do
if wget -q "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" -O "$CSVNAME.tmp" ; then
if [ -s "$CSVNAME.tmp" ] ; then
log Download OK
cp "$CSVNAME" "$CSVNAME.old"
mv "$CSVNAME.tmp" "$CSVNAME"
log Finished
break
# Check starting year before attempting partial downloads
if [ -z "$YEAR" ] ; then
log "Missing start year for account $ACCNO"
else
# Log action
log "Processing account $ACCNO starting $YEAR"
# Fetch CSV from bank
CSVNAME="$BANK_DIR/$ACCNO.csv"
for i in `seq 1 3` ; do
if wget -q "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" -O "$CSVNAME.tmp" ; then
if [ -s "$CSVNAME.tmp" ] ; then
log Download OK
cp "$CSVNAME" "$CSVNAME.old"
mv "$CSVNAME.tmp" "$CSVNAME"
log Finished
break
else
log Download successfull but empty or non-existing result.
log Retrying in 5 s.
fi
else
log Download successfull but empty or non-existing result.
log Retrying in 5 s.
log Failed download, retrying in 5 s.
sleep 5
fi
else
log Failed download, retrying in 5 s.
sleep 5
fi
done
done
fi
done < "$APIKEYS_FILE"
# Mark