Problem playing files with brackets in filename

Beet won’t play songs with brackets ([]) in the file name :frowning:

Here’s an example:

$ beet ls -f '$artist -- $album -- $title : $path' zamf you
Zamf -- Xingerbread -- Your Hand : /Users/redacted/Music/beet/Zamf/Xingerbread/01 Your Hand.mp3
Zamf -- Xingerbread -- You Belong to Me [Bob Dylan Cover] : /Users/redacted/Music/beet/Zamf/Xingerbread/13 You Belong to Me [Bob Dylan Cover].mp3

$ beet play zamf you
Playing 2 tracks.

However, the media player (VLC in my case) plays “Your Hand” only; it never plays “You Belong to Me”. I can reproduce this with various songs, and it seems to boil down to the [] characters in the file name.

Any advice?

Please include your configuration (especially for the play plugin) and the verbose output of the command.

Here you go:

# ~/.config/beets/config.yaml

directory: ~/Music/beet
library: ~/Music/beet.db
sort_item: albumartist+ album+ disc+ track+
plugins:
  - chroma
  - discogs
  - duplicates
  - edit
  - embedart
  - fetchart
  - info
  - lastgenre
  - lyrics
  - play
  - scrub
  - types

types:
  albumtotal: int

Verbose output:

$ beet --verbose play zamf you
user configuration: /Users/redacted/.config/beets/config.yaml
data directory: /Users/redacted/.config/beets
plugin paths: 
Sending event: pluginload
lyrics: Disabling google source: no API key configured.
lyrics: The Genius backend requires BeautifulSoup, which is not installed, so the source is disabled.
library database: /Users/redacted/Music/beet.db
library directory: /Users/redacted/Music/beet
Sending event: library_opened
Playing 2 tracks.
play: executing command: open ['/var/folders/ns/zxjyg_1d3w38f7gr6pg8w6p00000gn/T/tmpv2kx18o5.m3u']

$ cat /var/folders/ns/zxjyg_1d3w38f7gr6pg8w6p00000gn/T/tmpv2kx18o5.m3u
/Users/redacted/Music/beet/Zamf/Xingerbread/01 Your Hand.mp3
/Users/redacted/Music/beet/Zamf/Xingerbread/13 You Belong to Me [Bob Dylan Cover].mp3

Based on this, it might be a problem with VLC… the m3u file looks decent. Or does the m3u standard require to escape shell characters in playlists?

I’ve tried the following playlist, which use URL encoding. This works:

file:///Users/redacted/Music/beet/Zamf/Xingerbread/01%20Your%20Hand.mp3
file:///Users/redacted/Music/beet/Zamf/Xingerbread/13%20You%20Belong%20to%20Me%20%5BBob%20Dylan%20Cover%5D.mp3

So I reckon the play plugin should generate playlists in URL format… Would that be something for which you accept patches?

Got it! Yes, it looks like a specific problem with VLC.

The problem with .m3u playlists is that they don’t really have a spec. The Wikipedia article (especially the first section after the TOC) is very enlightening:

So every tool handles them differently. The gist is “a list of filenames separated by newlines,” but beyond that, it’s anyone’s guess. If VLC accepts file URLs but not brackets in ordinary pathnames, that’s sad but just the way things are when there’s no agreed-upon spec.

Anyway, yeah, totally, a config option to emit file:/// URLs instead of plain, absolute filesystem paths would be a good idea and a patch we’d absolutely accept.

Makes sense. I’ve entered this in my notes as Project #47 :slight_smile:

Don’t expect a patch anytime soon, but I might get to it someday. For reference, if other users are having the same problem, setting the raw option to true might be a workaround.