mpv-playlistmanager icon indicating copy to clipboard operation
mpv-playlistmanager copied to clipboard

Paths with \ display newlines, tabs and other special characters

Open pjammo opened this issue 3 years ago • 5 comments

Items containing \N or \n are parsed in a different way. Files 1 and 2 are local, files 3 and 4 are remote.

img

pjammo avatar May 26 '21 13:05 pjammo

I'm not super sure in what part of the code the issue is. I was able to reporoduce it with local files.

I would suggest as a workaround to use the following filename_replace

in lua file

filename_replace = [[
    [
      {
        "ext": { "all": true},
        "rules": [
          { "\\" : "/" },
        ]
      }
    ]
  ]],

in conf

filename_replace=[{"ext": {"all":true},"rules":[{"\\":"/"}]}]

This will change \ to /, I will consider making this a default if I can't manage to fix this bug.

jonniek avatar Dec 09 '21 21:12 jonniek

Thank you for this workaround. I hope you will figure out what the issue is.

pjammo avatar Dec 10 '21 08:12 pjammo

When the file name contains special characters of {, it will also destroy the display of the playlist. image

This is an ass escape character issue, refer to https://github.com/mpv-player/mpv/blob/94677723624fb84756e65c8f1377956667244bc9/player/lua/stats.lua#L145-L154

The file name displays one more character of \ when the following is applied.

filename_replace=[{"ext": {"all":true},"rules":[{"{":"\\{"}]}]

image This is confusing, and I don't know how to display the correct file name.

dyphire avatar Jul 21 '22 07:07 dyphire

See also https://github.com/libass/libass/issues/194#issuecomment-351902555.

FichteFoll avatar Jul 22 '22 10:07 FichteFoll

Thanks, that looks promising. I will experiment with this later today. It's not complicated by itself, but this script does 2 different replacing of it's own (templates and user custom defined) and some custom escaping also, so the order probably is important. It could be any user defined replaces cannot fix this issue.

Almost tempted to create a test suite for all this escaping stuff :sweat_smile:

jonniek avatar Jul 22 '22 11:07 jonniek