From 35305a5c451ee73dc9dbafdf20e6bb449c5ce0d3 Mon Sep 17 00:00:00 2001 From: Ken Fallon Date: Fri, 9 May 2025 21:02:45 +0200 Subject: [PATCH] IA create item working --- workflow/process_episode.bash | 42 +++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/workflow/process_episode.bash b/workflow/process_episode.bash index 4324d55..81c6d79 100755 --- a/workflow/process_episode.bash +++ b/workflow/process_episode.bash @@ -177,7 +177,7 @@ function check_variable_is_correct() { then echo_error "The \"duration_iso8601\" variable is missing." fi - ;; + ;; explicit) if [[ -z "${explicit}" || "${explicit}" == "null" ]] then @@ -978,12 +978,12 @@ function get_variables_from_episode_summary_json() { echo_debug "Creating Text to Speech summary. get_variables_from_episode_summary_json()" check_variable_is_correct ep_num working_dir - + if [ -z "${episode_summary_json}" ] then episode_summary_json="${working_dir}/episode_summary.json" fi - + if [ ! -s "${episode_summary_json}" ] then echo_debug "The \"episode_summary_json\" variable/file is missing." @@ -993,18 +993,18 @@ function get_variables_from_episode_summary_json() { fi fi check_variable_is_correct episode_summary_json - + for episode_summary_key in $( jq --raw-output '. | keys | @tsv' "${episode_summary_json}" ) do episode_summary_value="$( jq --raw-output ".${episode_summary_key}" "${episode_summary_json}" | sed -e 's/ \././g' -e 's/\.\./\./g' -e 's/ / /g' )" - declare "${episode_summary_key}=${episode_summary_value}" + export "${episode_summary_key}=${episode_summary_value}" echo_debug "Setting \"${episode_summary_key}\" to \"${episode_summary_value}\" from \"$( basename ${episode_summary_json} )\"" check_variable_is_correct ${episode_summary_key} - done + done duration_iso8601="$( \date -d@${duration} -u +%H:%M:%S )" check_variable_is_correct duration_iso8601 - + } ################################################# @@ -1627,22 +1627,26 @@ function wait_for_the_internet_archive_to_process() { # Send the derived files to the server borg to be sent to the Internet Archive function create_item_on_the_internet_archive() { + echo_debug "Sending the derived files to Internet Archive. create_item_on_the_internet_archive()" - check_variable_is_correct ep_num + check_variable_is_correct working_dir ep_num artist date synopsis title license_url if [ ! -s "${working_dir}/hpr${ep_num}.txt" ] then echo_error "The Internet Archive \"${working_dir}/hpr${ep_num}.txt\" is missing." fi + ia list "hpr${ep_num}" > /dev/null + if [ $? -ne 0 ] + then + echo_debug "The episode has not been posted to the Internet Archive" + ia upload hpr${ep_num} "${working_dir}/hpr${ep_num}.txt" --metadata=mediatype:audio --metadata="contributor:HackerPublicRadio" --metadata="creator:${artist}" --metadata="date:${date}" --metadata="description:${synopsis}." --metadata="language:eng" --metadata="licenseurl:${license_url}" --metadata="title:${title}." --metadata=reviews-allowed:none --header x-archive-keep-old-version:0 --retries=5 --no-derive --no-backup + else + echo_debug "The episode has been posted to the Internet Archive" + fi - echo ia upload hpr${ep_num} "${working_dir}/hpr${ep_num}.txt" --metadata=mediatype:audio --metadata="contributor:HackerPublicRadio" --metadata="creator:HPR Volunteers" --metadata="date:2025-05-05" --metadata="description:This show is a placeholder and will be updated soon." --metadata="language:eng" --metadata="licenseurl:http://creativecommons.org/licenses/by-sa/4.0" --metadata="title:A placeholder for hpr${ep_num}." --metadata=reviews-allowed:none --header x-archive-keep-old-version:0 --retries=5 --no-derive --no-backup - -# curl --silent --netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/say.php?id=${ep_num} --output "${episode_summary_json}" -# curl --netrc-file ${HOME}/.netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/shownotes.php?id=${ep_num} --output "${working_dir}/shownotes.json" - - + xdg-open https://archive.org/details/hpr${ep_num} wait_for_the_internet_archive_to_process } @@ -1828,12 +1832,8 @@ fi ######################################################################################### # Using DB info from here - - get_variables_from_episode_summary_json # Get the episode from HPR. - - # # create_tts_summary # Generate text to speech summary # @@ -1857,7 +1857,7 @@ get_variables_from_episode_summary_json # Get the episode from HPR. # copy_derived_files_to_borg -#create_item_on_the_internet_archive +create_item_on_the_internet_archive #upload_files_to_the_internet_archive @@ -1872,3 +1872,7 @@ exit 0 # else # echo_debug "The setting \"force_overwrite\" is set to false, so when files exist the program will skip files if they exist." # fi + +# curl --silent --netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/say.php?id=${ep_num} --output "${episode_summary_json}" +# curl --netrc-file ${HOME}/.netrc --write-out '%{http_code}' https://hub.hackerpublicradio.org/cms/shownotes.php?id=${ep_num} --output "${working_dir}/shownotes.json" +