From 2e13c35e55cace64537d41c4b202f9abf163387e Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 6 Apr 2018 14:32:36 +0200 Subject: cache_media --- odin/strm.nix | 2 ++ odin/strm/cache_media | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 odin/strm/cache_media diff --git a/odin/strm.nix b/odin/strm.nix index f5c5a2c1..82ba2bdb 100644 --- a/odin/strm.nix +++ b/odin/strm.nix @@ -12,6 +12,7 @@ stdenv.mkDerivation { substituteAllInPlace download_youtube substituteAllInPlace cleanup_youtube substituteAllInPlace send_media + substituteAllInPlace cache_media substituteAllInPlace send_kitty ''; @@ -22,6 +23,7 @@ stdenv.mkDerivation { download_youtube \ cleanup_youtube \ send_media \ + cache_media \ send_kitty ''; } diff --git a/odin/strm/cache_media b/odin/strm/cache_media new file mode 100644 index 00000000..68938799 --- /dev/null +++ b/odin/strm/cache_media @@ -0,0 +1,26 @@ +#!@zsh@/bin/zsh + +logTag=${0:t} + +exec 1> >(logger -t "$logTag" -p news.notice) +exec 2> >(logger -t "$logTag" -p news.error) + +debug() { logger -t "$logTag" -p news.debug } + +function notmuch { + msg1=1 + while true; do + result=$(env NOTMUCH_CONFIG=${HOME}/.notmuch-rss-config @notmuch@/bin/notmuch $@) + if ! [[ "$result" =~ "already locked" ]]; then + echo -nE "$result" + return + else + [[ $msg1 == "1" ]] && echo "Already locked" >&2 + msg1=0 + fi + sleep 2 + done +} + +exec -- nice -n 5 -- ionice -n 5 -- xargs -d '\n' -n 1 -r -P 1 -- download_youtube \ + <<<$(notmuch search --sort=oldest-first --output=messages --format=text "( tag:inbox AND is:media AND is:unread ) AND NOT ( tag:new OR tag:killed OR tag:failed OR tag:cached )") \ -- cgit v1.2.3