feat(nos): reenable subtitle management
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
6aec344314
commit
d624d33b01
12 changed files with 59 additions and 63 deletions
BIN
apps/config/package-lock.json
generated
BIN
apps/config/package-lock.json
generated
Binary file not shown.
|
@ -98,8 +98,8 @@ const findSubs = (
|
||||||
streams: FfprobeStream[],
|
streams: FfprobeStream[],
|
||||||
): FfprobeStream[] => {
|
): FfprobeStream[] => {
|
||||||
const subs = streams.filter((s) => s.tags?.language &&
|
const subs = streams.filter((s) => s.tags?.language &&
|
||||||
s.tags.language === lang &&
|
s.tags.language === lang &&
|
||||||
s.codec_type === 'subtitle');
|
s.codec_type === 'subtitle');
|
||||||
|
|
||||||
const pgs = subs.filter((s) => s.codec_name === 'hdmv_pgs_subtitle');
|
const pgs = subs.filter((s) => s.codec_name === 'hdmv_pgs_subtitle');
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -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
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -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} "$@"
|
|
||||||
'';
|
|
||||||
}
|
|
|
@ -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"
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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} "$@"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
BIN
flake.nix
BIN
flake.nix
Binary file not shown.
|
@ -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";
|
||||||
|
|
|
@ -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;
|
||||||
};
|
};
|
||||||
|
|
12
packages/subscleaner/default.nix
Normal file
12
packages/subscleaner/default.nix
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
poetry2nix,
|
||||||
|
subscleaner-src,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (poetry2nix.lib.mkPoetry2Nix {inherit pkgs;}) mkPoetryApplication;
|
||||||
|
in
|
||||||
|
mkPoetryApplication {
|
||||||
|
projectDir = subscleaner-src;
|
||||||
|
preferWheels = true;
|
||||||
|
}
|
Loading…
Reference in a new issue