diff --git a/hosts/storage-2/mixcloud.nix b/hosts/storage-2/mixcloud.nix index 02a534c..9967765 100644 --- a/hosts/storage-2/mixcloud.nix +++ b/hosts/storage-2/mixcloud.nix @@ -25,11 +25,13 @@ let Group = "data-mixcloud"; Restart="on-failure"; }; + wants = [ "youtube-dl-prepare.service" ]; + after = [ "youtube-dl-prepare.service" ]; path = [ pkgs.youtube-dl ]; script = '' mkdir -p /data/mixcloud/${source}/ cd /data/mixcloud/${source}/ - youtube-dl --ignore-errors --playlist-random --newline ${url} + youtube-dl --ignore-errors --playlist-random --newline -x --audio-format mp3 ${url} ''; startAt = "*-*-* 05:05:00"; } @@ -67,6 +69,17 @@ in { }; users.groups.data-mixcloud = {}; - systemd.services = (mapAttrs' generateYoutubedlMixcloudUnits mixcloudSources); + systemd.services = { + "youtube-dl-prepare" = { + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = "true"; + }; + script = '' + mkdir -p /data/mixcloud + chown -R data-mixcloud:data-mixcloud /data/mixcloud + ''; + }; + } // (mapAttrs' generateYoutubedlMixcloudUnits mixcloudSources); systemd.timers = (mapAttrs' generateYoutubedlMixcloudTimers mixcloudSources); }