summaryrefslogtreecommitdiff
path: root/odin
diff options
context:
space:
mode:
Diffstat (limited to 'odin')
-rw-r--r--odin/strm.nix2
-rw-r--r--odin/strm/cache_media26
2 files changed, 28 insertions, 0 deletions
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 {
12 substituteAllInPlace download_youtube 12 substituteAllInPlace download_youtube
13 substituteAllInPlace cleanup_youtube 13 substituteAllInPlace cleanup_youtube
14 substituteAllInPlace send_media 14 substituteAllInPlace send_media
15 substituteAllInPlace cache_media
15 substituteAllInPlace send_kitty 16 substituteAllInPlace send_kitty
16 ''; 17 '';
17 18
@@ -22,6 +23,7 @@ stdenv.mkDerivation {
22 download_youtube \ 23 download_youtube \
23 cleanup_youtube \ 24 cleanup_youtube \
24 send_media \ 25 send_media \
26 cache_media \
25 send_kitty 27 send_kitty
26 ''; 28 '';
27} 29}
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 @@
1#!@zsh@/bin/zsh
2
3logTag=${0:t}
4
5exec 1> >(logger -t "$logTag" -p news.notice)
6exec 2> >(logger -t "$logTag" -p news.error)
7
8debug() { logger -t "$logTag" -p news.debug }
9
10function notmuch {
11 msg1=1
12 while true; do
13 result=$(env NOTMUCH_CONFIG=${HOME}/.notmuch-rss-config @notmuch@/bin/notmuch $@)
14 if ! [[ "$result" =~ "already locked" ]]; then
15 echo -nE "$result"
16 return
17 else
18 [[ $msg1 == "1" ]] && echo "Already locked" >&2
19 msg1=0
20 fi
21 sleep 2
22 done
23}
24
25exec -- nice -n 5 -- ionice -n 5 -- xargs -d '\n' -n 1 -r -P 1 -- download_youtube \
26 <<<$(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 )") \