2024-05-18 17:51:06 -04:00
|
|
|
{
|
|
|
|
config,
|
2024-11-22 23:15:13 -05:00
|
|
|
mainUser,
|
2024-05-18 17:51:06 -04:00
|
|
|
pkgs,
|
2025-01-28 00:08:00 -05:00
|
|
|
self,
|
2024-05-18 17:51:06 -04:00
|
|
|
...
|
2025-01-28 00:08:00 -05:00
|
|
|
} @ extraArgs: let
|
|
|
|
inherit (self.appsPackages.${pkgs.system}) extract-subs;
|
|
|
|
inherit (self.packages.${pkgs.system}) subscleaner;
|
2024-05-18 23:49:54 -04:00
|
|
|
|
2025-01-28 00:08:00 -05:00
|
|
|
convert-mkv = pkgs.callPackage ./convert.nix {};
|
|
|
|
bazarr-bulk = pkgs.callPackage ./syncing.nix ({} // extraArgs);
|
|
|
|
in {
|
2024-05-18 23:49:54 -04:00
|
|
|
environment.systemPackages = [
|
|
|
|
bazarr-bulk
|
2024-05-18 00:04:26 -04:00
|
|
|
];
|
2024-05-18 23:49:54 -04:00
|
|
|
|
2024-05-18 17:51:06 -04:00
|
|
|
systemd = {
|
|
|
|
services.manage-subs = {
|
|
|
|
serviceConfig = {
|
|
|
|
User = mainUser;
|
|
|
|
Group = config.users.users.${mainUser}.group;
|
|
|
|
};
|
|
|
|
|
|
|
|
path = [
|
2024-05-18 23:49:54 -04:00
|
|
|
bazarr-bulk
|
2025-01-28 00:08:00 -05:00
|
|
|
convert-mkv
|
|
|
|
extract-subs
|
|
|
|
subscleaner
|
2024-05-18 17:51:06 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
# Make sure every video file is a mkv
|
2025-01-28 00:08:00 -05:00
|
|
|
find /data/{anime,history,movies,tv} -name '*.mp4' -exec convert-mkv "mp4" "{}" \;
|
2024-05-18 17:51:06 -04:00
|
|
|
|
|
|
|
# Export subs from mkv files
|
|
|
|
find /data/{anime,history,movies,tv} -name '*.mkv' -printf "%h\0" |
|
|
|
|
xargs -0 -I '{}' extract-subs '{}' "eng,fre"
|
|
|
|
|
|
|
|
# Remove ads and stuff in subs
|
2025-01-28 00:08:00 -05:00
|
|
|
find /data/{anime,history,movies,tv} -name '*.srt' | subscleaner
|
2024-05-18 23:49:54 -04:00
|
|
|
|
|
|
|
# Bulk sync everything
|
|
|
|
bb movies sync
|
|
|
|
bb tv-shows sync
|
2024-05-18 17:51:06 -04:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-05-18 23:49:54 -04:00
|
|
|
timers.manage-subs = {
|
2024-05-18 17:51:06 -04:00
|
|
|
wantedBy = ["timers.target"];
|
|
|
|
partOf = ["manage-subs.service"];
|
|
|
|
timerConfig.OnCalendar = ["0:00:00"];
|
|
|
|
};
|
|
|
|
};
|
2024-05-18 00:04:26 -04:00
|
|
|
}
|