Ajatt-Tools / mpvacious

🍜 Adds mpv keybindings to create Anki cards from movies and TV shows.
https://tatsumoto-ren.github.io/blog/mining-from-movies-and-tv-shows.html
GNU General Public License v3.0
602 stars 51 forks source link

Subtitle lines with only one double quote break when copying to clipboard on Windows #91

Closed seth-js closed 1 year ago

seth-js commented 1 year ago

The line "No me quedaba tiempo y había cosas importantes que debía hacer. wouldn't copy to the clipboard.

If I edit the line in the subtitle file to have a double quote at the end, the line is properly copied.

I wrote some extra code underneath text = text:gsub("&", "^^^&"):gsub("[<>|]", "") in win.lua:

if text:find("^\"") and not text:find("\"$") then
    -- text = text:gsub("$", "\"")
    text = text:gsub("^\"", "“")
end

The first or second text replacement option fixes the problem.

seth-js commented 1 year ago

The line En realidad, solo una". also wouldn't copy.

I changed the code to:

local _, quote_count = text:gsub("\"", "")
if quote_count == 1 then
    text = text:gsub("\"", "“")
end

This allows both "No me quedaba tiempo y había cosas importantes que debía hacer. and En realidad, solo una". to be copied.

tatsumoto-ren commented 1 year ago

Since quote appears to be a special symbol in cmd.exe, I think it's wise to replace all occurrences of it. Feel free to create a PR with your changes though.

seth-js commented 1 year ago

Thanks for approving the PR.

tatsumoto-ren commented 1 year ago

Anytime.