about summary refs log tree commit diff
path: root/pkgs/applications/video/mpv/scripts/autosubsync-mpv.nix
blob: d162da18c018a184fd0eb72f4c6ba468c0ee9864 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  lib,
  fetchFromGitHub,
  buildLua,
  alass,
}:

buildLua {
  pname = "autosubsync-mpv";
  version = "0-unstable-2022-12-26";

  src = fetchFromGitHub {
    owner = "joaquintorres";
    repo = "autosubsync-mpv";
    rev = "22cb928ecd94cc8cadaf8c354438123c43e0c70d";
    sha256 = "sha256-XQPFC7l9MTZAW5FfULRQJfu/7FuGj9bbjQUZhNv0rlc=";
  };

  # While nixpkgs only packages alass, we might as well make that the default
  patchPhase = ''
    runHook prePatch
    substituteInPlace autosubsync.lua                                            \
      --replace-warn 'alass_path = ""' 'alass_path = "${alass}/bin/alass-cli"'   \
      --replace-warn 'audio_subsync_tool = "ask"' 'audio_subsync_tool = "alass"' \
      --replace-warn 'altsub_subsync_tool = "ask"' 'altsub_subsync_tool = "alass"'
    runHook postPatch
  '';

  scriptPath = "./";
  passthru.scriptName = "autosubsync-mpv";

  meta = with lib; {
    description = "Automatically sync subtitles in mpv using the `n` button";
    homepage = "https://github.com/joaquintorres/autosubsync-mpv";
    maintainers = with maintainers; [ kovirobi ];
    license = licenses.mit;
  };
}