diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-06 14:32:36 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2018-04-06 14:32:36 +0200 |
commit | 2e13c35e55cace64537d41c4b202f9abf163387e (patch) | |
tree | 6fdb19d5dfe79fa0e479f51593b989c7eec544b0 | |
parent | 6f457860ffd4313109a19a57a776b3ec157c4d22 (diff) | |
download | nixos-2e13c35e55cace64537d41c4b202f9abf163387e.tar nixos-2e13c35e55cace64537d41c4b202f9abf163387e.tar.gz nixos-2e13c35e55cace64537d41c4b202f9abf163387e.tar.bz2 nixos-2e13c35e55cace64537d41c4b202f9abf163387e.tar.xz nixos-2e13c35e55cace64537d41c4b202f9abf163387e.zip |
cache_media
-rw-r--r-- | odin/strm.nix | 2 | ||||
-rw-r--r-- | odin/strm/cache_media | 26 |
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 | |||
3 | logTag=${0:t} | ||
4 | |||
5 | exec 1> >(logger -t "$logTag" -p news.notice) | ||
6 | exec 2> >(logger -t "$logTag" -p news.error) | ||
7 | |||
8 | debug() { logger -t "$logTag" -p news.debug } | ||
9 | |||
10 | function 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 | |||
25 | exec -- 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 )") \ | ||