Skip to content
Last.fm is disabling API Keys for non-paid accounts December 1st.Learn More

Match Stage

The Match Stage checks if a Play matches search expressions, provided by you. It does not change Play data.

Instead, the Stage succeeds if the Play matches and fails if it does not. Combined with Stage Flow Control and Play State Control this lets you decide what happens to a Play based on its data. Example scenarios:

  • Discarding Plays from a specific device or user
  • Marking Plays as Needs Review if a Title still looks wrong after the Musicbrainz Stage runs
  • Skipping later Stages when a Play is from an Artist you don’t want to look up

The Match Stage has a Default Stage. You do not need to create one in the top-level transformers of your AIO Config.

However, you can create one here if you want subsequent usage of this transformer to always have default rules, using Rules defaults.

Example
config.json
{
// ...your AIO Config
"transformers": [
{
"type": "match",
"name": "MyMatch",
"defaults": {
"title": "MyCoolTitle"1
}
}
]
}
  1. 1.always added when using "MyMatch" in a Source/Client...

A search expression can be a plain string that matches a literal:

Expression: "Live"
"My Song (Live)" => matches
"My Song" => does not match

or a regular expression:

Expression: "/(remaster|live)/i"
"My Song (Remastered 2011)" => matches

An empty string ("") matches when the Play does not have that data, like a Play with no Album.

Each expression may also be an object with its own when condition, so it is only checked if when passes:

{
"search": "/remaster/i",1
"when": {"artists": "The Beatles"}2
}
  1. 1.check if Title includes 'remaster'...
  2. 2....but only for Beatles Plays

Each Rule can be a single search expression or a list of them. If any expression in a Rule matches, the Rule matches.

The Rules you can use are:

  • title artists albumArtists album
  • art - any album, track, or artist art URL
  • user deviceId library playlist musicService - only available for Sources that report this info
  • duration listenedFor - instead of a search expression, use a comparison: = > or < followed by a duration. EX > 7 s < 2 minutes = 30s
{
"type": "match",
"name": "MyMatch",
"artists": ["Elephant Gym", "Tide/Edit"],1
"listenedFor": "< 30 s"2
}
  1. 1.Artist is Elephant Gym OR Tide/Edit...
  2. 2....AND the Play was listened to for less than 30 seconds

All Rules in a Stage must match for the Stage to succeed.

To match one of several different combinations, put each combination in matches. The Stage succeeds if the Rules at the top level or any set in matches match.

{
"type": "match",
"name": "MyMatch",
"matches": [
{ "deviceId": "kitchen-speaker" },1
{ "user": "guest", "album": "/Christmas/i" }2
]
}
  1. 1.Play is from the kitchen speaker...
  2. 2....OR is a guest listening to a Christmas album

A Match Stage with no Rules at all never matches.

Discard Plays from the kitchen speaker that were listened to for less than 30 seconds.

Example
{
"playTransform": {
"preCompare": [
{
"type": "match",
"name": "MyMatch",
"deviceId": "kitchen-speaker",
"listenedFor": "< 30 s",
"onSuccessAction": "discard",1
"onFailure": "continue"2
}
]
}
}
  1. 1.Play matched, set it to Discarded
  2. 2.Play did not match, nothing happens and it is processed normally

Use Musicbrainz to clean up the Play, then mark it as Needs Review if the Title still has feat. or Remaster in it.

Example
{
"playTransform": {
"preCompare": [
{
"type": "musicbrainz",
"name": "MyMB",
"onFailure": "continue"1
},
{
"type": "match",
"name": "MyMatch",
"title": "/(feat\\.|remaster)/i",
"onSuccessAction": "review",2
"failureReturnPartial": true3
}
]
}
}
  1. 1.Still check the Title even if Musicbrainz could not find a match
  2. 2.Title still looks messy, set Play to Needs Review
  3. 3.Title looks fine, keep the Musicbrainz changes

Stop the Hook early, without changing anything, for Plays that are not from your favorite Artists, so Musicbrainz only runs for them.

Example
{
"playTransform": {
"preCompare": [
{
"type": "match",
"name": "MyMatch",
"artists": ["Elephant Gym", "Tide/Edit", "/^toe$/i"]
},1
{
"type": "musicbrainz",
"name": "MyMB"
}
]
}
}
  1. 1.onFailure defaults to stop: if the Artist is not in this list, Musicbrainz never runs