diff --git a/devices/nos/default.nix b/devices/nos/default.nix index b6b4eee..2d82968 100644 --- a/devices/nos/default.nix +++ b/devices/nos/default.nix @@ -14,7 +14,7 @@ in { ./modules/qbittorrent ./modules/snapraid.nix ./modules/subtitles/cleanup.nix - ./modules/subtitles/syncing + ./modules/subtitles/syncing.nix ]; vars = { diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/.envrc b/devices/nos/modules/subtitles/node-syncsub/.envrc similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/.envrc rename to devices/nos/modules/subtitles/node-syncsub/.envrc diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/.eslintrc.json b/devices/nos/modules/subtitles/node-syncsub/.eslintrc.json similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/.eslintrc.json rename to devices/nos/modules/subtitles/node-syncsub/.eslintrc.json diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/default.nix b/devices/nos/modules/subtitles/node-syncsub/default.nix similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/default.nix rename to devices/nos/modules/subtitles/node-syncsub/default.nix diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/lang-codes.ts b/devices/nos/modules/subtitles/node-syncsub/lang-codes.ts similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/lang-codes.ts rename to devices/nos/modules/subtitles/node-syncsub/lang-codes.ts diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/main.ts b/devices/nos/modules/subtitles/node-syncsub/main.ts similarity index 97% rename from devices/nos/modules/subtitles/syncing/node-syncsub/main.ts rename to devices/nos/modules/subtitles/node-syncsub/main.ts index f80e548..4e605fa 100755 --- a/devices/nos/modules/subtitles/syncing/node-syncsub/main.ts +++ b/devices/nos/modules/subtitles/node-syncsub/main.ts @@ -97,6 +97,11 @@ async function main() { // ffprobe the video file to see available audio tracks ffProbe(VIDEO, (_e, data) => { + if (!data?.streams) { + console.error('Couldn\'t find streams in video file'); + process.exit(1); + } + const AVAIL_LANGS = data.streams .filter((s) => s.codec_type === 'audio') .map((s) => s['tags'] && s['tags']['language']); diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/package-lock.json b/devices/nos/modules/subtitles/node-syncsub/package-lock.json similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/package-lock.json rename to devices/nos/modules/subtitles/node-syncsub/package-lock.json diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/package.json b/devices/nos/modules/subtitles/node-syncsub/package.json similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/package.json rename to devices/nos/modules/subtitles/node-syncsub/package.json diff --git a/devices/nos/modules/subtitles/syncing/node-syncsub/tsconfig.json b/devices/nos/modules/subtitles/node-syncsub/tsconfig.json similarity index 100% rename from devices/nos/modules/subtitles/syncing/node-syncsub/tsconfig.json rename to devices/nos/modules/subtitles/node-syncsub/tsconfig.json diff --git a/devices/nos/modules/subtitles/syncing/default.nix b/devices/nos/modules/subtitles/syncing.nix similarity index 66% rename from devices/nos/modules/subtitles/syncing/default.nix rename to devices/nos/modules/subtitles/syncing.nix index 68133e6..bd322fa 100644 --- a/devices/nos/modules/subtitles/syncing/default.nix +++ b/devices/nos/modules/subtitles/syncing.nix @@ -1,20 +1,18 @@ { config, pkgs, - pocketsphinx-src, - subsync-src, + subsync, ... }: let inherit (config.vars) mainUser; - subsync = pkgs.callPackage ./subsync { - inherit pocketsphinx-src subsync-src; - }; + subsyncPkg = subsync.packages.${pkgs.system}.default; + node-syncsub = pkgs.callPackage ./node-syncsub { - inherit subsync; + subsync = subsyncPkg; }; in { - environment.systemPackages = [subsync node-syncsub]; + environment.systemPackages = [subsyncPkg node-syncsub]; systemd = { services.subsync-job = { @@ -26,7 +24,6 @@ in { path = with pkgs; [ findutils - subsync node-syncsub ]; @@ -36,10 +33,10 @@ in { # find /data/tv -name '*.mkv' -printf "%h\0" | xargs -0 -I '{}' node-syncsub '{}' "eng,fra" ''; }; - timers.subsync-job = { - wantedBy = ["timers.target"]; - partOf = ["subsync-job.service"]; - timerConfig.OnCalendar = ["0:00:00"]; - }; + #timers.subsync-job = { + # wantedBy = ["timers.target"]; + # partOf = ["subsync-job.service"]; + # timerConfig.OnCalendar = ["0:00:00"]; + #}; }; } diff --git a/devices/nos/modules/subtitles/syncing/subsync/default.nix b/devices/nos/modules/subtitles/syncing/subsync/default.nix deleted file mode 100644 index f796a14..0000000 --- a/devices/nos/modules/subtitles/syncing/subsync/default.nix +++ /dev/null @@ -1,64 +0,0 @@ -{ - 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 - sphinxbase - pocketsphinx - ]; - - nativeBuildInputs = with python3Packages; [ - pip - setuptools - wheel - ]; - - propagatedBuildInputs = with python3Packages; [ - certifi - cryptography - pybind11 - pycryptodome - pysubs2 - pyyaml - requests - utils - ]; - - patches = [./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" - ]} - ''; - } diff --git a/devices/nos/modules/subtitles/syncing/subsync/patches/cstdint.patch b/devices/nos/modules/subtitles/syncing/subsync/patches/cstdint.patch deleted file mode 100644 index adb6a56..0000000 --- a/devices/nos/modules/subtitles/syncing/subsync/patches/cstdint.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff --git a/gizmo/text/utf8.h b/gizmo/text/utf8.h -index 7c3bcdb..99f1a92 100644 ---- a/gizmo/text/utf8.h -+++ b/gizmo/text/utf8.h -@@ -2,6 +2,7 @@ - #define __UTF8_H__ - - #include -+#include - - - class Utf8 - -diff --git a/gizmo/text/ssa.h b/gizmo/text/ssa.h -index 66d9918..170e265 100644 ---- a/gizmo/text/ssa.h -+++ b/gizmo/text/ssa.h -@@ -5,6 +5,7 @@ - #include - #include - #include -+#include - - - class SSAParser diff --git a/devices/nos/modules/subtitles/syncing/subsync/patches/distutils.patch b/devices/nos/modules/subtitles/syncing/subsync/patches/distutils.patch deleted file mode 100644 index ac30051..0000000 --- a/devices/nos/modules/subtitles/syncing/subsync/patches/distutils.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4 -index 59a2ff09..af64eab2 100644 ---- a/m4/ax_python_devel.m4 -+++ b/m4/ax_python_devel.m4 -@@ -132,21 +132,6 @@ variable to configure. See ``configure --help'' for reference. - fi - fi - -- # -- # Check if you have distutils, else fail -- # -- AC_MSG_CHECKING([for the distutils Python package]) -- ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` -- if test -z "$ac_distutils_result"; then -- AC_MSG_RESULT([yes]) -- else -- AC_MSG_RESULT([no]) -- AC_MSG_ERROR([cannot import Python module "distutils". --Please check your Python installation. The error was: --$ac_distutils_result]) -- PYTHON_VERSION="" -- fi -- - # - # Check for Python include path - # diff --git a/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix b/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix deleted file mode 100644 index 10da403..0000000 --- a/devices/nos/modules/subtitles/syncing/subsync/pocketsphinx.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ - autoreconfHook, - fetchFromGitHub, - pkg-config, - python3, - sphinxbase, - stdenv, - swig2, - ... -}: -stdenv.mkDerivation { - pname = "pocketsphinx"; - version = "5prealpha"; - - src = fetchFromGitHub { - owner = "cmusphinx"; - repo = "pocketsphinx"; - rev = "5da71f0a05350c923676b02a69423d1291825d5b"; - hash = "sha256-YZwuVYg8Uqt1gOYXeYC8laRj+IObbuO9f/BjcQKRwkY="; - }; - - patches = [./patches/distutils.patch]; - - autoreconfPhase = '' - ./autogen.sh - ''; - nativeBuildInputs = [ - autoreconfHook - pkg-config - swig2 - python3 - ]; - propagatedBuildInputs = [ - sphinxbase - ]; - - postFixup = '' - cp $out/include/pocketsphinx/* $out/include - ''; -} diff --git a/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix b/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix deleted file mode 100644 index d6ad2a9..0000000 --- a/devices/nos/modules/subtitles/syncing/subsync/sphinxbase.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - autoreconfHook, - bison, - fetchFromGitHub, - pkg-config, - python3, - stdenv, - swig2, - ... -}: -stdenv.mkDerivation { - name = "sphinxbase"; - version = "5prealpha"; # Deprecated - - buildInputs = [bison pkg-config python3 swig2]; - nativeBuildInputs = [autoreconfHook]; - - autoreconfPhase = '' - ./autogen.sh - ''; - - src = fetchFromGitHub { - owner = "cmusphinx"; - repo = "sphinxbase"; - rev = "617e53691889336a482631380f75b453445d0dae"; - hash = "sha256-w/Huz4+crTzdiSyQVAx0h3lhtTTrtPyKp3xpQD5EG9g="; - }; - - postFixup = '' - cp $out/include/sphinxbase/* $out/include/ - ''; -} diff --git a/flake.lock b/flake.lock index 73aecdd..85e5a40 100644 --- a/flake.lock +++ b/flake.lock @@ -1405,6 +1405,23 @@ "type": "github" } }, + "pocketsphinx-src_2": { + "flake": false, + "locked": { + "lastModified": 1645539790, + "narHash": "sha256-YZwuVYg8Uqt1gOYXeYC8laRj+IObbuO9f/BjcQKRwkY=", + "owner": "cmusphinx", + "repo": "pocketsphinx", + "rev": "5da71f0a05350c923676b02a69423d1291825d5b", + "type": "github" + }, + "original": { + "owner": "cmusphinx", + "ref": "last-pre-1.0", + "repo": "pocketsphinx", + "type": "github" + } + }, "pointer-event-src": { "flake": false, "locked": { @@ -1496,7 +1513,7 @@ "pointer-event-src": "pointer-event-src", "pokemon-colorscripts-src": "pokemon-colorscripts-src", "secrets": "secrets", - "subsync-src": "subsync-src", + "subsync": "subsync", "touch-gestures-src": "touch-gestures-src", "trash-d-src": "trash-d-src", "vimplugin-riscv-src": "vimplugin-riscv-src", @@ -1562,19 +1579,43 @@ "type": "github" } }, - "subsync-src": { + "sphinxbase-src": { "flake": false, "locked": { - "lastModified": 1681249928, - "narHash": "sha256-jUur1U1yNShQx70/mj36+sGoVk8+E5hQUV/G79q2A2k=", - "owner": "sc0ty", - "repo": "subsync", - "rev": "8e0cf71960b9a5418acb60a1910cf3295d67e6bf", + "lastModified": 1654774494, + "narHash": "sha256-w/Huz4+crTzdiSyQVAx0h3lhtTTrtPyKp3xpQD5EG9g=", + "owner": "cmusphinx", + "repo": "sphinxbase", + "rev": "617e53691889336a482631380f75b453445d0dae", "type": "github" }, "original": { - "owner": "sc0ty", + "owner": "cmusphinx", + "repo": "sphinxbase", + "rev": "617e53691889336a482631380f75b453445d0dae", + "type": "github" + } + }, + "subsync": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "pocketsphinx-src": "pocketsphinx-src_2", + "sphinxbase-src": "sphinxbase-src" + }, + "locked": { + "lastModified": 1712018289, + "narHash": "sha256-JYG+GQuyvDoZ6TWD0lDjaWDNTq5FxNh3AymTHxWyggI=", + "owner": "matt1432", "repo": "subsync", + "rev": "ee9e1592ae4ec7c694d8857aa72be079d81ea209", + "type": "github" + }, + "original": { + "owner": "matt1432", + "repo": "subsync", + "rev": "ee9e1592ae4ec7c694d8857aa72be079d81ea209", "type": "github" } }, diff --git a/flake.nix b/flake.nix index a6a2cc8..8d38a83 100644 --- a/flake.nix +++ b/flake.nix @@ -199,6 +199,7 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + jellyfin-flake = { type = "github"; owner = "matt1432"; @@ -207,6 +208,17 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + subsync = { + type = "github"; + owner = "matt1432"; + repo = "subsync"; + + # Keep version that uses Sphinxbase + rev = "ee9e1592ae4ec7c694d8857aa72be079d81ea209"; + + inputs.nixpkgs.follows = "nixpkgs"; + }; + # Desktop inputs hyprland = { type = "github"; @@ -300,13 +312,6 @@ flake = false; }; - subsync-src = { - type = "github"; - owner = "sc0ty"; - repo = "subsync"; - flake = false; - }; - trash-d-src = { type = "github"; owner = "rushsteve1";