summaryrefslogtreecommitdiff
path: root/packages/mpv-autosub.nix
blob: e3fc2214d8e798506d09dc9b731de105e6e976c4 (plain)
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
39
40
41
42
43
44
45
46
{
  fetchFromGitHub,
  lib,
  mpv-unwrapped,
  python3Packages,
  stdenvNoCC,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
  pname = "mpv-autosub";
  version = "unstable-2021-06-29";

  src = fetchFromGitHub {
    owner = "davidde";
    repo = finalAttrs.pname;
    rev = "35115355bd339681f97d067538356c29e5b14afa";
    hash = "sha256-BKT/Tzwl5ZA4fbdc/cxz0+CYc1zyY/KOXc58x5GYow0=";
  };

  postPatch = ''
    substituteInPlace autosub.lua \
      --replace '/home/david/.local/bin/subliminal' '${python3Packages.subliminal}/bin/subliminal' \
      --replace "'Dutch', 'nl', 'dut'" "'Russian', 'ru', 'rus'" \
      --replace "'tta'" "'tta', 'webm'" \
      --replace "disabled for audio files" "disabled for this filetype"

    sed -iE '/.*add_key_binding.*/d' autosub.lua
  '';

  installPhase = ''
    runHook preInstall

    install -Dm644 autosub.lua $out/share/mpv/scripts/autosub.lua

    runHook postInstall
  '';

  passthru.scriptName = "autosub.lua";

  meta = with lib; {
    description = "Automatic downloading of subtitles for MPV";
    inherit (finalAttrs.src.meta) homepage;
    license = licenses.mit;
    inherit (mpv-unwrapped.meta) platforms;
    maintainers = with maintainers; [azahi];
  };
})