summaryrefslogtreecommitdiff
path: root/odin
diff options
context:
space:
mode:
Diffstat (limited to 'odin')
-rw-r--r--odin/strm.nix6
-rw-r--r--odin/strm/cleanup_youtube14
2 files changed, 6 insertions, 14 deletions
diff --git a/odin/strm.nix b/odin/strm.nix
index 094da07c..487fd170 100644
--- a/odin/strm.nix
+++ b/odin/strm.nix
@@ -1,4 +1,7 @@
1{ stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, buildPerlPackage, perlPackages }: 1{ stdenv
2, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, rolling-directory
3, buildPerlPackage, perlPackages
4}:
2 5
3let 6let
4 manual-youtube = buildPerlPackage { 7 manual-youtube = buildPerlPackage {
@@ -46,6 +49,7 @@ in stdenv.mkDerivation {
46 inherit zsh pv notmuch rss2email; 49 inherit zsh pv notmuch rss2email;
47 ffmpeg = ffmpeg-full; 50 ffmpeg = ffmpeg-full;
48 youtubedl = youtube-dl; 51 youtubedl = youtube-dl;
52 rollingdirectory = rolling-directory;
49 53
50 buildPhase = '' 54 buildPhase = ''
51 substituteAllInPlace download_youtube 55 substituteAllInPlace download_youtube
diff --git a/odin/strm/cleanup_youtube b/odin/strm/cleanup_youtube
index 2d91fe1f..76c3f0bb 100644
--- a/odin/strm/cleanup_youtube
+++ b/odin/strm/cleanup_youtube
@@ -19,19 +19,7 @@ function cleanup {
19 19
20urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } 20urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
21 21
22dir=/srv/media/youtube 22@rollingdirectory@/bin/rolling-directory /srv/media/youtube 50Gi
23maxsize=$((1024 * 1024 * 1024 * 50))
24
25while [[ $(du -bs $dir | awk '{ print $1; }') -gt $maxsize ]]; do
26 find $dir -type f -not -path $dir/CACHEDIR.TAG -print0 | \
27 xargs -0 -- stat --printf '%W %Y %Z %X %n\0' | \
28 sort -t '\0' -z | \
29 awk -F '\0' '{ gsub("^\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+", "", $1); printf "%s\0", $1; }' | \
30 xargs -0 -- rm -v
31done
32
33find $dir -xtype l -delete
34find $dir -type d -empty -delete
35 23
36notmuch search --output=messages --format=text 'is:cached' | \ 24notmuch search --output=messages --format=text 'is:cached' | \
37 while read id; do 25 while read id; do