b7cae1cb90
Show_Submission/copy_shownotes: Changed the location of the function library Show_Submission/do_brave: Updates to the way local stand-alone HTML is generated for review purposes. Show_Submission/do_index: Changed the location of the function library Show_Submission/do_pandoc: Changed the location of the function library; now uses 'author_title.pl' to generate YAML for Pandoc Show_Submission/do_parse: Trivial change Show_Submission/do_pictures: Changed the location of the function library; better handling of the show specification Show_Submission/do_report: Changed the location of the function library Show_Submission/do_update_reservations: Changed the location of the function library Show_Submission/fix_relative_links: Added features 'say' and 'state' Show_Submission/parse_JSON: New checks: notes too short, trailing spaces on title, summary and tags (needing JSON changes). Check for Markdown in the assets (see 'do_pandoc_assets'). New 'trim' function.
117 lines
3.0 KiB
Bash
Executable File
117 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#===============================================================================
|
|
#
|
|
# FILE: copy_shownotes
|
|
#
|
|
# USAGE: ./copy_shownotes
|
|
#
|
|
# DESCRIPTION: Copies the shownotes (and related files) downloaded from the
|
|
# HPR server. This happens after 'sync_hpr' has been run to
|
|
# collect updates from the ~hpr/upload/ directory on the server
|
|
# and store the result in the local upload/ directory.
|
|
# 2022-12-17: Converted to shownotes.json.
|
|
#
|
|
# OPTIONS: ---
|
|
# REQUIREMENTS: ---
|
|
# BUGS: ---
|
|
# NOTES: ---
|
|
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
|
|
# VERSION: 0.0.10
|
|
# CREATED: 2015-09-16 21:51:15
|
|
# REVISION: 2024-06-18 20:42:17
|
|
#
|
|
#===============================================================================
|
|
|
|
set -o nounset # Treat unset variables as an error
|
|
|
|
SCRIPT=${0##*/}
|
|
|
|
#
|
|
# Load library functions
|
|
#
|
|
LIB="$HOME/HPR/function_lib.sh"
|
|
[ -e "$LIB" ] || { echo "$SCRIPT: Unable to source functions"; exit 1; }
|
|
# shellcheck source=/home/cendjm/HPR/function_lib.sh
|
|
source "$LIB"
|
|
|
|
#
|
|
# Colour codes
|
|
#
|
|
define_colours
|
|
|
|
#
|
|
# Directories
|
|
#
|
|
BASEDIR="$HOME/HPR/Show_Submission"
|
|
LOGS="$BASEDIR/logs"
|
|
UPLOAD="$BASEDIR/upload"
|
|
CACHE="$BASEDIR/shownotes"
|
|
|
|
#
|
|
# Filenames
|
|
#
|
|
LOGFILE="$LOGS/${SCRIPT}.log"
|
|
#SHOWNOTES='shownotes.txt'
|
|
SHOWNOTES='shownotes.json'
|
|
ORIGIN='.origin'
|
|
STATUS='.status'
|
|
DUMMY='.dummy'
|
|
|
|
#
|
|
# Loop through everything in the $UPLOAD directory using a regular expression
|
|
# to find sub-directories. These look like:
|
|
# 1445633350_1906_2015-11-23_f348faf9125c129c1ebe0dd0edd721a0562a9d464bbbf
|
|
#
|
|
# The regex used in find takes into account that it needs to match the full
|
|
# path.
|
|
#
|
|
count=0
|
|
target=".*/[0-9]+_[0-9]{4}_[0-9]{4}-[0-9]{2}-[0-9]{2}_.+$"
|
|
while read -r d
|
|
do
|
|
#
|
|
# Parse out the show number
|
|
#
|
|
show="$(echo "$d" | cut -f2 -d_)"
|
|
from="$UPLOAD/$d/"
|
|
dir="$CACHE/hpr${show}"
|
|
to="$dir/$SHOWNOTES"
|
|
origin="$dir/$ORIGIN"
|
|
status="$dir/$STATUS"
|
|
dummy="$dir/$DUMMY"
|
|
|
|
#
|
|
# Make the receiving directory if it doesn't exist
|
|
#
|
|
if [[ ! -e $dir ]]; then
|
|
mkdir "$dir"
|
|
fi
|
|
|
|
#
|
|
# Copy files if there are no shownotes or the file exists and is empty.
|
|
#
|
|
# 2022-12-17: We're soon not using shownotes.txt any more. The data is in
|
|
# shownotes.json instead. Also, dummy shows have a '.dummy' file rather
|
|
# than empty notes.
|
|
#
|
|
# if [[ ! -e $to || ! -s $to ]]; then
|
|
if [[ ! -e $to || -e $dummy ]]; then
|
|
rsync -vaP "$from" "${dir}/"
|
|
echo "$d" > "$origin"
|
|
echo "copied" > "$status"
|
|
((count++))
|
|
printf '%(%F %T)T %s\n' -1 "$dir" >> "$LOGFILE"
|
|
echo "${green}Copied notes for show $show${reset}"
|
|
fi
|
|
done < <(find "$UPLOAD" -maxdepth 1 -regextype posix-egrep -regex "$target" -type d -printf '%f\n')
|
|
|
|
if [[ $count -eq 0 ]]; then
|
|
echo "${yellow}Nothing to do${reset}"
|
|
else
|
|
echo "${green}Notes copied: $count${reset}"
|
|
fi
|
|
|
|
exit
|
|
|
|
# vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21
|