diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-03-16 22:23:38 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-03-16 22:23:38 +0100 |
commit | 01a5fd2b8619c71d2acdf38b30de9f37e853d1d7 (patch) | |
tree | ec565c4d5eeb05a53e80b60ac215d0ba3f5705bf /.config/mpv | |
parent | 3cc320fd9518b10d7b2cc5322c153844aa5ead0b (diff) |
filter subtitles before copy in mpv
Diffstat (limited to '.config/mpv')
-rw-r--r-- | .config/mpv/scripts/copy-subs.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/.config/mpv/scripts/copy-subs.lua b/.config/mpv/scripts/copy-subs.lua index 32ae7ef..305299a 100644 --- a/.config/mpv/scripts/copy-subs.lua +++ b/.config/mpv/scripts/copy-subs.lua @@ -3,7 +3,13 @@ _G.auto = false function copy() local sub = mp.get_property("sub-text") if sub then - os.execute("echo '" .. sub:gsub('\'', '\'\\\'\'') .. "' | xclip -selection clipboard -i") + -- remove some specific unicode characters + sub = sub:gsub('\u{27a1}', '') + sub = sub:gsub('\u{fffd}', '') + + sub = sub:gsub('\n', ' ') -- replace newlines with space + sub = sub:gsub('\'', '\'\\\'\'') -- escape single quotes + os.execute("echo '" .. sub .. "' | xclip -selection clipboard -i") end end |