download & stream-dl units + ryot disabled

This commit is contained in:
2024-06-12 23:59:44 -06:00
parent 1c61865222
commit 17c3d7a98f
6 changed files with 161 additions and 85 deletions

View File

@@ -1,42 +1,93 @@
{ pkgs, lib, ... }: {
{ pkgs, lib, config, ... }: {
imports = [ ./base.nix ];
options.my.units.download.enable = lib.mkEnableOption "enable";
config = {
home-manager.users.jawz = {
xdg.configFile."gallery-dl/config.json".source =
../../dotfiles/gallery-dl/config.json;
services.lorri.enable = true;
programs = {
bash = {
shellAliases = {
comic =
''download -u jawz -i "$(cat $LC | fzf --multi --exact -i)"'';
gallery =
''download -u jawz -i "$(cat $LW | fzf --multi --exact -i)"'';
dl = "download -u jawz -i";
programs.bash = {
shellAliases = {
comic = ''download -u jawz -i "$(cat $LC | fzf --multi --exact -i)"'';
gallery =
''download -u jawz -i "$(cat $LW | fzf --multi --exact -i)"'';
dl = "download -u jawz -i";
};
initExtra = ''
list_root=$XDG_CONFIG_HOME/jawz/lists/jawz
export LW=$list_root/watch.txt
export LI=$list_root/instant.txt
export LC=$list_root/comic.txt
'';
};
};
systemd.user = lib.mkIf config.my.units.download.enable {
services = let
mkDownloadService = desc: execStartCmd: {
restartIfChanged = true;
description = "Downloads ${desc}";
wantedBy = [ "default.target" ];
path = [ pkgs.bash ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = execStartCmd;
};
initExtra = ''
list_root=$XDG_CONFIG_HOME/jawz/lists/jawz
export LW=$list_root/watch.txt
export LI=$list_root/instant.txt
export LC=$list_root/comic.txt
'';
};
in {
tuhmayto = mkDownloadService "tuhmayto stuff" ''
/etc/profiles/per-user/jawz/bin/download \
-u jawz -i https://twitter.com/tuhmayto/media \
https://www.furaffinity.net/user/tuhmayto/'';
"download@" = mkDownloadService "post from multiple sources"
"/etc/profiles/per-user/jawz/bin/download %I";
"instagram@" = mkDownloadService "post types from instagram" ''
/etc/profiles/per-user/jawz/bin/download \
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 {
"instagram@stories" = downloadTimer "*-*-* 08:12:00" 120 // { };
"download@main" = downloadTimer "*-*-* 06,18:02:00" 30 // { };
"download@push" = downloadTimer "*:0/5" 30 // { };
"download@manga" = downloadTimer "Fri *-*-* 03:08:00" 30 // { };
# "download@kemono" = downloadTimer
# "*-*-1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31 18:06:00" 60 // { };
tuhmayto = {
enable = true;
description = "Downloads tuhmayto stuff";
wantedBy = [ "timers.target" ];
timerConfig = { OnCalendar = "*:0/10"; };
};
};
};
users.users.jawz.packages = [ pkgs.gallery-dl ];
my.scripts.download = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "download";
package = with pkgs.python3Packages;
(buildPythonApplication {
pname = "download";
version = "2.5";
src = ../../scripts/download/.;
buildInputs = [ setuptools ];
propagatedBuildInputs = [ pyyaml types-pyyaml yt-dlp ];
});
package = pkgs.python3Packages.buildPythonApplication {
pname = "download";
version = "2.5";
src = ../../scripts/download/.;
buildInputs =
[ pkgs.python3Packages.setuptools pkgs.gallery-dl pkgs.ffmpeg ];
propagatedBuildInputs = with pkgs.python3Packages; [
pyyaml
types-pyyaml
yt-dlp
];
};
};
};
}

View File

@@ -0,0 +1,47 @@
{ pkgs, lib, config, ... }: {
imports = [ ./base.nix ];
options.my.units.stream-dl.enable = lib.mkEnableOption "enable";
config = let
stream-dl = pkgs.writeScriptBin "stream-dl"
(builtins.readFile ../../scripts/stream-dl.sh);
in {
systemd.user = lib.mkIf config.my.units.stream-dl.enable {
services."stream@" = {
description = "monitors a stream channel for online streams.";
restartIfChanged = true;
wantedBy = [ "default.target" ];
path = [ pkgs.nix stream-dl ];
serviceConfig = {
Restart = "on-failure";
RestartSec = 30;
ExecStart = "${stream-dl}/bin/stream-dl %I";
};
};
timers = let
streamTimer = {
enable = true;
description = "monitors a stream channel for online streams.";
wantedBy = [ "timers.target" ];
timerConfig = {
OnBootSec = "5min";
OnUnitActiveSec = "65min";
RandomizedDelaySec = 30;
};
};
in {
"stream@johnneal911" = streamTimer // { };
"stream@uk2011boy" = streamTimer // { };
"stream@tommy9x6" = streamTimer // { };
"stream@brocollirob" = streamTimer // { };
"stream@tomayto\\x20picarto" = streamTimer // { };
};
};
my.scripts.stream-dl = {
enable = lib.mkDefault false;
install = true;
service = false;
name = "stream-dl";
package = stream-dl;
};
};
}