Adding stats and automating update. Check for url in uploads

This commit is contained in:
2024-02-14 15:11:25 +01:00
parent da88c1afc4
commit c44a6f0f04
3 changed files with 88 additions and 29 deletions

View File

@@ -16,6 +16,16 @@ do
echo "ERROR: \"${shownotes}\" not found"
exit 1
fi
metadata_url="$( jq --raw-output '.metadata.url' "${shownotes}" )"
if [ -n "${metadata_url}" ]
then
save_name=$( basename "${metadata_url}" | sed -e 's/[^A-Za-z0-9.]/_/g' -e 's/__/_/g' )
if [ ! -s "${reserve_show_dir}/${save_name}" ]
then
echo "ERROR: \"${metadata_url}\" needs to be downloaded as \"${reserve_show_dir}/${save_name}\""
exit 1
fi
fi
Host_ID="$( jq --raw-output '.host.Host_ID' "${shownotes}" )"
Host_Name="$( jq --raw-output '.host.Host_Name' "${shownotes}" | sed -e 's/[^A-Za-z0-9]/_/g' -e 's/__/_/g' )"
Key="$( jq --raw-output '.metadata.Key' "${shownotes}" )"

8
bin/update-stats.bash Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
hub_dir="/home/hpr/hub"
for format in txt csv json xml
do
curl --silent --netrc-file /home/hpr/.netrc https://hub.hackerpublicradio.org/cms/stats.php?format=${format} --output ${hub_dir}/stats.${format}
done