occivink / mpv-scripts

Various scripts for mpv
The Unlicense
417 stars 38 forks source link

[encode] Cannot write filenames that contain '%' symbol #57

Closed nick-s-b closed 3 years ago

nick-s-b commented 3 years ago

Hi,

I have compiled the latest mpv from github and have pulled the latest copy of encode.lua and the issue persists. Namely, if the filename contains the '%' symbol, encode.lua will fail to export the new file.

To test this, rename any file to 100%.mp4, for example, and try to use encode.lua to extract a portion of it. It will fail. The culprit is line 53:

https://github.com/occivink/mpv-scripts/blob/master/scripts/encode.lua#L53

I'm running Linux so I don't know if this is an issue under other OSes as well. I've been using this script for a very long time without any issues. Today, I was watching some anime that had '%' in the title and it failed to work.

occivink commented 3 years ago

Right, that's because gsub transforms text using lua patterns, which use % as a meta-character. There is also no 'literal' mode, so it'll have to do some escaping as mentioned in https://stackoverflow.com/questions/9790688/escaping-strings-for-gsub Did I mention I hate lua patterns?