download & stream-dl units + ryot disabled

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

View File

@ -1,8 +1,4 @@
{ config, lib, pkgs, ... }: { pkgs, ... }: {
let
stream-dl = pkgs.writeScriptBin "stream-dl"
(builtins.readFile ../../scripts/stream-dl.sh);
in {
imports = imports =
[ ./servers.nix ./docker.nix ./hardware-configuration.nix ../../base.nix ]; [ ./servers.nix ./docker.nix ./hardware-configuration.nix ../../base.nix ];
my = { my = {
@ -15,6 +11,10 @@ in {
python.enable = true; python.enable = true;
sh.enable = true; sh.enable = true;
}; };
units = {
download.enable = true;
stream-dl.enable = true;
};
scripts = { scripts = {
run.enable = true; run.enable = true;
split-dir.enable = true; split-dir.enable = true;
@ -120,20 +120,8 @@ in {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
}; };
}; };
timers = { };
user = { user = {
services = { 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";
};
};
# unpackerr = { # unpackerr = {
# enable = true; # enable = true;
# restartIfChanged = true; # restartIfChanged = true;
@ -159,24 +147,7 @@ in {
}; };
}; };
}; };
timers = let timers.qbit_manage = {
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 // { };
qbit_manage = {
enable = true; enable = true;
description = "Tidy up my torrents"; description = "Tidy up my torrents";
wantedBy = [ "timers.target" ]; wantedBy = [ "timers.target" ];
@ -184,5 +155,4 @@ in {
}; };
}; };
}; };
};
} }

View File

@ -60,24 +60,24 @@
[ "/var/lib/docker-configs/vocechat:/home/vocechat-server/data" ]; [ "/var/lib/docker-configs/vocechat:/home/vocechat-server/data" ];
environment = { TZ = "America/Mexico_City"; }; environment = { TZ = "America/Mexico_City"; };
}; };
ryot = { # ryot = {
image = "ghcr.io/ignisda/ryot:latest"; # image = "ghcr.io/ignisda/ryot:v5.5.0";
ports = [ "8765:8000" ]; # ports = [ "8765:8000" ];
environment = { # environment = {
TZ = "America/Mexico_City"; # TZ = "America/Mexico_City";
DATABASE_URL = "postgres:///ryot?host=${postgresSocket}"; # DATABASE_URL = "postgres:///ryot?host=${postgresSocket}";
SERVER_INSECURE_COOKIE = "true"; # # FRONTEND_INSECURE_COOKIES = "true";
VIDEO_GAMES_TWITCH_CLIENT_ID = "tfu0hw0zbdbu4lco4h72nqkb8krxp9"; # VIDEO_GAMES_TWITCH_CLIENT_ID = "tfu0hw0zbdbu4lco4h72nqkb8krxp9";
VIDEO_GAMES_TWITCH_CLIENT_SECRET = "582ecfb01ihv6wnt8zbc9pf3hs9p54"; # VIDEO_GAMES_TWITCH_CLIENT_SECRET = "582ecfb01ihv6wnt8zbc9pf3hs9p54";
}; # };
volumes = [ "${postgresSocket}:${postgresSocket}" ]; # volumes = [ "${postgresSocket}:${postgresSocket}" ];
labels = { # labels = {
"flame.type" = "application"; # "flame.type" = "application";
"flame.name" = "Ryot"; # "flame.name" = "Ryot";
"flame.url" = "tracker.servidos.lat"; # "flame.url" = "tracker.servidos.lat";
"flame.icon" = "radar"; # "flame.icon" = "radar";
}; # };
}; # };
multi-scrobbler = { multi-scrobbler = {
image = "foxxmd/multi-scrobbler"; image = "foxxmd/multi-scrobbler";
ports = [ "9078:9078" ]; ports = [ "9078:9078" ];

View File

@ -90,6 +90,11 @@ in {
jellyfin = base // { }; jellyfin = base // { };
# prowlarr.enable = true; # prowlarr.enable = true;
# jira.enable = true; # jira.enable = true;
# adguardhome = {
# enable = true;
# mutableSettings = true;
# openFirewall = true;
# };
microbin = { microbin = {
enable = true; enable = true;
settings = { settings = {
@ -218,7 +223,7 @@ in {
"OC\\Preview\\Movie" "OC\\Preview\\Movie"
]; ];
}; };
phpExtraExtensions = all: [ all.pdlib all.bz2 ]; phpExtraExtensions = all: [ all.pdlib all.bz2 all.ldap ];
}; };
postgresql = let postgresql = let
dbNames = dbNames =
@ -240,7 +245,7 @@ in {
}; };
systemd = { systemd = {
services = { services = {
nextcloud-cron = { path = [ pkgs.perl ]; }; nextcloud-cron.path = [ pkgs.perl ];
# sub-sync = { # sub-sync = {
# restartIfChanged = true; # restartIfChanged = true;
# description = "syncronizes subtitles downloaded & modified today"; # description = "syncronizes subtitles downloaded & modified today";

View File

@ -1,4 +1,4 @@
{ ... }: { { lib, ... }: {
imports = [ imports = [
./scripts/download.nix ./scripts/download.nix
./scripts/ffmpeg4discord.nix ./scripts/ffmpeg4discord.nix
@ -10,5 +10,8 @@
./scripts/split-dir.nix ./scripts/split-dir.nix
./scripts/tasks.nix ./scripts/tasks.nix
./scripts/update-dns.nix ./scripts/update-dns.nix
./scripts/stream-dl.nix
]; ];
my.units.download.enable = lib.mkDefault false;
my.units.stream-dl.enable = lib.mkDefault false;
} }

View File

@ -1,15 +1,14 @@
{ pkgs, lib, ... }: { { pkgs, lib, config, ... }: {
imports = [ ./base.nix ]; imports = [ ./base.nix ];
options.my.units.download.enable = lib.mkEnableOption "enable";
config = { config = {
home-manager.users.jawz = { home-manager.users.jawz = {
xdg.configFile."gallery-dl/config.json".source = xdg.configFile."gallery-dl/config.json".source =
../../dotfiles/gallery-dl/config.json; ../../dotfiles/gallery-dl/config.json;
services.lorri.enable = true; services.lorri.enable = true;
programs = { programs.bash = {
bash = {
shellAliases = { shellAliases = {
comic = comic = ''download -u jawz -i "$(cat $LC | fzf --multi --exact -i)"'';
''download -u jawz -i "$(cat $LC | fzf --multi --exact -i)"'';
gallery = gallery =
''download -u jawz -i "$(cat $LW | fzf --multi --exact -i)"''; ''download -u jawz -i "$(cat $LW | fzf --multi --exact -i)"'';
dl = "download -u jawz -i"; dl = "download -u jawz -i";
@ -22,21 +21,73 @@
''; '';
}; };
}; };
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;
};
};
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 = { my.scripts.download = {
enable = lib.mkDefault false; enable = lib.mkDefault false;
install = true; install = true;
service = false; service = false;
name = "download"; name = "download";
package = with pkgs.python3Packages; package = pkgs.python3Packages.buildPythonApplication {
(buildPythonApplication {
pname = "download"; pname = "download";
version = "2.5"; version = "2.5";
src = ../../scripts/download/.; src = ../../scripts/download/.;
buildInputs = [ setuptools ]; buildInputs =
propagatedBuildInputs = [ pyyaml types-pyyaml yt-dlp ]; [ 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;
};
};
}