Parse start year information.
This commit is contained in:
parent
2546f40871
commit
474c5a06fa
1 changed files with 28 additions and 21 deletions
49
fetch_fio.sh
49
fetch_fio.sh
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue