From 941f35b76b3fda872745f8788f8546d979513bde Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 6 Apr 2018 14:26:03 +0200 Subject: send_kitty --- odin/strm.nix | 3 ++- odin/strm/send_kitty | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 odin/strm/send_kitty diff --git a/odin/strm.nix b/odin/strm.nix index 36d0e876..9ddec319 100644 --- a/odin/strm.nix +++ b/odin/strm.nix @@ -12,11 +12,12 @@ stdenv.mkDerivation { substituteAllInPlace download_youtube substituteAllInPlace cleanup_youtube substituteAllInPlace send_media + substituteAllInPlace send_kitty ''; installPhase = '' mkdir -p $out/bin - install -m 755 -t $out/bin download_youtube cleanup_youtube send_media + install -m 755 -t $out/bin download_youtube cleanup_youtube send_media send_kitty ''; } diff --git a/odin/strm/send_kitty b/odin/strm/send_kitty new file mode 100755 index 00000000..a294d84c --- /dev/null +++ b/odin/strm/send_kitty @@ -0,0 +1,41 @@ +#!@zsh@/bin/zsh + +set -o errexit +umask 022 + +wDir=/srv/hlidskjalf +concatDir=${wDir}/concat +lastFile=${concatDir}/latest.mkv + +fList="" + +function cleanup() { + [[ -n "${fList}" ]] && rm -v ${fList} +} + +trap cleanup EXIT + +fList=$(mktemp --tmpdir filelist.XXXXXX) + +typeset -a findArg +findArg=() + +if [[ -e ${lastFile} ]]; then + findArg=(-mtime -1 -a -newer ${lastFile}) +else + findArg=(-mtime -1) +fi + +find -L /srv/hlidskjalf \( -path /srv/hlidskjalf/concat -prune \) -o \( \( ${findArg} \) -type f -print \) | sort | >! ${fList} + +cat ${fList} >&2 + +if [[ $(wc -l ${fList} | cut -d ' ' -f 1) -eq 0 ]]; then + exit 0 +fi + +newFile="${concatDir}/$(date +'%Y-%m-%d-%H-%M-%S').mkv" + +@ffmpeg@/bin/ffmpeg -safe 0 -f concat -i =(awk $'{ print "file \'"$0"\'" }' ${fList}) -c copy -metadata "description=$(xargs -a ${fList} -- basename -s ".mkv")" ${newFile} +queue.hel ${newFile} +ln -vfs $(realpath --relative-to=${lastFile:h} ${newFile}) ${lastFile} -- cgit v1.2.3