Add work around for subtitle timings so as to not use the patched mpv version
I made a script recently that works off another mpv script author's work which does something similar to yours in that it records the audio of a subtitle's timestamps in one press of a button. I would like to use your scripts too but I'm quite disheartened that I'd also need to download your patched version of mpv. Therefore, to eliminate that requirement, maybe it would be better to incorporate my script's work around for using the subtitle timestamps. What I did can be seen below (I apologize in advance for using es5... I'm pretty sure mpv's engine is limited to es5 though so I don't know how you were able to use ts with es6 conventions).
function cut_audio_fragment_quickly() {
mp.set_property("pause", "yes");
set_end_timestamp();
print("End timestamp: success!")
do {
dump(mp.wait_event(0));
replay_sub();
set_start_timestamp();
} while (mp.wait_event(0).event !== "none");
print("Start timestamp: success!");
do {
dump(mp.wait_event(0));
mp.commandv("seek", end_timestamp, "absolute+exact");
cut_audio_fragment();
if (!pauseAfterQuickCut) {
mp.set_property("pause", "no");
}
} while (mp.wait_event(0).event !== "none");
print("Audio fragment cut: success!");
}
I upstreamed my patches some months ago. It's even in the stable releases:
https://github.com/mpv-player/mpv/releases/tag/v0.30.0
command: add sub-start & sub-end properties
Sorry but the readme is a bit old. Updating it soon.
Ahhh, thanks for clarifying, I asked because I wanted to see if your script would work on the app IINA which is based off mpv. I have now confirmed that it does, thanks to your clarification.
Another question: How did you manage to get typescript to work as a scripting language in mpv? I thought only es5 javascript and lua were allowed.
I compile the typescript down to es5: https://github.com/pigoz/mpv-nihongo/blob/master/package.json#L28 https://github.com/pigoz/mpv-nihongo/blob/master/package.json#L30
This project is really not very clean at the moment. I should make it more generic so that other people can use it.
Interesting how you managed that. I agree that the project should be made more generic, because I'm having trouble getting it to work at the moment. Your instructions aren't exactly very clear. I assumed that you add the cloned repository into the scripts folder and yarn compile and build there. Is this how it works? Or am I missing something obvious because it's not working for me.
No, I just clone it anywhere. And run yarn install && yarn build. In the dist folder then you can find the JavaScript files compatible with mpv.
Last question. Any chance I can get a copy of your mpv-blacklist.txt? Don't know what it's used for but if it's necessary then I'd like to use it to make your script work. Thanks
Nevermind, I think I understand what it does. I will make my own. Yours would be nice to have though lol.
my mpv-blacklist, it's kinda dependent on the words you want to be excluded: https://0x0.st/zF8U.txt