hpr-tools/Show_Submission/do_show

88 lines
2.2 KiB
Plaintext
Raw Normal View History

#!/bin/bash -
#===============================================================================
#
# FILE: do_show
#
# USAGE: ./do_show <epno>
#
# DESCRIPTION: Displays the raw show details of a given show. To be run after
# 'sync_hpr' and 'copy_shownotes'. The resulting file will be
# called 'shownotes.json' in a directory called 'hpr${epno}'.
#
# OPTIONS: ---
# REQUIREMENTS: ---
# BUGS: ---
# NOTES: The target file used to be called 'hpr${epno}_shownotes.txt'
# but we simplified it so we can use 'rsync' for copying files.
# 2022-12-17: stoped referring to this old file, since now we
# only use shownotes.json.
# 2023-01-07: Refactored to avoid nested tests (though I don't
# find them confusing in this script).
# AUTHOR: Dave Morriss (djm), Dave.Morriss@gmail.com
# VERSION: 0.0.6
# CREATED: 2016-12-15 09:51:09
# REVISION: 2023-01-07 14:51:41
#
#===============================================================================
set -o nounset # Treat unset variables as an error
SCRIPT=${0##*/}
#DIR=${0%/*}
VERSION='0.0.6'
#
# Check the argument after any options
#
if [[ $# -ne 1 ]]; then
echo "$SCRIPT ($VERSION); Usage: $SCRIPT shownumber"
exit
fi
#
# Paths to files
#
BASENAME="$HOME/HPR/Show_Submission"
SHOWDIR="$BASENAME/shownotes/hpr${1}"
FROM="$SHOWDIR/shownotes.json"
PLACEHOLDER="$SHOWDIR/.dummy"
#
# Not a show, just a placeholder
#
if [[ -e $PLACEHOLDER ]]; then
echo "$SCRIPT: This directory contains a placeholder only; aborting"
exit 1
fi
#
# The JSON file isn't there
#
if [[ ! -e $FROM ]]; then
echo "$SCRIPT: File not found: $FROM"
exit 1
fi
#
# File is there but empty!
#
if [[ ! -s $FROM ]]; then
echo "$SCRIPT: File $FROM is empty"
exit 1
fi
#
# Display a subset of the JSON
#
jqprog="{ host: .host, episode: .episode, "
jqprog+="format: .metadata.POST.shownotes_format, "
jqprog+="series: .metadata.POST.series, "
jqprog+="media: .metadata.FILES.media_files.name }"
jq -C "$jqprog" "$FROM" | less -R
exit
# vim: syntax=sh:ts=8:sw=4:ai:et:tw=78:fo=tcrqn21