From 7e61a4b4f1184657289555d8112226c77ffcf1b7 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 18 Apr 2018 14:36:35 +0200 Subject: Nicer utils --- odin/strm.nix | 6 +++++- odin/strm/cleanup_youtube | 14 +------------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'odin') 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 @@ -{ stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, buildPerlPackage, perlPackages }: +{ stdenv +, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, rolling-directory +, buildPerlPackage, perlPackages +}: let manual-youtube = buildPerlPackage { @@ -46,6 +49,7 @@ in stdenv.mkDerivation { inherit zsh pv notmuch rss2email; ffmpeg = ffmpeg-full; youtubedl = youtube-dl; + rollingdirectory = rolling-directory; buildPhase = '' 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 { urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; } -dir=/srv/media/youtube -maxsize=$((1024 * 1024 * 1024 * 50)) - -while [[ $(du -bs $dir | awk '{ print $1; }') -gt $maxsize ]]; do - find $dir -type f -not -path $dir/CACHEDIR.TAG -print0 | \ - xargs -0 -- stat --printf '%W %Y %Z %X %n\0' | \ - sort -t '\0' -z | \ - awk -F '\0' '{ gsub("^\\S+\\s+\\S+\\s+\\S+\\s+\\S+\\s+", "", $1); printf "%s\0", $1; }' | \ - xargs -0 -- rm -v -done - -find $dir -xtype l -delete -find $dir -type d -empty -delete +@rollingdirectory@/bin/rolling-directory /srv/media/youtube 50Gi notmuch search --output=messages --format=text 'is:cached' | \ while read id; do -- cgit v1.2.3