feat(nos): reenable subtitle management
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2025-01-28 00:08:00 -05:00
parent 6aec344314
commit d624d33b01
12 changed files with 59 additions and 63 deletions

Binary file not shown.

View file

@ -139,7 +139,9 @@ const main = async(): Promise<void> => {
} }
// Extract all subs // Extract all subs
subs.forEach((sub) => { extractSub(sub); }); subs.forEach((sub) => {
extractSub(sub);
});
}); });
removeContainerSubs(); removeContainerSubs();

View file

@ -8,8 +8,6 @@
./obsidian-livesync ./obsidian-livesync
./qbittorrent ./qbittorrent
./snapraid ./snapraid
./subtitles
# TODO: I need to actually do this properly before unleashing it on my library
# ./subtitles
]; ];
} }

View file

@ -1,30 +0,0 @@
{pkgs, ...}: let
scriptSrc = pkgs.fetchFromGitHub {
owner = "brianspilner01";
repo = "media-server-scripts";
rev = "00d9efcd37bb2667d23d7747240b59291cde64d3";
hash = "sha256-Qql6Z+smU8vEJaai0POjdMnYpET9ak4NddNQevEQ8Ds=";
};
script = pkgs.concatTextFile {
name = "sub-clean.sh";
files = ["${scriptSrc}/sub-clean.sh"];
executable = true;
};
in
pkgs.writeShellApplication {
name = "sub-clean";
runtimeInputs = builtins.attrValues {
inherit
(pkgs)
findutils
gnugrep
gawk
;
};
text = ''
exec ${script} "$@"
'';
}

View file

@ -1,13 +1,12 @@
{pkgs, ...}: {
pkgs.writeShellApplication { writeShellApplication,
name = "convertMkv"; ffmpeg-full,
...
}:
writeShellApplication {
name = "convert-mkv";
runtimeInputs = builtins.attrValues { runtimeInputs = [ffmpeg-full];
inherit
(pkgs)
ffmpeg-full
;
};
text = '' text = ''
extension="$1" extension="$1"

View file

@ -2,17 +2,15 @@
config, config,
mainUser, mainUser,
pkgs, pkgs,
self,
... ...
} @ inputs: let } @ extraArgs: let
convertMkv = pkgs.callPackage ./convert.nix {inherit pkgs;}; inherit (self.appsPackages.${pkgs.system}) extract-subs;
extractSubs = pkgs.callPackage ./extract-subs {inherit pkgs;}; inherit (self.packages.${pkgs.system}) subscleaner;
sub-clean = pkgs.callPackage ./cleanup.nix {inherit pkgs;};
bazarr-bulk = pkgs.callPackage ./syncing.nix inputs;
in {
# TODO:
# - Improve cleanup
# - figure out bazarr postprocessing with syncing subs
convert-mkv = pkgs.callPackage ./convert.nix {};
bazarr-bulk = pkgs.callPackage ./syncing.nix ({} // extraArgs);
in {
environment.systemPackages = [ environment.systemPackages = [
bazarr-bulk bazarr-bulk
]; ];
@ -25,22 +23,22 @@ in {
}; };
path = [ path = [
convertMkv
extractSubs
sub-clean
bazarr-bulk bazarr-bulk
convert-mkv
extract-subs
subscleaner
]; ];
script = '' script = ''
# Make sure every video file is a mkv # Make sure every video file is a mkv
find /data/{anime,history,movies,tv} -name '*.mp4' -exec convertMkv "mp4" "{}" \; find /data/{anime,history,movies,tv} -name '*.mp4' -exec convert-mkv "mp4" "{}" \;
# Export subs from mkv files # Export subs from mkv files
find /data/{anime,history,movies,tv} -name '*.mkv' -printf "%h\0" | find /data/{anime,history,movies,tv} -name '*.mkv' -printf "%h\0" |
xargs -0 -I '{}' extract-subs '{}' "eng,fre" xargs -0 -I '{}' extract-subs '{}' "eng,fre"
# Remove ads and stuff in subs # Remove ads and stuff in subs
find /data/{anime,history,movies,tv} -name '*.srt' -exec sub-clean "{}" \; find /data/{anime,history,movies,tv} -name '*.srt' | subscleaner
# Bulk sync everything # Bulk sync everything
bb movies sync bb movies sync

View file

@ -2,14 +2,17 @@
bazarr-bulk, bazarr-bulk,
config, config,
lib, lib,
pkgs, system,
writeShellApplication,
... ...
}: let }: let
bbPkg = bazarr-bulk.packages.${pkgs.system}.default; inherit (lib) getExe;
bbPkg = bazarr-bulk.packages.${system}.default;
in in
pkgs.writeShellApplication { writeShellApplication {
name = "bb"; name = "bb";
text = '' text = ''
exec ${lib.getExe bbPkg} --config ${config.sops.secrets.bazarr-bulk.path} "$@" exec ${getExe bbPkg} --config ${config.sops.secrets.bazarr-bulk.path} "$@"
''; '';
} }

Binary file not shown.

BIN
flake.nix

Binary file not shown.

View file

@ -67,6 +67,11 @@ let
repo = "nurl"; repo = "nurl";
}; };
poetry2nix = mkInput {
owner = "nix-community";
repo = "poetry2nix";
};
# These are here to make sure all 'systems' and popular inputs are the same # These are here to make sure all 'systems' and popular inputs are the same
flake-compat = mkInput { flake-compat = mkInput {
owner = "edolstra"; owner = "edolstra";
@ -336,6 +341,11 @@ let
owner = "rushsteve1"; owner = "rushsteve1";
repo = "trash-d"; repo = "trash-d";
} }
{
type = "gitlab";
owner = "rogs";
repo = "subscleaner";
}
{ {
type = "gitlab"; type = "gitlab";
owner = "mishakmak"; owner = "mishakmak";

View file

@ -45,6 +45,10 @@
some-sass-language-server = pkgs.callPackage ./some-sass-language-server {}; some-sass-language-server = pkgs.callPackage ./some-sass-language-server {};
subscleaner = pkgs.callPackage ./subscleaner {
inherit (inputs) poetry2nix subscleaner-src;
};
trash-d = pkgs.callPackage ./trash-d { trash-d = pkgs.callPackage ./trash-d {
inherit (inputs) trash-d-src; inherit (inputs) trash-d-src;
}; };

View file

@ -0,0 +1,12 @@
{
pkgs,
poetry2nix,
subscleaner-src,
...
}: let
inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication;
in
mkPoetryApplication {
projectDir = subscleaner-src;
preferWheels = true;
}