Add http status thingy
This commit is contained in:
parent
8ad34e1a2c
commit
f7d9e0e20c
|
@ -21,10 +21,15 @@ RUN dpkg-reconfigure libdvd-pkg
|
|||
RUN true \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y install \
|
||||
lame \
|
||||
busybox \
|
||||
jq \
|
||||
procps \
|
||||
cowsay
|
||||
|
||||
COPY scripts /scripts
|
||||
COPY abcde.conf /etc/
|
||||
COPY abcde.conf httpd.conf /etc/
|
||||
COPY --chown=linuxserver:linuxserver www /www
|
||||
USER linuxserver
|
||||
ENTRYPOINT ["/scripts/init.sh"]
|
||||
|
||||
# vi: ts=2 sw=2 et ai
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
.mjs:text/javascript
|
|
@ -1,9 +1,17 @@
|
|||
#! /bin/sh
|
||||
|
||||
# If you haven't set OUTDIR, set it to the default
|
||||
: ${OUTDIR:=/incoming}
|
||||
export OUTDIR
|
||||
|
||||
log () {
|
||||
printf "\033[36m=== [%s] \033[0m %s\n" "$0" "$*"
|
||||
}
|
||||
|
||||
# If you haven't set OUTDIR, set it to the default
|
||||
: ${OUTDIR:=/incoming}
|
||||
export OUTDIR
|
||||
status () {
|
||||
task=$1
|
||||
status=$2
|
||||
|
||||
echo "$status" > $OUTDIR/status.$task
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ while sleep 2; do
|
|||
workdir=$mtype/$d
|
||||
[ -f $workdir/read.finished ] || continue
|
||||
|
||||
log "Encoding $workdir"
|
||||
status "encoder" "$workdir"
|
||||
if ! run_in $workdir $encode; then
|
||||
log "$encode failed"
|
||||
else
|
||||
|
@ -24,6 +24,7 @@ while sleep 2; do
|
|||
fi
|
||||
done
|
||||
done
|
||||
status "encoder" "idle"
|
||||
done
|
||||
|
||||
# vi: ts=2 sw=2 et ai
|
||||
|
|
|
@ -4,7 +4,9 @@ cd /incoming
|
|||
|
||||
mkdir -p audio video
|
||||
|
||||
busybox httpd -p 8080 -h /www
|
||||
nice /scripts/reader.sh &
|
||||
nice /scripts/encoder.sh &
|
||||
nice /scripts/status.sh &
|
||||
|
||||
wait
|
||||
|
|
|
@ -7,6 +7,7 @@ with_time_dir () {
|
|||
now=$(date --rfc-3339=s | tr ' ' T)
|
||||
mkdir -p $mtype/$now
|
||||
cd $mtype/$now
|
||||
status "reader" "$mtype"
|
||||
if ! "$@"; then
|
||||
log "$1 failed"
|
||||
else
|
||||
|
@ -29,6 +30,7 @@ while sleep 2; do
|
|||
*)
|
||||
;;
|
||||
esac
|
||||
status "reader" "idle"
|
||||
done
|
||||
|
||||
# vi: sw=2 ts=2 et ai
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
#! /bin/sh
|
||||
|
||||
. /scripts/common.sh
|
||||
|
||||
cat <<EOD
|
||||
{
|
||||
"finished": {
|
||||
"video": $(ls *.mkv | jq -nR '[inputs]'),
|
||||
"audio": $(ls */*/*.mp3 | jq -nR '[inputs]')
|
||||
},
|
||||
"status": {
|
||||
"reader": $(cat status.reader | jq -nR '[inputs][0]'),
|
||||
"encoder": $(cat status.encoder | jq -nR '[inputs][0]')
|
||||
}
|
||||
}
|
||||
EOD
|
|
@ -0,0 +1,13 @@
|
|||
#! /bin/sh
|
||||
|
||||
. /scripts/common.sh
|
||||
|
||||
while true; do
|
||||
if ! /scripts/status.json.sh > /www/status.json.new; then
|
||||
log "Unable to render status!"
|
||||
else
|
||||
mv /www/status.json.new /www/status.json
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Media-Sucker</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.3/css/bulma.min.css">
|
||||
<script src="sucker.mjs" type="module"></script>
|
||||
</head>
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<div class="columns">
|
||||
|
||||
<div class="column">
|
||||
<div class="card status">
|
||||
<div class="card-header has-background-info">
|
||||
<div class="card-header-title">Status</div>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<p class="reader">
|
||||
Reader:
|
||||
<span class="text">unknown</span>
|
||||
<progress class="progress is-primary" max="100" value="0"></progress>
|
||||
</p>
|
||||
<p class="encoder">
|
||||
Encoder:
|
||||
<span class="text">unknown</span>
|
||||
<progress class="progress is-primary" max="100" value="0"></progress>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="panel video">
|
||||
<div class="panel-heading">Completed Video</div>
|
||||
<div class="items"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="column">
|
||||
<div class="panel audio">
|
||||
<div class="panel-heading">Completed Audio</div>
|
||||
<div class="items"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
</div>
|
||||
</section>
|
||||
<template class="panel-file-item">
|
||||
<a class="panel-block">
|
||||
<span class="filename">--filename--</span>
|
||||
</a>
|
||||
</template>
|
||||
</body>
|
||||
</html>
|
||||
<!--
|
||||
vi: ts=2 sw=2 et ai
|
||||
-->
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"comment": "This file will be overwritten during runtime. It's only here for testing.",
|
||||
"finished": {
|
||||
"video": [
|
||||
"Video 1.mkv",
|
||||
"Video 2.mkv",
|
||||
"Video 3.mkv"
|
||||
],
|
||||
"audio": [
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/01 - Track_1.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/02 - Track_2.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/03 - Track_3.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/04 - Track_4.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/05 - Track_5.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/06 - Track_6.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/07 - Track_7.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/08 - Track_8.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/09 - Track_9.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/10 - Track_10.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/11 - Track_11.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/12 - Track_12.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/13 - Track_13.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/14 - Track_14.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.182628/15 - Track_15.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/01 - Track_1.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/02 - Track_2.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/03 - Track_3.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/04 - Track_4.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/05 - Track_5.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/06 - Track_6.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/07 - Track_7.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/08 - Track_8.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/09 - Track_9.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/10 - Track_10.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/11 - Track_11.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/12 - Track_12.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/13 - Track_13.mp3",
|
||||
"Unknown_Artist/Unknown_Album_20220106.191506/14 - Track_14.mp3"
|
||||
]
|
||||
},
|
||||
"status": {
|
||||
"reader": "idle",
|
||||
"encoder": "idle"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
const MILLISECOND = 1
|
||||
const SECOND = 1000
|
||||
|
||||
async function update() {
|
||||
let resp = await fetch("status.json", {cache: "no-store"})
|
||||
let s = await resp.json()
|
||||
|
||||
for (let activity of ["reader", "encoder"]) {
|
||||
let val = s.status[activity]
|
||||
let e = document.querySelector(`.status .${activity}`)
|
||||
let txt = e.querySelector(".text")
|
||||
let progress = e.querySelector("progress")
|
||||
txt.textContent = val
|
||||
if (val == "idle") {
|
||||
progress.value = 0
|
||||
} else {
|
||||
// Removing the value makes it pulse
|
||||
progress.removeAttribute("value")
|
||||
}
|
||||
}
|
||||
|
||||
let fileItem = document.querySelector("template.panel-file-item").content
|
||||
|
||||
for (let section of ["video", "audio"]) {
|
||||
let e = document.querySelector(`.${section} .items`)
|
||||
while (e.firstChild) e.firstChild.remove()
|
||||
for (let fn of s.finished[section]) {
|
||||
let item = fileItem.cloneNode(true)
|
||||
item.querySelector(".filename").textContent = fn
|
||||
e.append(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(update, 2 * SECOND)
|
||||
update()
|
||||
|
||||
// vi: ts=2 sw=2 et ai
|
Loading…
Reference in New Issue