summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2018-04-06 19:54:03 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2018-04-06 19:54:03 +0200
commite52e5ea5494319f158e9d9c1425b16b9986e929a (patch)
tree7330667fc281e6de00b968bd31ff7ca5e5234f41
parenta29c95fe7335167cc3012dedfef2c4afbe1392c7 (diff)
downloadnixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar
nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar.gz
nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar.bz2
nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.tar.xz
nixos-e52e5ea5494319f158e9d9c1425b16b9986e929a.zip
rss_staggered
-rw-r--r--odin/strm.nix8
-rwxr-xr-xodin/strm/rss_staggered32
2 files changed, 37 insertions, 3 deletions
diff --git a/odin/strm.nix b/odin/strm.nix
index 8c88514e..71d93011 100644
--- a/odin/strm.nix
+++ b/odin/strm.nix
@@ -1,4 +1,4 @@
1{ stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch }: 1{ stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email }:
2 2
3stdenv.mkDerivation { 3stdenv.mkDerivation {
4 name = "strm"; 4 name = "strm";
@@ -6,7 +6,7 @@ stdenv.mkDerivation {
6 6
7 phases = [ "unpackPhase" "buildPhase" "installPhase" ]; 7 phases = [ "unpackPhase" "buildPhase" "installPhase" ];
8 8
9 inherit zsh pv notmuch; 9 inherit zsh pv notmuch rss2email;
10 ffmpeg = ffmpeg-full; 10 ffmpeg = ffmpeg-full;
11 youtubedl = youtube-dl; 11 youtubedl = youtube-dl;
12 12
@@ -16,6 +16,7 @@ stdenv.mkDerivation {
16 substituteAllInPlace send_media 16 substituteAllInPlace send_media
17 substituteAllInPlace cache_media 17 substituteAllInPlace cache_media
18 substituteAllInPlace send_kitty 18 substituteAllInPlace send_kitty
19 substituteAllInPlace rss_staggered
19 ''; 20 '';
20 21
21 installPhase = '' 22 installPhase = ''
@@ -26,6 +27,7 @@ stdenv.mkDerivation {
26 cleanup_youtube \ 27 cleanup_youtube \
27 send_media \ 28 send_media \
28 cache_media \ 29 cache_media \
29 send_kitty 30 send_kitty \
31 rss_staggered
30 ''; 32 '';
31} 33}
diff --git a/odin/strm/rss_staggered b/odin/strm/rss_staggered
new file mode 100755
index 00000000..54bbd1a3
--- /dev/null
+++ b/odin/strm/rss_staggered
@@ -0,0 +1,32 @@
1#!@zsh@/bin/zsh
2
3delta_t=20
4interval=3600
5
6staggerFile=~/.rss-stagger
7
8[[ "${FLOCKER}" != "$0" ]] && exec env FLOCKER="$0" flock -x "${staggerFile}" "$0" "$@" || :
9
10feeds=$(@rss2email@/bin/r2e list | awk -F ':' 'END { print $1; }')
11max=$(($feeds + 1))
12num=$(((max * delta_t) / interval))
13[[ $num -lt 1 ]] && num=1
14
15now=$(cat ${staggerFile} || echo 0)
16now=$((now % max))
17
18typeset -a run
19run=()
20typeset -a names
21names=()
22
23n=0
24
25for i in $(seq $((now + 1)) $((now + num + 1))); do
26 n=$((i % max))
27 run+=$n
28done
29
30echo $n >! ${staggerFile}
31
32exec @rss2email@/bin/r2e run $run