feat(applications): ✨ add show catalog listing command
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
027e9b2c21
commit
d614d4f9b4
1 changed files with 25 additions and 1 deletions
|
|
@ -234,6 +234,29 @@ stats_json() {
|
|||
"$l1" "$l5" "$l15" "$cores" "$mcpu"
|
||||
}
|
||||
|
||||
# JSON catalogue of every show under tv/cartoons/anime: name, dir, episode count
|
||||
# and distinct-season count (picking the dominant release per show). Lets the
|
||||
# PlumTV app browse the real library over the mesh when plum's NFS ~/media is
|
||||
# down. [{name,dir,episodes,seasons}].
|
||||
list_json() {
|
||||
local out="[" first=1 d base files eps seas nm
|
||||
while IFS= read -r d; do
|
||||
[ -n "$d" ] || continue
|
||||
base=$(pick_release_root "$d")
|
||||
files=$(find "$base" -type f -iregex "$VIDEO_RE" ! -ipath '*/Specials/*' ! -ipath '*/Extras/*' 2>/dev/null)
|
||||
[ -n "$files" ] || continue
|
||||
# End count pipelines in wc -l (always exit 0) — grep -c exits 1 on zero and
|
||||
# would trip `set -e`. Intermediate grep failures are fine (no pipefail).
|
||||
eps=$(printf '%s\n' "$files" | wc -l | tr -d ' ')
|
||||
seas=$(printf '%s\n' "$files" | grep -oiE 's[0-9]+e[0-9]+' | grep -oiE '^s[0-9]+' | sort -u | wc -l | tr -d ' ')
|
||||
nm=$(basename "$d")
|
||||
[ $first -eq 1 ] || out="$out,"; first=0
|
||||
out="$out{\"name\":$(json_str "$nm"),\"dir\":$(json_str "$d"),\"episodes\":$eps,\"seasons\":$seas}"
|
||||
done < <(find "$MEDIA_ROOT"/tv "$MEDIA_ROOT"/cartoons "$MEDIA_ROOT"/anime \
|
||||
-mindepth 1 -maxdepth 1 -type d 2>/dev/null | sort)
|
||||
echo "$out]"
|
||||
}
|
||||
|
||||
# --- dispatch ---------------------------------------------------------------
|
||||
cmd="${1:-}"; shift || true
|
||||
case "$cmd" in
|
||||
|
|
@ -322,6 +345,7 @@ case "$cmd" in
|
|||
stop) sudo systemctl stop "$UNIT" 2>/dev/null || true; sudo pkill -x mpv 2>/dev/null || true; rm -f "$SOCK"; echo stopped ;;
|
||||
status) status_json ;;
|
||||
stats) stats_json ;;
|
||||
list) list_json ;;
|
||||
ensure-display) ensure_display; echo "display ready: $(cat /sys/class/drm/card0-${CONNECTOR}/status 2>/dev/null)" ;;
|
||||
*) die "usage: black-tv {play <path>|play-show <q> [S] [E]|resume-show <q>|enqueue <x>|goto-ep N|releases|switch <rel>|pause|resume|toggle|vol N|seek S|next|prev|stop|status|stats|watched [q]|ensure-display}" ;;
|
||||
*) die "usage: black-tv {play <path>|play-show <q> [S] [E]|resume-show <q>|enqueue <x>|goto-ep N|releases|switch <rel>|pause|resume|toggle|vol N|seek S|next|prev|stop|status|stats|list|watched [q]|ensure-display}" ;;
|
||||
esac
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue