Add two untracked scripts
This commit is contained in:
parent
a8897cc793
commit
1d14028ba0
51
bin/hpr-assets.bash
Executable file
51
bin/hpr-assets.bash
Executable file
@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
file_dir="/var/IA/uploads"
|
||||
|
||||
#$allowed_extensions = "flac", "opus", "ogg", "spx", "mp3", "jpg", "png", "json", "srt", "tsv", "txt", "vtt";
|
||||
|
||||
if [ -d "${file_dir}" ]
|
||||
then
|
||||
cd "${file_dir}"
|
||||
echo '"episode_id","filename","extension","size", "sha1sum", "mime_type", "file_type"' | tee "${file_dir}/assets.csv"
|
||||
find "${file_dir}" -type f \( -iname "hpr*.wav" -o -iname "hpr*.flac" -o -iname "hpr*.opus" -o -iname "hpr*.ogg" -o -iname "hpr*.spx" -o -iname "hpr*.mp3" -o -iname "hpr*.jpg" -o -iname "hpr*.png" -o -iname "hpr*.json" -o -iname "hpr*.srt" -o -iname "hpr*.tsv" -o -iname "hpr*.txt" -o -iname "hpr*.vtt" \) | while read this_file
|
||||
do
|
||||
this_file_basename=$( basename "${this_file}" )
|
||||
this_file_dirname=$( dirname "${this_file}" )
|
||||
this_file_prefix="${this_file_basename%.*}"
|
||||
this_file_extension="${this_file_basename##*.}"
|
||||
if [ "$( echo "${this_file_prefix}" | grep -Ec '^hpr[0-9]{4}' )" -ne "1" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
this_file_episode_id="$( echo "${this_file_prefix}" | sed 's/hpr//g' | awk -F '_' '{print $1}' )"
|
||||
if [ "${this_file_episode_id}" -lt "1" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "${this_file_episode_id}" -gt "99999" ]
|
||||
then
|
||||
continue
|
||||
fi
|
||||
|
||||
this_file_size="$( ls -al "${this_file}" | awk '{print $5}' )"
|
||||
this_file_sha1sum="$( sha1sum "${this_file}" | awk '{print $1}' )"
|
||||
this_file_mime_type=$( file --dereference --brief --mime "${this_file}" )
|
||||
this_file_file_type=$( file --dereference --brief "${this_file}" )
|
||||
|
||||
echo "${this_file_episode_id},\"${this_file_basename}\",\"${this_file_extension}\",\"${this_file_size}\",\"${this_file_sha1sum}\",\"${this_file_mime_type}\",\"${this_file_file_type}\"" | tee --append "${file_dir}/assets.csv"
|
||||
|
||||
done
|
||||
fi
|
||||
|
||||
if [ -s "${file_dir}/assets.csv" ]
|
||||
then
|
||||
cat "${file_dir}/assets.csv" | csvtojson | jq '{"assets":[.[]]}' | tee "${file_dir}/assets.json"
|
||||
fi
|
||||
|
||||
if [ -s "${file_dir}/assets.json" ]
|
||||
then
|
||||
curl --netrc-file $HOME/.netrc --verbose --request POST https://hub.hackerpublicradio.org/cms/assets.php --data-ascii @"${file_dir}/assets.json" --header "Content-Type: application/json"
|
||||
fi
|
4
bin/hpr_ccdn_stats.bash
Normal file
4
bin/hpr_ccdn_stats.bash
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
yesterday="$( \date -u +%Y-%m-%d -d yesterday)"
|
||||
echo -e "${yesterday}\t$( grep -Ec "${yesterday}T.*Sending request to" /home/hpr/logs/naughty-ip.txt )" >> /home/hpr/hub/hpr_ccdn_stats.tsv
|
Loading…
Reference in New Issue
Block a user