mar04 / chapters_for_mpv

mpv script for adding/editing/removing/saving/loading chapters
MIT License
46 stars 4 forks source link

plugin fails if media filename contains newline #8

Open calestyo opened 1 year ago

calestyo commented 1 year ago

Hey.

At least for the case that the media file name contains a newline (\n), but possibly also for other such unusual characters (perhaps \r), the plugin fails, e.g.:

$ mpv --msg-level=chapters=debug 'a'$'\n''b.mp4'
[chapters] Loading lua script /home/user/.config/mpv/scripts/chapters.lua...
[chapters] loading mp.defaults
[chapters] loading file /home/user/.config/mpv/scripts/chapters.lua
[chapters] reading options for chapters 
[chapters] Opened config file script-opts/chapters.conf. 
[chapters] options: {"placeholder_title" = "Chapter ", "hash" = false, "ask_for_title" = true, "autosave" = false, "global_chapters" = true, "pause_on_input" = false, , "autoload" = true, "chapters_dir" = "/home/user/.config/mpv/chapters"} 
[chapters] looking for: ./a
[chapters] b.mp4.ffmetadata 
[chapters] looking in the global directory 
[chapters] full_path, mpv: a
[chapters] b.mp4 
[chapters] looking for command: realpath 
[chapters] command found: /usr/bin/realpath 
[chapters] command: {"/usr/bin/realpath", "--"} 
[chapters] command2: {"/usr/bin/realpath", "--", "a
[chapters] b.mp4"} 
[chapters] unix, full path: /home/user/ggg/ab.mp4 
…

Cheers, Chris.

calestyo commented 1 year ago

Okay I found the issue... will provide a PR.