2026-04-05 16:35:17 +02:00
#!/usr/bin/env bash
2026-11-08 18:27:09 +01:00
# https://brycebeattie.com/files/tts/
2026-11-21 15:15:52 +01:00
#
# https://github.com/OHF-Voice/piper1-gpl
# A fast and local neural text-to-speech engine that embeds espeak-ng for phonemization.
# GPL-3.0 license
#
# https://github.com/espeak-ng/espeak-ng
# The eSpeak NG is a compact open source software text-to-speech synthesizer for Linux, Windows, Android and other operating systems.
# It supports more than 100 languages and accents. It is based on the eSpeak engine created by Jonathan Duddington.
# Licenses GPL-3.0, Apache-2.0, BSD-2-Clause
#
# LJSpeech (high) US English female voice. Single speaker.
# Trained from scratch for 2000 epochs on high quality settings using the LJ Speech dataset.
# I reencoded the recordings to a bit rate of 22050 Hz so it would match other voices released for Piper TTS.
# License: public domain
#
# https://keithito.com/LJ-Speech-Dataset/
# This is a public domain speech dataset consisting of 13,100 short audio clips of a single speaker reading passages from 7 non-fiction books.
# A transcription is provided for each clip. Clips vary in length from 1 to 10 seconds and have a total length of approximately 24 hours.
# The texts were published between 1884 and 1964, and are in the public domain.
# The audio was recorded in 2016-17 by the LibriVox project and is also in the public domain.
#
piper_voice = "/opt/bin/piper/piper/piper-voices/en/en_US/ljspeech/high/en_US-ljspeech-high.onnx"
function post_show_to_hpr_db() {
echo_debug "Retrieving information for hpr ${ ep_num } for release on ${ ep_date } "
IFS = '→' read -r ep_num ep_date title duration summary hostid series_id explicit license tags <<< " $( sqlite3 -separator '→' " ${ hpr_db } " "SELECT id, date, title, duration, summary, hostid, series, explicit, license, tags FROM eps WHERE eps.id = \" ${ ep_num } \" AND date = \" ${ ep_date } \" LIMIT 1;" ) "
echo_debug "Posting the show to the HPR DB. post_show_to_hpr_db()"
if [ ! -s " ${ shownotes_html_edited } " ]
then
echo_error "Failed to find the extracted shownote html file \" ${ shownotes_html_edited } \""
fi
notes = " $( cat " ${ shownotes_html_edited } " | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' ) "
title_encoded = " $( echo " ${ title } " | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' ) "
summary_encoded = " $( echo " ${ summary } " | jq --slurp --raw-input @uri | sed -e 's/%0A"$//g' -e 's/^"//g' ) "
post_show_json = " ${ working_dir } /post_show.json"
echo "{
\"ep_num\": \" ${ ep_num } \",
\"ep_date\": \" ${ ep_date } \",
\"title\": \" ${ title_encoded } \",
\"duration\": \" ${ duration } \",
\"summary\": \" ${ summary_encoded } \",
\"hostid\": \" ${ hostid } \",
\"series_id\": \" ${ series_id } \",
\"explicit\": \" ${ explicit } \",
\"episode_license\": \" ${ license } \",
\"tags\": \" ${ tags } \",
\"notes\": \" ${ notes } \"
}" > " ${ post_show_json } "
if [ $? -ne 0 ]
then
echo_error "The file \" ${ post_show_json } \" is not valid json."
fi
2026-11-08 18:27:09 +01:00
2026-11-21 15:15:52 +01:00
jq 'del(.notes)' post_show.json
2026-11-08 18:27:09 +01:00
2026-11-21 15:15:52 +01:00
curl --netrc --show-headers --request POST "https://hub.hackerpublicradio.org/cms/update_show_json.php" --header "Content-Type: application/json" --data-binary "@ ${ post_show_json } "
}
2026-11-08 18:27:09 +01:00
2026-04-05 16:35:17 +02:00
############################################################################################
# Update db
source settings $1
2026-11-08 18:27:09 +01:00
git_dir = " $HOME /tmp/hpr/hpr_generator"
2026-11-21 15:15:52 +01:00
hpr_db = " ${ git_dir } /hpr.db"
hpr_sql = " ${ git_dir } /hpr.sql"
2026-04-05 16:35:17 +02:00
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
if [ ! -d " ${ git_dir } " ]
then
echo_error "The git dir \" ${ git_dir } \" is missing"
fi
cd " ${ git_dir } "
git pull
2026-11-21 15:15:52 +01:00
ssh hpr -t "/docker/users/hpr/userfiles/sql/hpr_db_backup.bash"
remote_hpr_sql_md5sum = " $( ssh hpr -t "md5sum /docker/users/hpr/userfiles/sql/hpr.sql" 2>& 1 | grep /docker/users/hpr/userfiles/sql/hpr.sql | awk '{print $1}' ) "
hpr_sql_md5sum = " $( md5sum " ${ hpr_sql } " | awk '{print $1}' ) "
2026-04-05 16:35:17 +02:00
2026-11-21 15:15:52 +01:00
if [ " ${ remote_hpr_sql_md5sum } " != " ${ hpr_sql_md5sum } " ]
then
echo_debug "The hpr.sql file changed, downloading new version"
#$HOME/tmp/hpr/hpr_generator/utils/update-hpr-db.sh
./utils/update-hpr-db.sh
if [ $? -ne 0 ]
then
echo 'Terminating...' >& 2
exit 1
fi
fi
2026-04-05 16:35:17 +02:00
if [[ ! -s " ${ hpr_db } " || -z " ${ hpr_db } " ]]
then
echo_error "The \"hpr_db\" variable/file is missing."
fi
if [ " $( file --brief --mime-type " ${ hpr_db } " | grep --count 'application/vnd.sqlite3' ) " -ne "1" ]
then
echo_error "The \"hpr_db\" variable has not a valid \"application/vnd.sqlite3\" mime type."
fi
############################################################################################
# Get previous show info
2026-05-13 12:56:34 +02:00
row = $( sqlite3 " ${ hpr_db } " "
2026-04-05 16:35:17 +02:00
SELECT notes
FROM eps
WHERE duration > 0
AND series = 47
ORDER BY date DESC
LIMIT 1;
" )
2026-11-08 18:27:09 +01:00
# <!-- HPRCN:month=2026-10,latest_comment=4952,latest_host=464,latest_episode=4760 -->
2026-05-13 12:56:34 +02:00
2026-04-05 16:35:17 +02:00
eval $(
echo " $row " |
grep -o '<!-- HPRCN:[^>]*-->' |
sed -E 's/<!-- HPRCN:(.*) -->/\1/' |
tr ',' '\n'
)
2026-11-08 18:27:09 +01:00
previous_month = " ${ month } "
this_month = " $( \d ate --date " ${ previous_month } -01 + 1 month" "+%Y-%m" ) "
2026-05-13 12:56:34 +02:00
previous_cn_latest_comment = " ${ latest_comment } "
previous_cn_latest_episode = " ${ latest_episode } "
2026-11-08 18:27:09 +01:00
previous_latest_host = " ${ latest_host } "
end_of_month_episode_date = " $( \d ate --date " ${ this_month } -01 + 1 month - 1 day" "+%Y-%m-%d" ) "
echo_debug "The last show month was for ${ previous_month } , and this month is ${ this_month } , previous_cn_latest_comment: ${ previous_cn_latest_comment } , latest_host: ${ previous_latest_host } , and previous_cn_latest_episode: ${ previous_cn_latest_episode } , end_of_month_episode_date: ${ end_of_month_episode_date } "
############################################################################################
# Get last show info
IFS = '|' read -r end_of_month_episode_number <<< " $( sqlite3 " ${ hpr_db } " "
2026-11-21 15:15:52 +01:00
SELECT MAX(id) AS end_of_month_episode_number
FROM eps
2026-11-08 18:27:09 +01:00
WHERE date <= \" ${ end_of_month_episode_date } \"
LIMIT 1;
" ) "
echo_debug "Last episode this month is hpr ${ end_of_month_episode_number } released on ${ end_of_month_episode_date } "
2026-04-05 16:35:17 +02:00
############################################################################################
# Get next show info
this_month = $( \d ate --date= " ${ month } -01 +1 month" +%Y-%m )
2026-11-21 15:15:52 +01:00
IFS = '|' read -r ep_num ep_date <<< " $( sqlite3 " ${ hpr_db } " "
2026-04-05 16:35:17 +02:00
SELECT id, date
FROM eps
WHERE duration = 0
AND series = 47
ORDER BY date ASC
LIMIT 1;
" ) "
2026-11-21 15:15:52 +01:00
echo_debug "This is going to be hpr ${ ep_num } for release on ${ ep_date } "
2026-04-05 16:35:17 +02:00
2026-11-21 15:15:52 +01:00
working_dir = " $HOME /processing/x_ ${ ep_num } _ ${ ep_date } _x"
if [ ! -d " ${ working_dir } " ]
2026-04-05 16:35:17 +02:00
then
2026-11-21 15:15:52 +01:00
mkdir -vp " ${ working_dir } "
2026-04-05 16:35:17 +02:00
fi
2026-11-21 15:15:52 +01:00
echo_debug "The episode dir is \" ${ working_dir } \""
2026-04-05 16:35:17 +02:00
2026-11-21 15:15:52 +01:00
shownotes_html = " ${ working_dir } /shownotes.html"
2026-11-08 18:27:09 +01:00
if [ -e " ${ shownotes_html } " ]
then
rm -v " ${ shownotes_html } "
fi
shownotes_html_edited = " ${ shownotes_html %.* } " _edited.html
if [ -e " ${ shownotes_html_edited } " ]
then
rm -v " ${ shownotes_html_edited } "
fi
2026-11-21 15:15:52 +01:00
shownotes_recordings_dir = " ${ working_dir } /Recordings"
comment_script_md = " ${ working_dir } /script.md"
2026-11-08 18:27:09 +01:00
if [ -e " ${ comment_script_md } " ]
then
rm -v " ${ comment_script_md } "
fi
if [ ! -d " ${ shownotes_recordings_dir } " ]
then
mkdir -vp " ${ shownotes_recordings_dir } "
fi
2026-04-05 16:35:17 +02:00
2026-11-21 15:15:52 +01:00
############################################################################################
# Call to action
echo "<h2>Recording Comments</h2>
<p>We would love it if you could assist with the recording of comments for this episode.</p>
<ol>
<li>Install <a href=\"https://gitlab.com/norrist/solocast\">https://gitlab.com/norrist/solocast</a></li>
<li>Install <a href=\"https://syncthing.net/\">Syncthing</a></li>
<li>Contact the <a href=\"https://hackerpublicradio.org/about.html#contact\">Janitors</a> to get access to the shared folder for completed Recordings</li>
</ol>
<p>Selecting <em>solocast record</em> will allow you to record a comment or post, which syncthing will syncronise to the rest of the team.</p>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
############################################################################################
# Add New hosts to shownotes
2026-05-13 12:56:34 +02:00
results = $( sqlite3 " ${ hpr_db } " "SELECT hostid, host FROM hosts WHERE hostid > ${ latest_host } ;" )
2026-04-05 16:35:17 +02:00
2026-11-08 18:27:09 +01:00
echo "<h2>New hosts</h2>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<p>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
if [ -z " ${ results } " ]
then
2026-11-08 18:27:09 +01:00
echo "There were no new hosts this month." | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
newest_host = " ${ latest_host } "
else
2026-11-08 18:27:09 +01:00
echo "Welcome to our new hosts: <br>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
while IFS = "|" read -r hostid host
do
newest_host = " ${ hostid } "
2026-11-08 18:27:09 +01:00
echo "<li><a href=\"https://hackerpublicradio.org/correspondents/ ${ hostid } .html\" target=\"_blank\"> ${ host } </a></li>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
done <<< " ${ results } "
2026-11-08 18:27:09 +01:00
echo "</ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
fi
2026-11-08 18:27:09 +01:00
echo "</p>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
############################################################################################
# Add Last Month's Shows to shownotes
2026-05-13 12:56:34 +02:00
results = $( sqlite3 -separator '→' " ${ hpr_db } " "
2026-04-05 16:35:17 +02:00
SELECT eps.id, hosts.host, eps.title, eps.date, eps.hostid
FROM eps, hosts
2026-05-13 12:56:34 +02:00
WHERE eps.id > ${ previous_cn_latest_episode }
2026-04-05 16:35:17 +02:00
AND eps.date LIKE \" ${ this_month } %\"
AND eps.valid = 1
AND eps.hostid = hosts.hostid;
" )
2026-11-08 18:27:09 +01:00
echo "<h2>Last Month's Shows</h2>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
# [%# The id 't01' is in the HPR CSS but might give trouble on the IA -%]
2026-11-08 18:27:09 +01:00
echo "<table id=\"t01\">" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<tr>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<th>Id</th>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<th>Day</th>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<th>Date</th>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<th>Title</th>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<th>Host</th>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "</tr>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
if [ -z " ${ results } " ]
then
echo_error "There were no shows found for this month."
else
2026-11-21 15:15:52 +01:00
while IFS = "→" read -r eps_id host title this_ep_date hostid
2026-04-05 16:35:17 +02:00
do
2026-11-08 18:27:09 +01:00
echo "<tr>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<td><strong><a href=\"https://hackerpublicradio.org/eps/hpr ${ eps_id } /index.html\" target=\"_blank\"> ${ eps_id } </a></strong></td>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-21 15:15:52 +01:00
echo "<td> $( \d ate --date= ${ this_ep_date } +%a ) </td>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<td class=\"shrink\"> ${ this_ep_date } </td>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-08 18:27:09 +01:00
echo "<td><a href=\"https://hackerpublicradio.org/eps/hpr ${ eps_id } /index.html\" target=\"_blank\"> ${ title } </a></td>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<td><a href=\"https://hackerpublicradio.org/correspondents/ ${ hostid } .html\" target=\"_blank\"> ${ host } </a></td>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
latest_episode = ${ eps_id }
2026-11-08 18:27:09 +01:00
echo "</tr>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
done <<< " ${ results } "
fi
2026-11-08 18:27:09 +01:00
echo "</table>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
############################################################################################
# Add Comments to shownotes
function render_comments() {
results = ${ 1 }
if [ -z " ${ results } " ]
then
echo_error "There were no comments found for this month."
else
this_comment = "0"
open_line = "0"
2026-11-08 18:27:09 +01:00
echo "<ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-21 15:15:52 +01:00
while IFS = "→" read -r comments_id comments_eps_id this_ep_date eps_title hosts_host hosts_hostid comments_comment_author_name comments_comment_timestamp comments_comment_title
2026-04-05 16:35:17 +02:00
do
2026-11-08 18:27:09 +01:00
2026-11-21 15:15:52 +01:00
echo "# Comment ${ comments_id } Vvvvvvvvvvvvvvvvvvvvvvvvvvvv" >> " ${ comment_script_md } "
echo " ${ eps_title } by ${ hosts_host } " >> " ${ comment_script_md } "
echo "- https://hackerpublicradio.org/eps/hpr ${ comments_eps_id } /index.html#comment_ ${ comments_id } ( ${ this_ep_date } )" >> " ${ comment_script_md } "
echo "- https://hackerpublicradio.org/correspondents/ ${ hosts_hostid } .html" >> " ${ comment_script_md } "
2026-11-08 18:27:09 +01:00
comment_script_txt = " ${ shownotes_recordings_dir } /Comment ${ comments_id } .txt"
comment_script_piper = " ${ shownotes_recordings_dir } /Comment ${ comments_id } _piper.wav"
comment_script_espeak = " ${ shownotes_recordings_dir } /Comment ${ comments_id } _espeak.wav"
2026-11-21 15:15:52 +01:00
echo " ${ comments_comment_author_name } said: « ${ comments_comment_title } »" > " ${ comment_script_txt } "
sqlite3 " ${ hpr_db } " "SELECT comments.comment_text AS comment_text FROM comments WHERE comments.id = ${ comments_id } ;" >> " ${ comment_script_txt } "
echo " ${ comments_comment_text } " >> " ${ comment_script_txt } "
echo "" >> " ${ comment_script_txt } "
2026-11-08 18:27:09 +01:00
cat " ${ comment_script_txt } " >> " ${ comment_script_md } "
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ ! -e " ${ comment_script_piper } " ]
then
echo_debug "Genereating piper \" ${ comment_script_piper } \""
piper --model " ${ piper_voice } " --input-file " ${ comment_script_txt } " --output_file " ${ comment_script_piper } "
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ ! -e " ${ comment_script_espeak } " ]
then
echo_debug "Genereating espeak \" ${ comment_script_espeak } \""
espeak -f " ${ comment_script_txt } " -w " ${ comment_script_espeak } "
fi
2026-11-21 15:15:52 +01:00
2026-04-05 16:35:17 +02:00
if [ " ${ this_comment } " -ne " ${ comments_eps_id } " ]
then
if [ " ${ open_line } " -ne "0" ]
then
2026-11-08 18:27:09 +01:00
echo "</ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
fi
open_line = "1"
this_comment = " ${ comments_eps_id } "
2026-11-21 15:15:52 +01:00
echo "<li><strong><a href=\"https://hackerpublicradio.org/eps/hpr ${ comments_eps_id } /index.html#comments\" target=\"_blank\">hpr ${ comments_eps_id } </a></strong> ( ${ this_ep_date } ) \"<em> ${ eps_title } </em>\" by <a href=\"https://hackerpublicradio.org/correspondents/ ${ hosts_hostid } .html\" target=\"_blank\"> ${ hosts_host } </a>.<br></li>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-08 18:27:09 +01:00
echo "<ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
fi
2026-11-08 18:27:09 +01:00
echo "<li style=\"list-style: none; display: inline\"><strong> ${ comments_comment_author_name } </strong> said: \"<em><a href=\"https://hackerpublicradio.org/eps/hpr ${ comments_eps_id } /index.html#comment_ ${ comments_id } \" target=\"_blank\"> ${ comments_comment_title } </a></em>\" ( ${ comments_comment_timestamp } )<br/></li>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
comment_script_txt = " ${ shownotes_recordings_dir } /Comment ${ comments_id } .txt"
comment_script_piper = " ${ shownotes_recordings_dir } /Comment ${ comments_id } _piper.wav"
comment_script_espeak = " ${ shownotes_recordings_dir } /Comment ${ comments_id } _espeak.wav"
comment_script_narration = " ${ shownotes_recordings_dir } /Comment ${ comments_id } Vvvvvvvvvvvvvvvvvvvvvvvvvvv.wav"
2026-11-21 15:15:52 +01:00
echo "<ul>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
if [ -e " ${ comment_script_narration } " ]
then
comment_script_narration_web = "./Recordings/ $( basename " ${ comment_script_narration } " ) "
echo "<li><audio controls=\"\" preload=\"none\" >
<source src=\" ${ comment_script_narration_web } \" type=\"audio/x-wav\">
2026-11-21 15:15:52 +01:00
</audio>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ -e " ${ comment_script_piper } " ]
then
comment_script_piper_web = "./Recordings/ $( basename " ${ comment_script_piper } " ) "
echo "<audio controls=\"\" preload=\"none\" >
<source src=\" ${ comment_script_piper_web } \" type=\"audio/x-wav\">
2026-11-21 15:15:52 +01:00
</audio>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ -e " ${ comment_script_espeak } " ]
then
comment_script_espeak_web = "./Recordings/ $( basename " ${ comment_script_espeak } " ) "
echo "<audio controls=\"\" preload=\"none\" >
<source src=\" ${ comment_script_espeak_web } \" type=\"audio/x-wav\">
2026-11-21 15:15:52 +01:00
</audio></li>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
fi
2026-11-21 15:15:52 +01:00
echo "</ul>" >> " ${ shownotes_html_edited } "
2026-04-05 16:35:17 +02:00
latest_comment = " ${ comments_id } "
done <<< " ${ results } "
2026-11-08 18:27:09 +01:00
echo "</ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "</ul>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
fi
}
# -------------------------------------------
2026-11-08 18:27:09 +01:00
echo "<h2>Comments this month</h2>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
2026-11-08 18:27:09 +01:00
echo "<h3>Past shows</h3>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
2026-05-13 12:56:34 +02:00
previous_cn_latest_comment_last_changed = $( sqlite3 " ${ hpr_db } " "SELECT last_changed FROM comments WHERE comments.id = ${ previous_cn_latest_comment } ;" )
2026-04-05 16:35:17 +02:00
2026-05-13 12:56:34 +02:00
results = $( sqlite3 -separator '→' " ${ hpr_db } " "
2026-04-05 16:35:17 +02:00
SELECT
comments.id,
comments.eps_id,
eps.date,
eps.title,
hosts.host,
hosts.hostid,
comments.comment_author_name,
comments.comment_timestamp,
comments.comment_title
FROM comments
JOIN eps ON comments.eps_id = eps.id
JOIN hosts ON eps.hostid = hosts.hostid
2026-05-13 12:56:34 +02:00
WHERE comments.id > " ${ previous_cn_latest_comment } "
AND eps.id <= " ${ previous_cn_latest_episode } "
2026-04-05 16:35:17 +02:00
ORDER BY eps.date;
" )
render_comments " ${ results } "
2026-11-08 18:27:09 +01:00
echo "<h3>This month's shows</h3>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
2026-05-13 12:56:34 +02:00
results = $( sqlite3 -separator '→' " ${ hpr_db } " "
2026-04-05 16:35:17 +02:00
SELECT
comments.id,
comments.eps_id,
eps.date,
eps.title,
hosts.host,
hosts.hostid,
comments.comment_author_name,
comments.comment_timestamp,
comments.comment_title
FROM comments
JOIN eps ON comments.eps_id = eps.id
JOIN hosts ON eps.hostid = hosts.hostid
WHERE eps.date LIKE \" ${ this_month } -%\"
ORDER BY eps.date;
" )
render_comments " ${ results } "
############################################################################################
# Add maillist and cal to shownotes
2026-11-08 18:27:09 +01:00
mailman_base = "https://lists.hackerpublicradio.com/pipermail/hpr/ $( \d ate -d" ${ this_month } -01" +%Y-%B ) "
mailman_link = " ${ mailman_base } /thread.html"
wget " ${ mailman_link } " -O thread.html
grep --perl-regexp -- 'A HREF' thread.html | awk -F '"' '{print $2}' | while read this_post
do
this_post_html = " ${ shownotes_recordings_dir } /Post ${ this_post %.* } .html"
if [ ! -e ${ this_post_html } ]
then
2026-11-21 15:15:52 +01:00
wget ${ mailman_base } /${ this_post } --output-document= ${ this_post_html }
2026-11-08 18:27:09 +01:00
fi
this_post_txt = " ${ shownotes_recordings_dir } /Post ${ this_post %.* } .txt"
if [ ! -e ${ this_post_txt } ]
then
grep ' <B>' " ${ this_post_html } " | tee --append " ${ this_post_txt } "
sed --quiet --expression= '/<!--beginarticle-->/,/<!--endarticle-->/{ /<!--beginarticle-->/d; /<!--endarticle-->/d; p; }' " ${ this_post_html } " | tee --append " ${ this_post_txt } "
sed -e 's#^ <B>##g' -e 's#</B># says:#g' -e 's#<PRE>##g' -e 's#</PRE>##g' -i " ${ this_post_txt } "
fi
done
for this_post in ${ shownotes_recordings_dir } /Post*txt
do
this_post_name = " $( basename " ${ this_post } " ) "
if [ " $( find ${ shownotes_recordings_dir } -type f -iname " ${ this_post_name %.* } *.wav" | wc -l ) " -eq "0" ]
then
2026-11-21 15:15:52 +01:00
kate " ${ this_post } " >/dev/null 2>& 1 &
2026-11-08 18:27:09 +01:00
fi
done
if [ " $( ps -ef | grep kate | grep Post | wc -l ) " -ne "0" ]
then
read -p "Were the posts edited ? (N|y) ? " -n 1 -r
echo # (optional) move to a new line
if [[ ! $REPLY = ~ ^[ yY] $ ]]
then
echo_error "The final review was not approved."
fi
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
for this_post in ${ shownotes_recordings_dir } /Post*txt
do
post_id = " $( basename " ${ this_post %.* } " ) "
post_script_txt = " ${ shownotes_recordings_dir } / ${ post_id } .txt"
post_script_piper = " ${ shownotes_recordings_dir } / ${ post_id } _piper.wav"
post_script_espeak = " ${ shownotes_recordings_dir } / ${ post_id } _espeak.wav"
2026-11-21 15:15:52 +01:00
echo " " >> ${ comment_script_md }
echo "# ${ post_id %.* } vvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" >> ${ comment_script_md }
cat ${ this_post } >> ${ comment_script_md }
2026-11-08 18:27:09 +01:00
if [ ! -e " ${ post_script_piper } " ]
then
echo_debug "Genereating piper \" ${ post_script_piper } \""
piper --model " ${ piper_voice } " --input-file " ${ post_script_txt } " --output_file " ${ post_script_piper } "
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ ! -e " ${ post_script_espeak } " ]
then
echo_debug "Genereating espeak \" ${ post_script_espeak } \""
espeak -f " ${ post_script_txt } " -w " ${ post_script_espeak } "
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
done
echo "<h2>Mailing List discussions</h2>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
echo "<p>Policy decisions surrounding HPR are taken by the community as a whole. This
discussion takes place on the <a href=\"https://lists.hackerpublicradio.com/mailman/listinfo/hpr\" target=\"_blank\">Mailing List</a>
which is open to all HPR listeners and contributors. The discussions are open
and available on the HPR server under <a href=\"https://lists.hackerpublicradio.com/pipermail/hpr\">Mailman</a>.
</p>
<p>The threaded discussions this month can be found here:</p>
2026-11-08 18:27:09 +01:00
<a href=\" ${ mailman_link } \" target=\"_blank\"> ${ mailman_link } </a>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<UL>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
2026-11-21 15:15:52 +01:00
# <!--0 01793572759.5072- -->
# <LI><A HREF="005072.html">[Hpr] Community News Clone Voices
# </A><A NAME="5072"> </A>
# <I>Paul Jewell
# </I>
2026-11-08 18:27:09 +01:00
sed --null-data "s/\n//g" thread.html | \
2026-11-21 15:15:52 +01:00
sed --expression= 's/<LI>/\n<LI>/g' \
--expression= 's#</LI>#</LI>\n#g' \
--expression= 's#<UL>#\n<UL>\n#g' \
--expression= 's#</UL>#\n</UL>\n#g' \
--expression= 's#<ul>#\n<ul>\n#g' \
--expression= 's#</ul>#\n</ul>\n#g' | \
2026-11-08 18:27:09 +01:00
grep --perl-regexp -- '<LI>|</LI>|<UL>|</UL>' | while read this_post_line
do
2026-11-21 15:15:52 +01:00
if [ " $( echo " ${ this_post_line } " | grep --count '<UL></LI>' ) " -eq "1" ]
2026-11-08 18:27:09 +01:00
then
2026-11-21 15:15:52 +01:00
echo " ${ this_post_line } ⋄⋄" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
fi
2026-11-08 18:27:09 +01:00
2026-11-21 15:15:52 +01:00
if [ " $( echo " ${ this_post_line } " | grep --count '<LI>' ) " -eq "1" ]
then
IFS = '→' read -r this_post_html this_post_title this_post_name <<< " $( echo " ${ this_post_line } " | awk -F '"|<|>|/' '{print $5"→"$7"→"$19}' ) "
echo "<li><a href=\" ${ mailman_base } / ${ this_post_html } \"> ${ this_post_title } </a> by <i> ${ this_post_name } </i></li>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
post_id = "Post $( echo " ${ this_post_html } " | sed 's/\.html//g' ) "
2026-11-08 18:27:09 +01:00
post_script_narration = " ${ shownotes_recordings_dir } / ${ post_id } Vvvvvvvvvvvvvvvvvvvvvvvvvvvv.wav"
post_script_piper = " ${ shownotes_recordings_dir } / ${ post_id } _piper.wav"
post_script_espeak = " ${ shownotes_recordings_dir } / ${ post_id } _espeak.wav"
2026-11-21 15:15:52 +01:00
echo "<ul>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
if [ -e " ${ post_script_narration } " ]
then
post_script_narration_web = "./Recordings/ $( basename " ${ post_script_narration } " ) "
echo "<li><audio controls=\"\" preload=\"none\" >
<source src=\" ${ post_script_narration_web } \" type=\"audio/x-wav\">
2026-11-21 15:15:52 +01:00
</audio>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ -e " ${ post_script_piper } " ]
then
post_script_piper_web = "./Recordings/ $( basename " ${ post_script_piper } " ) "
echo "<audio controls=\"\" preload=\"none\" >
<source src=\" ${ post_script_piper_web } \" type=\"audio/x-wav\">
2026-11-21 15:15:52 +01:00
</audio>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
fi
2026-11-21 15:15:52 +01:00
2026-11-08 18:27:09 +01:00
if [ -e " ${ post_script_espeak } " ]
then
post_script_espeak_web = "./Recordings/ $( basename " ${ post_script_espeak } " ) "
echo "<audio controls=\"\" preload=\"none\" >
<source src=\" ${ post_script_espeak_web } \" type=\"audio/x-wav\">
2026-11-21 15:15:52 +01:00
</audio></li>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
fi
2026-11-21 15:15:52 +01:00
echo "</ul>" >> " ${ shownotes_html_edited } "
2026-11-08 18:27:09 +01:00
else
2026-11-21 15:15:52 +01:00
echo " ${ this_post_line } " | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-08 18:27:09 +01:00
fi
done
echo "</UL>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
echo "<h2>Events Calendar</h2>
2026-04-05 16:35:17 +02:00
<p>With the kind permission of <strong>LWN.net</strong> we are linking to
<a href=\"https://lwn.net/Calendar/\" target=\"_blank\">The LWN.net Community Calendar</a>.</p>
<p>Quoting the site:</p>
<blockquote>This is the LWN.net community event calendar, where we track
events of interest to people using and developing Linux and free software.
Clicking on individual events will take you to the appropriate web
2026-11-08 18:27:09 +01:00
page.</blockquote>" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-04-05 16:35:17 +02:00
2026-05-13 12:56:34 +02:00
latest_comment = $( sqlite3 " ${ hpr_db } " "SELECT MAX(id) FROM comments;" )
2026-11-08 18:27:09 +01:00
echo "<!-- HPRCN:month= ${ this_month } ,latest_comment= ${ latest_comment } ,latest_host= ${ newest_host } ,latest_episode= ${ latest_episode } -->" | tee --append " ${ shownotes_html_edited } " >> " ${ shownotes_html } "
2026-11-21 15:15:52 +01:00
cd " ${ working_dir } "
2026-11-08 18:27:09 +01:00
while [ " $( $HOME /sourcecode/hpr/solocast/solocast/solocast.py status | grep --count 'All Segments Recorded' ) " == "0" ]
do
$HOME /sourcecode/hpr/solocast/solocast/solocast.py record
$HOME /sourcecode/hpr/solocast/solocast/solocast.py status
sleep 1
done
2026-11-21 15:15:52 +01:00
rsync -av --partial --progress ${ working_dir } /Recordings/ hpr:hackerpublicradio.org/public_html/eps/hpr${ ep_num } /Recordings/
rsync -av --partial --progress ${ working_dir } /script.md hpr:hackerpublicradio.org/public_html/eps/hpr${ ep_num } /script.md
post_show_to_hpr_db
echo_debug "The End."