refactor(subtitles): cleanup file structure of module
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-03-26 11:26:06 -04:00
parent 9fb211e673
commit bec85ec552
10 changed files with 108 additions and 116 deletions

View file

@ -13,8 +13,8 @@ in {
./modules/mergerfs.nix ./modules/mergerfs.nix
./modules/qbittorrent ./modules/qbittorrent
./modules/snapraid.nix ./modules/snapraid.nix
./modules/subtitles/sub-clean.nix ./modules/subtitles/cleanup.nix
./modules/subtitles/subsync ./modules/subtitles/syncing
]; ];
vars = { vars = {

View file

@ -1,53 +0,0 @@
{
config,
pkgs,
pocketsphinx-src,
subsync-src,
...
}: let
inherit (config.vars) mainUser;
sphinxbase = pkgs.callPackage ./sphinxbase.nix {};
pocketsphinx = pkgs.callPackage ./pocketsphinx.nix {
inherit sphinxbase pocketsphinx-src;
};
subsync = pkgs.callPackage ./subsync.nix {
inherit sphinxbase pocketsphinx subsync-src;
};
in {
systemd = {
services.subsync-job = {
serviceConfig = {
Type = "oneshot";
User = mainUser;
Group = config.users.users.${mainUser}.group;
};
path = with pkgs; [
findutils
subsync
(writeShellApplication {
name = "sync-sub";
runtimeInputs = [subsync];
text = ''
# TODO: sync on a specific file
# $1 = file path
'';
})
];
script = ''
find /data/anime -name '*.srt' -exec sync-sub "{}" \;
find /data/movies -name '*.srt' -exec sync-sub "{}" \;
find /data/tv -name '*.srt' -exec sync-sub "{}" \;
'';
};
timers.subsync-job = {
wantedBy = ["timers.target"];
partOf = ["subsync-job.service"];
timerConfig.OnCalendar = ["0:00:00"];
};
};
}

View file

@ -1,61 +0,0 @@
{
ffmpeg,
pkg-config,
pocketsphinx,
python3Packages,
sphinxbase,
subsync-src,
...
}: let
inherit (builtins) concatStringsSep;
in
python3Packages.buildPythonPackage {
pname = "subsync";
version = subsync-src.shortRev;
src = subsync-src;
buildInputs = [
ffmpeg
pkg-config
pocketsphinx
sphinxbase
];
nativeBuildInputs = with python3Packages; [
pip
setuptools
wheel
];
propagatedBuildInputs = with python3Packages; [
certifi
cryptography
pybind11
pycryptodome
pysubs2
pyyaml
requests
utils
];
patches = [
./patches/cmd_ln.patch
./patches/cstdint.patch
];
# The tests are for the GUI
doCheck = false;
# 'pip install .' takes care of building the package
buildPhase = "";
installPhase = ''
python -m pip install . ${concatStringsSep " " [
"--no-index"
"--no-warn-script-location"
"--prefix=\"$out\""
"--no-cache"
]}
'';
}

View file

@ -0,0 +1,39 @@
{
config,
pkgs,
pocketsphinx-src,
subsync-src,
...
}: let
inherit (config.vars) mainUser;
subsync = pkgs.callPackage ./subsync {
inherit pocketsphinx-src subsync-src;
};
in {
systemd = {
services.subsync-job = {
serviceConfig = {
Type = "oneshot";
User = mainUser;
Group = config.users.users.${mainUser}.group;
};
path = with pkgs; [
findutils
subsync
];
script = ''
find /data/anime -name '*.srt' -exec node-syncsub "{}" \;
find /data/movies -name '*.srt' -exec node-syncsub "{}" \;
find /data/tv -name '*.srt' -exec node-syncsub "{}" \;
'';
};
timers.subsync-job = {
wantedBy = ["timers.target"];
partOf = ["subsync-job.service"];
timerConfig.OnCalendar = ["0:00:00"];
};
};
}

View file

@ -0,0 +1,67 @@
{
callPackage,
ffmpeg,
pkg-config,
pocketsphinx-src,
python3Packages,
subsync-src,
...
} @ pkgs: let
inherit (builtins) concatStringsSep;
sphinxbase = callPackage ./sphinxbase.nix pkgs;
pocketsphinx =
callPackage ./pocketsphinx.nix (pkgs
// {inherit pocketsphinx-src sphinxbase;});
in
python3Packages.buildPythonPackage {
pname = "subsync";
version = subsync-src.shortRev;
src = subsync-src;
buildInputs = [
ffmpeg
pkg-config
pocketsphinx
sphinxbase
];
nativeBuildInputs = with python3Packages; [
pip
setuptools
wheel
];
propagatedBuildInputs = with python3Packages; [
certifi
cryptography
pybind11
pycryptodome
pysubs2
pyyaml
requests
utils
];
patches = [
./patches/cmd_ln.patch
./patches/cstdint.patch
];
# The tests are for the GUI
doCheck = false;
# 'pip install .' takes care of building the package
buildPhase = "";
installPhase = ''
python -m pip install . ${concatStringsSep " " [
"--no-index"
"--no-warn-script-location"
"--prefix=\"$out\""
"--no-cache"
]}
'';
}