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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
{ config, lib, userName, pkgs, sources, ... }:
{
home-manager.users.${userName} = {
programs.mpv = {
enable = true;
package = pkgs.symlinkJoin {
inherit (pkgs.mpv) name;
paths = [(pkgs.mpv.override {
scripts = [
(pkgs.stdenv.mkDerivation (sources.mpv-reload // rec {
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 reload.lua $out/share/mpv/scripts/${passthru.scriptName}
'';
passthru.scriptName = "reload.lua";
}))
(pkgs.stdenv.mkDerivation (sources.mpv-createchapter // rec {
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 createchapter.lua $out/share/mpv/scripts/${passthru.scriptName}
'';
passthru.scriptName = "createchapter.lua";
}))
(pkgs.stdenv.mkDerivation (sources.mpv-autosave // rec {
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 autosave.lua $out/share/mpv/scripts/${passthru.scriptName}
'';
passthru.scriptName = "autosave.lua";
}))
(pkgs.stdenv.mkDerivation (sources.mpv-mpris // rec {
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 mpris.so $out/share/mpv/scripts/${passthru.scriptName}
'';
nativeBuildInputs = with pkgs; [ pkg-config glib mpv ffmpeg.dev ];
passthru.scriptName = "mpris.so";
}))
(pkgs.stdenv.mkDerivation (sources.mpv-chapterskip // rec {
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 chapterskip.lua $out/share/mpv/scripts/${passthru.scriptName}
'';
passthru.scriptName = "chapterskip.lua";
}))
(pkgs.stdenv.mkDerivation (sources.mpv-subselect // rec {
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 sub-select.lua $out/share/mpv/scripts/${passthru.scriptName}
'';
passthru.scriptName = "sub-select.lua";
}))
(pkgs.stdenv.mkDerivation (sources.mpv-youtube-quality // rec {
patches = [
(pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/31.patch"; hash = "sha256-2aTTkW48uRe8XC1ZQ8J5T9sUmZ5F3YAoYCMxqEs2AY8="; })
(pkgs.fetchpatch { url = "https://github.com/jgreco/mpv-youtube-quality/pull/20.patch"; hash = "sha256-X5BwDsxziYbeiQvrBt8+IS+6oH1i0LvaaYtugL790gg="; })
];
installPhase = ''
install -d $out/share/mpv/scripts
install -m 0644 youtube-quality.lua $out/share/mpv/scripts/${passthru.scriptName}
'';
passthru.scriptName = "youtube-quality.lua";
}))
];
})];
buildInputs = [ pkgs.makeWrapper ];
postBuild = ''
makeWrapper $out/bin/mpv $out/bin/mpvrm \
--add-flags "--script=${pkgs.writeTextDir "share/mpv/scripts/delete.lua" ''
del_path = '''
do_del = false
mp.add_hook('on_load', 50, function()
del_path = '''
end)
mp.add_hook('on_unload', 50, function()
del_path = mp.get_property('path')
end)
mp.add_key_binding('Ctrl+q', function()
do_del = true
mp.commandv('quit', '4')
end)
mp.register_event('end-file', function(params)
if (params.reason == 'eof' or (do_del and params.reason == 'quit')) and del_path ~= ''' then
print('deleting: '..del_path)
os.remove(del_path)
end
end)
''}/share/mpv/scripts/delete.lua"
'';
};
bindings = {
# "CTRL+n" = "af toggle \"lavfi=[dynaudnorm=f=100:g=31:s=20.0]\"";
};
config = {
ytdl = true;
subs-with-matching-audio = false;
audio-display = false;
osd-font = "Fira Sans";
sub-font = "Fira Sans";
# vo = "gpu";
vo = "gpu-next";
hwdec = "auto";
scale = "bilinear";
force-window = "yes";
# af = "lavfi=[dynaudnorm=f=100:g=31:s=20.0]";
script-opts = lib.concatStringsSep "," [
"osc-layout=topbar"
"vidscale=no"
"deadzonesize=0.9"
"ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp"
"chapterskip-skip=sponsor;intro;endcard;interact"
"chapterskip-categories=sponsor>%[SponsorBlock%]: .*Sponsor.*;intro>%[SponsorBlock%]: .*Intro Animation.*;endcard>%[SponsorBlock%]: .*Endcards.*;interact>%[SponsorBlock%]: .*Interaction Reminder.*"
"sub_select-config=${pkgs.writeTextDir "sub-select.json" (builtins.toJSON [
{
alang = "*";
slang = "forced";
}
{
alang = ["jpn" "ja"];
slang = "eng?";
blacklist = [ "sign" ];
}
{
alang = ["jpn" "ja"];
slang = "und";
blacklist = [ "sign" ];
}
{
alang = ["eng?" "deu?"];
slang = "no";
}
{
alang = "*";
slang = "eng?";
}
{
alang = "*";
slang = "und";
}
])}"
];
watch-later-options = lib.concatStringsSep "," [ "start" ];
};
};
xdg.configFile."mpv/youtube-dl".source = "${pkgs.yt-dlp}/bin/yt-dlp";
};
}
|