Last active
July 18, 2020 11:16
-
-
Save wareya/0e090dca608bcc91df95ae198aceef94 to your computer and use it in GitHub Desktop.
subtitle text grabbing script for mpv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function on_new_sub(name, text) | |
{ | |
if(text == null || text == "") | |
return; | |
var newtext = ""; | |
for(var i = 0; i < text.length; i += 1) | |
{ | |
var c = text[i]; | |
if(c == "\n" || c == "\r") | |
continue; | |
else if(c == '"') | |
newtext += "”"; | |
else | |
newtext += c; | |
} | |
//mp.commandv("show-text", newtext); | |
//mp.commandv("print-text", newtext); | |
var cmd = 'echo "' + newtext + '" | clip'; | |
//mp.commandv("print-text", cmd); | |
mp.command("run cmd /D /C " + cmd); // this line may need to be modified to include a chcp 65001 | or chcp 6501 & on some systems | |
} | |
mp.observe_property("sub-text", "string", on_new_sub); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment