Beets apostrophe replacement breaks searching

When beets imports songs, it replaces the standard apostrophe character with another that isn’t typeable from my keyboard. As a result, I can’t perform any searches for songs/artists with an apostrophe in their name.

For example this returns nothing when typed from my keyboard:

$ beet ls "Mary Jane's Last Dance"

But finding the song via another search without the apostrophe then copying the output and pasting that into the search finds the song:

$ beet ls Mary Last Dance
Tom Petty and the Heartbreakers - Greatest Hits - Mary Jane’s Last Dance
$ beet ls "Mary Jane’s Last Dance"
Tom Petty and the Heartbreakers - Greatest Hits - Mary Jane’s Last Dance

How can I get beets to not replace the apostrophe with the other variant not available via my keyboard? I looked at the various import options and didn’t see anything that would address this. The closest I found was the “replace” option but changes the filename; and doesn’t affect the search.

Thanks in advance.

Beets just takes the data from MusicBrainz, and the MusicBrainz style guidelines are to use typographical characters instead of generic ones. Some entries on MusicBrainz have the generic characters, but many have been updated.

If you don’t want the typographical characters in your tags you can use the replace config: Configuration — beets 1.4.9 documentation

If you are fine keeping them there’s totally a way to type those characters, you just need to learn how for your OS.

1 Like

Thanks. I tried the replace config but it seems to only work for the filename. It doesn’t change the tags. The documentation also only references filenames; not tags.
http://docs.beets.io/en/v1.4.9/reference/config.html#replace

Here is my replace config:

replace:
    '[\u2019]': \'

I tried re-tagging by doing an import again on the album and while it made the replacement for the filename, the tag and subsequent search still uses the typographical apostrophe.

Interesting. I don’t do this myself so I will try it tomorrow.

My bad, you’re absolutely right. Reading the docs for the replace config it’s for filenames only.

If there’s a way to do what you want I’m not sure what it is. This might make a good plug-in idea to ASCIIfy all tags.

Hopefully someone with more experience can chime in.

Just as an aside: you can also use the . symbol, which is regex-speak for “any character”, to sidestep this issue in many cases. E.g.:

beet ls "title::Mary Jane.s Last Dance"

The :: says to match that field using regex mode. But note that in regex mode:

  • searches are slower, since it needs to pull down more information from the SQLite database up front, and then run it against the given regex expression.
  • searches are case sensitive, so you might want to do something like beet ls "title::[Mm]ary [Jj]ane.s [Ll]ast [Dd]ance" if you aren’t sure about the capitalization of a search.

Still, regex is a very powerful way of doing searches, so I just wanted to mention it.

  • On macOS, to type the symbol, press shift+option+].
  • On Windows, while holding the Alt key, type 0146 on the numpad.
  • On many Linux flavors (Ubuntu for sure, at least), type Compose+', then release Compose and type shift+. (i.e. the > symbol if on a U.S. keyboard). (The compose key is something you have to set up yourself, in the keyboard settings; I have mine mapped to the right-side Alt key, because I’d never use that key otherwise.)

I did notice though, unfortunately, that path: searches involving this single apostrophe character do not match on my system, regardless of if I write beet ls "path:Don’t Say Goodbye" or beet ls "path:Don't Say Goodbye". This is probably a bug, and might be due to the fact that I use asciify_paths: yes in my config.yaml, though I didn’t dig in further to verify my theory.

Thank you all for your replies. I looked at the work-arounds and while I still much prefer to have Beets find what I type natively via the keyboard, the regex search looks like the best alternative.

Also in playing around with this, I noticed while Beets may take data from MusicBrainz, MusicBrainz’s own product, Picard, tags songs with the ASCII apostrophe character. I can take an album tagged with Picard then on the Beets import of the same album, see it change all the apostrophe characters from ASCII to unicode.

1 Like

Picard has an option to replace Unicode characters with ASCII characters in tags, but Beets doesn’t. I think a plug-in for Beets could do it, but that means someone would have to write it.

1 Like