96 lines
2.9 KiB
Nix
96 lines
2.9 KiB
Nix
{
|
|
inputs,
|
|
pkgs,
|
|
lib,
|
|
config,
|
|
...
|
|
}:
|
|
let
|
|
download = import ./common.nix {
|
|
inherit
|
|
config
|
|
inputs
|
|
lib
|
|
pkgs
|
|
;
|
|
};
|
|
in
|
|
{
|
|
options.my.units = {
|
|
download.enable = lib.mkEnableOption "media download automation scripts";
|
|
downloadManga.enable = lib.mkEnableOption "manga download automation";
|
|
};
|
|
config = {
|
|
systemd.user = {
|
|
services =
|
|
let
|
|
mkDownloadService = desc: execStartCmd: {
|
|
restartIfChanged = true;
|
|
description = "Downloads ${desc}";
|
|
wantedBy = [ "default.target" ];
|
|
path = [ pkgs.bash ];
|
|
serviceConfig = {
|
|
TimeoutStartSec = 2000;
|
|
TimeoutStopSec = 2000;
|
|
Restart = "on-failure";
|
|
RestartSec = 30;
|
|
ExecStart = "${download.wrappedDownload}/bin/download ${execStartCmd}";
|
|
}
|
|
// lib.optionalAttrs (download.gallerySecretsPath != null) {
|
|
EnvironmentFile = download.gallerySecretsPath;
|
|
};
|
|
};
|
|
in
|
|
{
|
|
tuhmayto = lib.mkIf config.my.units.download.enable (
|
|
mkDownloadService "tuhmayto stuff" ''
|
|
-u jawz -i https://x.com/tuhmayto/media \
|
|
https://www.furaffinity.net/user/tuhmayto/ \
|
|
https://bsky.app/profile/tumayto.bsky.social''
|
|
);
|
|
"download@" = lib.mkIf (config.my.units.download.enable || config.my.units.downloadManga.enable) (
|
|
mkDownloadService "post from multiple sources" "%I"
|
|
);
|
|
"instagram@" = lib.mkIf config.my.units.download.enable (
|
|
mkDownloadService "post types from instagram" "instagram -u jawz -t %I"
|
|
);
|
|
};
|
|
timers =
|
|
let
|
|
downloadTimer = time: delay: {
|
|
enable = true;
|
|
description = "Downloads post types from different sites";
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig = {
|
|
OnCalendar = time;
|
|
RandomizedDelaySec = delay;
|
|
Persistent = true;
|
|
};
|
|
};
|
|
in
|
|
{
|
|
"download@main" = lib.mkIf config.my.units.download.enable (
|
|
downloadTimer "*-*-* 06,18:02:00" 30 // { }
|
|
);
|
|
"download@push" = lib.mkIf config.my.units.download.enable (downloadTimer "*:0/5" 30 // { });
|
|
"download@manga" = lib.mkIf config.my.units.downloadManga.enable (
|
|
downloadTimer "*-*-* 03:08:00" 30 // { }
|
|
);
|
|
tuhmayto = lib.mkIf config.my.units.download.enable {
|
|
enable = true;
|
|
description = "Downloads tuhmayto stuff";
|
|
wantedBy = [ "timers.target" ];
|
|
timerConfig.OnCalendar = "*:0/10";
|
|
};
|
|
};
|
|
};
|
|
my.scripts.download = {
|
|
enable = lib.mkDefault false;
|
|
install = true;
|
|
service = false;
|
|
name = "download";
|
|
package = download.wrappedDownload;
|
|
};
|
|
};
|
|
}
|