2023-05-02 20:40:30 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2022-01-02 21:55:09 +01:00
|
|
|
|
2022-05-26 00:41:57 +02:00
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
mixcloudSources = {
|
|
|
|
avocadoom = "https://www.mixcloud.com/avocadoom/";
|
|
|
|
b4m = "https://www.mixcloud.com/b4m/";
|
|
|
|
barbnerdy = "https://soundcloud.com/barbnerdy";
|
|
|
|
beh2342 = "https://soundcloud.com/beh2342";
|
|
|
|
couchsofa = "https://www.mixcloud.com/couchsofa/";
|
2024-01-05 19:47:37 +01:00
|
|
|
#das-kraftfuttermischwerk = "https://soundcloud.com/das-kraftfuttermischwerk";
|
2022-05-26 00:41:57 +02:00
|
|
|
dj-spock = "https://www.mixcloud.com/dj_spock/";
|
|
|
|
LoungeControl = "https://www.mixcloud.com/LoungeControl/";
|
|
|
|
sh1bumi = "https://soundcloud.com/sh1bumi";
|
|
|
|
shroombab = "https://www.mixcloud.com/shroombab/";
|
|
|
|
tasmo = "https://www.mixcloud.com/tasmo/";
|
|
|
|
vidister = "https://mixcloud.com/vidister/";
|
|
|
|
};
|
|
|
|
|
|
|
|
generateYoutubedlMixcloudUnits = source: url: (
|
|
|
|
nameValuePair "youtube-dl-mixcloud-${source}" {
|
|
|
|
serviceConfig = {
|
|
|
|
User = "data-mixcloud";
|
|
|
|
Group = "data-mixcloud";
|
|
|
|
Restart="on-failure";
|
|
|
|
};
|
2023-01-18 20:40:45 +01:00
|
|
|
wants = [ "youtube-dl-prepare.service" ];
|
|
|
|
after = [ "youtube-dl-prepare.service" ];
|
2022-05-26 00:41:57 +02:00
|
|
|
path = [ pkgs.youtube-dl ];
|
|
|
|
script = ''
|
|
|
|
mkdir -p /data/mixcloud/${source}/
|
|
|
|
cd /data/mixcloud/${source}/
|
2023-02-17 22:02:27 +01:00
|
|
|
youtube-dl --ignore-errors --playlist-random --download-archive .already-downloaded.txt --newline -x --audio-format mp3 ${url}
|
2022-05-26 00:41:57 +02:00
|
|
|
'';
|
|
|
|
startAt = "*-*-* 05:05:00";
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
generateYoutubedlMixcloudTimers = source: url: (
|
|
|
|
nameValuePair "youtube-dl-mixcloud-${source}" {
|
|
|
|
timerConfig = {
|
|
|
|
RandomizedDelaySec = 10800;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
in {
|
2023-05-16 08:13:12 +02:00
|
|
|
age.secrets.mixcloud-htpasswd = {
|
|
|
|
owner = "nginx";
|
|
|
|
group = "nginx";
|
|
|
|
};
|
|
|
|
|
2022-01-02 21:55:09 +01:00
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
"mixcloud.clerie.de" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
alias = "/data/mixcloud/";
|
2023-05-02 20:40:30 +02:00
|
|
|
basicAuthFile = config.age.secrets.mixcloud-htpasswd.path;
|
2022-01-02 21:55:09 +01:00
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
2022-05-26 01:04:25 +02:00
|
|
|
autoindex_exact_size off;
|
2022-01-02 21:55:09 +01:00
|
|
|
'';
|
|
|
|
};
|
2023-04-29 21:03:02 +02:00
|
|
|
locations."/media/" = {
|
|
|
|
alias = "/data/media/";
|
2023-05-02 20:40:30 +02:00
|
|
|
basicAuthFile = config.age.secrets.mixcloud-htpasswd.path;
|
2023-04-29 21:03:02 +02:00
|
|
|
extraConfig = ''
|
|
|
|
autoindex on;
|
|
|
|
autoindex_exact_size off;
|
|
|
|
'';
|
|
|
|
};
|
2022-01-02 21:55:09 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.data-mixcloud = {
|
|
|
|
group = "data-mixcloud";
|
|
|
|
home = "/data/mixcloud";
|
|
|
|
useDefaultShell = true;
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
users.groups.data-mixcloud = {};
|
|
|
|
|
2024-02-18 14:58:45 +01:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /data/mixcloud - data-mixcloud data-mixcloud - -"
|
|
|
|
];
|
|
|
|
|
|
|
|
systemd.services = (mapAttrs' generateYoutubedlMixcloudUnits mixcloudSources);
|
2022-05-26 00:41:57 +02:00
|
|
|
systemd.timers = (mapAttrs' generateYoutubedlMixcloudTimers mixcloudSources);
|
2022-01-02 21:55:09 +01:00
|
|
|
}
|