Sonos character limits

Before Christmas I received an email alerting me to Sonos's metadata limits. Sonos's limitation of a maximum of 65,000 tracks is fairly well known, but this limitation goes deeper: it affects how many characters for each field of metadata are saved and displayed for tracks in your library.

A great example of musical metadata this can affect was given by the author: Illinois. Some of the track names are extremely long, and thus appear truncated in the Sonos.

The email went on to ask:

I don't know if bliss can be customised to run to either warn users e.g. mark it as non-compliant? That would be best.

Or probably easier just to truncate tracks to these lengths (not so good as the user doesn't know what's been done and then).

If so, I'd be interested to hear how to do this - and in doing so may extend my knowledge of bliss and how to get the most out of it.

This is certainly achievable using bliss's custom rules feature. And it's a bit more useful than my last example.

As usual, regex rules are created in the .bliss/regex-rules folder. Due to limitations about how rules are currently structured, I created one rule for each field listed on the Sonos page:

# Rule to limit album fields to 92 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the album name to exactly 92 characters.
rule sonosAlbumCharLimit with label "Sonos album name character limit" has alternatives
92_CHARS {
find /^(.{0,92}+).+$/ replace with "$1"
}
applies to album_name
# Rule to limit artist fields to 76 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the artist or album artist name to exactly 76 characters.
rule sonosArtistCharLimit with label "Sonos artist character limit" has alternatives
76_CHARS {
find /^(.{0,76}+).+$/ replace with "$1"
}
applies to artist, album_artist
# Rule to limit genre fields to 22 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the genre to exactly 22 characters.
rule sonosGenreCharLimit with label "Sonos genre character limit" has alternatives
22_CHARS {
find /^(.{0,22}+).+$/ replace with "$1"
}
applies to genre
# Rule to limit track name fields to 100 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the track name to exactly 100 characters.
rule sonosTrackCharLimit with label "Sonos track name character limit" has alternatives
100_CHARS {
find /^(.{0,100}+).+$/ replace with "$1"
}
applies to track_name

These rules simply look for fields which are longer than the prescribed limits, and offer a fix to truncate those fields. With the above files saved in our regex-rules folder, we can see in the settings:

Enabling the Sonos character limits

Once those rules are applied, Illinois gets assessed:

Illinois's long track lengths assessed and a one-click fix offered

Clicking Set TRACK_NAME to 100 chars will truncate the track name.

I suppose some shortcomings of how custom rules currently work are exposed:

  • It's hard to see all of the fixes that will be applied for track names.
  • The settings UI could be better laid out and structured.

Plus there's the requirement to understand regular expressions of course... All stuff to work on!

If you don't want a plain truncation of the string, something prettier would be to truncate and have an ellipsis at the end - "…". Because I'm not sure if the Sonos controller supports ellipsis, we can just use three periods instead. Here's that variation applied to the track name rule:

# Rule to limit track fields to 100 characters, as per https://sonos.custhelp.com/app/answers/detail/a_id/1552/kw/tag%20character%20limit
# Offers a one-click fix to truncate the track to exactly 97 characters with a three character ellipsis at the end
rule sonosTrackCharLimit with label "Sonos track name character limit" has alternatives
100_CHARS {
find /^(.{0,97}+)(.{0,3}+).+$/ replace with "$1..."
}
applies to track_name

The same approach could be applied to the other tags.

An interesting application of custom rules!

Thanks to Upupa4me for the image above.
tags: sonos custom rule regex

Type Comment Here (at least 3 chars)

The Music Library Management blog

Dan Gravell

I'm Dan, the founder and programmer of bliss. I write bliss to solve my own problems with my digital music collection.