media-sucker/scripts/status.json.sh

28 lines
564 B
Bash
Executable File

#! /bin/sh
. $(dirname $0)/common.sh
queue () {
ls audio/*/env.json video/*/env.json 2>/dev/null \
| while read envjson
do
dir=${envjson%/env.json}
cat $envjson \
| jq --arg dir "$dir" '.directory = $dir'
done
}
cat <<EOD
{
"finished": {
"video": $(ls *.mkv 2>/dev/null | jq -nR '[inputs]'),
"audio": $(ls */*/.mp3 2>/dev/null | jq -nR '[inputs]')
},
"queue": $(queue | jq --slurp),
"status": {
"reader": $(cat status.reader | jq -nR '[inputs][0]'),
"encoder": $(cat status.encoder | jq -nR '[inputs][0]'),
}
}
EOD