# AcoustID Import Track Metadata

This statement is used to extract data from downloaded AcoustID metadata. The statement is primarily intended to be used when a folder contains tracks from multiple albums or when the AcoustID Import MusicBrainz IDs statement has failed to find a best match release. It can also be used to find basic metadata for tracks which effectively have no tag information.

Tracks which do not have the AcoustID metadata will be ignored.

You can specify certain conditions to avoid having the statement run. You can effectively disable the running of the statement for a track if:

- the current Album field is not empty
- the current Artist field is not empty
- the current Title field is not empty
- the current Year field is not empty (non zero)
- both the MusicBrainz Recording Id and the MusicBrainz ReleaseId exist

You can choose to import the Album, Album Artist, Artist, Title and Year fields and also to only import the metadata if the fields are not empty. If the statement succeeds, the Acoustid Id, MusicBrainz Release Id, MusicBrainz Recording Id, MusicBrainz Release Country and MusicBrainz Release Group Id are always imported if available. The best way to programmatically test if the statement succeeded is to clear Acoustid Id before the statement then test for its presence.

You can also import the Length field which will represent the duration as stored in the remote database. This field can always be compared against the Time (ms) property which represents the actual duration of the audio stream.

The criteria used to choose a release/recording for metadata extraction is as follows:

Match first
  The first release/recording in the AcoustID data is chosen.
Preferred country codes take priority
  The Preferences - MusicBrainz - Country code setting is used to determine a preferred match. The release/recording associated with the leftmost country code in the list is chosen. If none of your preferred country codes are available, the first release/recording in the AcoustID data is chosen.
Match the current MusicBrainz Release Id
  This mode is useful when you have a Release Id but not a Recording Id. Perhaps you set the Release Id manually. With this mode if a recording in the same release cannot be found, then no recording will be chosen.
Custom
  A specified string contains criteria codes which are tested in a left to right order to determine the preferred match. The criteria codes are easy to specify by the use of the menu displayed by the disclosure button. The criteria codes are case insensitive. You can also specify a maximum number of seconds for a duration difference. if the absolute value of a potential match's duration difference is greater than the specified value, it will not be considered. An empty value or a value less or equal to zero, is interpreted as don't care. The supplied strings may contain any of the escape sequences described in Escape Sequences and as such are only evaluated at runtime.

## Custom Criteria Codes

Unless otherwise specified, fuzzy comparisons are used.

R Album
  If the associated track's Album field is not empty, higher priority is given to results which have a release title which better matches the Album field.
P Album Artist
  If the associated track's Album Artist field is not empty, higher priority is given to results which have a release artist which better matches the Album Artist field.
A Artist
  If the associated track's Artist field is not empty, higher priority is given to results which have a recording artist which better matches the Artist field.
+ Artist and Title
  Higher priority is given to results where the Artist and Title fields are a better match. The fields are individually tested and the results are added. This gives equal weight to the Artist and Title fields. When Artist (A) and Title (T) are individually specified, the first has higher priority.
~ Artist and Title Merged
  Higher priority is given to results where the merged contents of the Artist and Title fields are a better match. fuzzy non positional testing is used.
C Country
  Results which better match a leftmost preferred country code are given a higher priority.
= Disc Count
  Results which have a media count equal to the associated track's Disc Count will be given priority. Note that a Disc Count of 0 is treated as 1.
D Duration
  Results closest in duration to the track's duration are given priority.
N Not Part of a Compilation
  Results which are not part of a compilation are given priority.
M Part of a Compilation
  Results which are part of a compilation are given priority.
G Release Group ID
  If the associated track has a MusicBrainz Release Group Id, results with the same release group ID are given priority.
I Release ID
  If the associated track has a MusicBrainz Release Id, results with the same release ID are given priority.
S Score
  AcoustID result data supplies a score paramater for recordings. When this criteria is specified, recordings with higher scores are given priority.
T Title
  If the associated track's Title field is not empty, higher priority is given to results which have a release title which better matches the Title field.
# Track Count
  Results which have a track count equal to the associated track's Disc Count * Track Count will be given priority. Note that a Disc Count of 0 is treated as 1. Note also that the track count returned in the AcoustID data is a total track count.
Y Year
  If the associated track's Year Artist field is not empty (0), higher priority is given to results which have a release year which matches the Year field.

## Advanced Topics

If you are running the action in the UI and you want to suppress errors, select the Silent option.

If you have accumulated downloaded AcoustID data in a database and you wish to use the data with this statement, you will more than likely be using a dummy file for the lookup. This statement, when Custom is chosen, can use a file's audio duration as part of the process. If you wish to override the duration, you must set the AcoustID Duration Override named variable to the desired duration in ms. This will only work if this statement is called on a single file. ie. you are executing grouped or only a single file is effectively selected. Note also, that the AcoustID Duration Override named variable is cleared after each call to this statement.