#!/bin/bash
d="09"
cl=(AR AU BR CA DE ES FR GB IT MX NL US)
token="${TOKEN}"
for c in "${cl[@]}"
do
  flnm="streams_202012${d}_${c}"
  u="curl --location --request GET 'https://provider-api.spotify.com/v1/analytics/sonybmgmusicentertainment/enhanced/streams/2020/12/$d/$c' --header 'Authorization: Bearer ${token}' --output ${flnm}.gz"
  echo $u
  eval $u
done
for c in "${cl[@]}"
do
  flnm="streams_202012${d}_${c}"
  eval "aws s3 cp ${flnm}.gz s3://sme-data-archive/spotify/streams/v4/report_date=2020-12-${d}/report_licensor=sme/"
  eval "gzip -dv ${flnm}.gz"
  eval "aws s3 cp ${flnm} s3://sme-data-decompressed/spotify/streams/v4/report_date=2020-12-${d}/report_licensor=sme/${flnm}.json && rm ${flnm}"
done
