Distribution of the supporting files in notes

This commit is contained in:
Ken Fallon 2024-12-27 16:01:54 +01:00
parent e3e458b2d2
commit bf0a1f056d
2 changed files with 39 additions and 9 deletions

View File

@ -5,7 +5,6 @@
git_dir="$HOME/tmp/hpr/hpr_generator/sourcecode"
if [ ! -d "${git_dir}/.git" ]
then
#git clone gitea@repo.anhonesthost.net:rho_n/hpr_generator.git "${git_dir}"
git clone gitea@repo.anhonesthost.net:HPR/hpr_generator.git "${git_dir}"
fi

View File

@ -33,7 +33,7 @@ echo "Processing the next HPR Show in the queue"
#
# Replaced METADATA_PROCESSED with SHOW_SUBMITTED
response=$( curl --silent --netrc-file ${HOME}/.netrc "https://hub.hackerpublicradio.org/cms/status.php" | \
grep 'SHOW_SUBMITTED' | \
grep ',SHOW_SUBMITTED,' | \
head -1 | \
sed 's/,/ /g' )
@ -55,6 +55,7 @@ email_unpadded="$( echo $email | sed 's/.nospam@nospam./@/g' )"
upload_dir="/home/hpr/upload/${timestamp_epoc}_${ep_num}_${ep_date}_${key}"
source_dir="hpr:${upload_dir}"
publish_dir="hpr:www/eps/hpr${ep_num}"
dest_dir="${timestamp_epoc}_${ep_num}_${ep_date}_${key}"
ssh hpr -t "detox -v ${upload_dir}/"
@ -116,12 +117,11 @@ fi
sed "s#>#>\n#g" "${shownotes_html}" | sponge "${shownotes_html}"
# Extract Images
## TODO Temp fix until https://repo.anhonesthost.net/HPR/hpr-tools/issues/3
image_count="1"
touch ${shownotes_html%.*}_combined.html
for image in $( grep --color=never -Po 'data:image/[^;]*;base64,\K[a-zA-Z0-9+/=]*' "${shownotes_html}" )
for image in $( grep --color=never --perl-regexp --only-matching 'data:image/[^;]*;base64,\K[a-zA-Z0-9+/=]*' "${shownotes_html}" )
do
this_image="${processing_dir}/${dest_dir}/hpr${ep_num}_${image_count}"
echo -n "$image" | base64 -di > ${this_image}
@ -135,9 +135,30 @@ do
((image_count=image_count+1))
done
for image in $( grep --color=never --perl-regexp --only-matching '<img.*src.*http.*>' "${shownotes_html}" | awk -F 'src=' '{print $2}' | awk -F '"' '{print $2}' )
do
this_image="${processing_dir}/${dest_dir}/hpr${ep_num}_${image_count}"
wget "${image}" --output-document=${this_image}
this_ext="$( file --mime-type ${this_image} | awk -F '/' '{print $NF}' )"
if [ ! -e "${this_image}.${this_ext}" ]
then
mv -v "${this_image%.*}" "${this_image}.${this_ext}"
fi
this_width="$( mediainfo "${this_image}.${this_ext}" | grep Width | awk -F ': | pixels' '{print $2}' | sed 's/ //g' )"
if [ "${this_width}" -gt "400" ]
then
magick "${this_image}.${this_ext}" -resize 400x "${this_image}_tn.${this_ext}"
fi
((image_count=image_count+1))
done
## TODO End Temp fix until https://repo.anhonesthost.net/HPR/hpr-tools/issues/3
ls -al "${processing_dir}/${dest_dir}/"
## Manually edit the shownotes to fix issues
kate "${shownotes_json}" >/dev/null 2>&1 &
kate "${shownotes_html}" >/dev/null 2>&1 &
# librewolf "${shownotes_html}" >/dev/null 2>&1 &
seamonkey "${shownotes_html}" >/dev/null 2>&1 &
# bluefish "${shownotes_html}" >/dev/null 2>&1 &
@ -226,7 +247,6 @@ tags="$( jq --raw-output '.episode.Tags' ${shownotes_json} | jq --slurp --raw-in
host_license=$( jq --raw-output '.host.Host_License' ${shownotes_json} | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' )
host_profile=$( jq --raw-output '.host.Host_Profile' ${shownotes_json} | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' )
# notes="$( grep -P ":\t" ${shownotes_txt} | awk -F "\t" '{print $2}' )"
notes="$( cat "${shownotes_html}" | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' )"
if [ $# -gt 0 ]
@ -251,7 +271,6 @@ then
exit 15
fi
###################
# Post show to HPR
#
@ -299,10 +318,22 @@ echo "{
\"notes\": \"${notes}\"
}" | tee "${post_show_json}"
echo "INFO: Uploading hpr${ep_num} from ${email_unpadded}"
echo "INFO: Uploading processed files to \"${processing_dir}/${dest_dir}/\""
echo ""
echo rsync -ave ssh --partial --progress ${processing_dir}/${dest_dir}/ ${source_dir}/
rsync -ave ssh --partial --progress ${processing_dir}/${dest_dir}/ ${source_dir}/
echo ""
curl --netrc --include --request POST "https://hub.hackerpublicradio.org/cms/add_show_json.php" --header "Content-Type: application/json" --data-binary "@${post_show_json}"
if [ "$( curl --silent --write-out '%{http_code}' http://hackerpublicradio.org/say.php?id=${ep_num} --output /dev/null )" != 200 ]
then
echo "ERROR: The Episode hpr${ep_num} has not been posted"
exit 16
fi
echo "INFO: Uploading completed files to \"${publish_dir}/\""
echo ""
echo "rsync -ave ssh --partial --progress \"${processing_dir}/${dest_dir}/hpr${ep_num}\"* \"${publish_dir}/\""
rsync -ave ssh --partial --progress "${processing_dir}/${dest_dir}/hpr${ep_num}"* "${publish_dir}/"
echo ""