# Description

Musicfix is a music file renamer and tagger with consistency concerns. It has a release-centered logic and gets data from the Discogs.com site. First configure the target music directory (‘mdir` config attribute). Next browse the site and locate your album. Change to the album’s directory. Ensure the files are ordered and provide the release id to the program. Enjoy!

# Dependencies

* System packages: taglib
* Ruby gems: stringex taglib-ruby

# Usage

$ musicfix        
Usage: musicfix [fake] relid [tracks]
       musicfix [fake] dump relid [relfile]
       musicfix [fake] load [relfile]
       musicfix [fake] tags [relfile]

The common path is to just give the release id:

$ musicfix 1234

More sophisticated track selection can be performed by providing a tracks selector command line argument of the form:

"1--3,5,8"
"A2--A4,B3"
"1-8--1-9,1-10--1-11"

Alternatively, YAML metadata files can be used (‘release.yaml` by default) in order to dump information from Discogs.com and/or load the information from file. This way you can generate a base release file, edit to your needs, and then use it for tagging and renaming. The fake prefix on all commands results in no files to be copied/written and no cover artwork to be downloaded. For example:

$ musicfix dump 1234
$ musicfix fake load
$ musicfix load

You may also generate a release file using the existing audio file tags and use that file instead:

$ musicfix tags
$ musicfix load

The release metadata is saved together with the music files by default, and the load command looks for any YAML files in the current directory (if there is no relfile specified and ‘release.yaml` does not exist). This is useful for renaming files again using a new naming scheme.

# Configuration

In the simplest case no configuration is needed! The music files are copied to the ~/music directory, which is created if needed. If you want to change that, create a ‘~/.musicfixrc` configuration file containing:

mdir: ~/music/fixed

Furthermore, templates are used for the naming of music files, the cover artwork image and the release metadata file. The defaults are:

track: '"#{mdir}/#{fba}-#{my}-#{fb}-#{fv}/#{fd}#{n}-#{fa}-#{ft}.#{x}"'
image: '"#{mdir}/#{fba}-#{my}-#{fb}-#{fv}/#{zz}-#{fba}-#{fb}_cover.jpg"'
rdata: '"#{mdir}/#{fba}-#{my}-#{fb}-#{fv}/#{zz}-#{fba}-#{fb}_release.yaml"'

To run a shell command upon completion use the ‘after` attribute. For example, to update the MPD database:

after: '"mpc update #{fba}-#{my}-#{fb}-#{fv}"'

The variables used in the templates are explained below. The ‘f’ prefix means “normalized for filename”.

Use everywhere:

[f]b: album name
[f]ba: album artist
y: release year
my: master release year
g: genre style
[f]v: release format

Only for track naming:

[f]a: track artist
[f]t: track title
[f]d: disc number or side letter for vinyls
n: track number, zero padded
x: file extension in lowercase

Only for image and rdata naming:

zz: zeros that match d + n width

Only for image naming:

i: the index in the list

# Cover artwork support

From March 2015 and onwards cover artwork images are resources restricted to authenticated clients. The easiest way to do this and the one supported by musicfix is to create a Discogs account and generate a personal access token from the developers settings. Add the token in ‘~/.musicfixrc` like this:

token: abcxyz123456

You’ll get no cover artwork without adding your personal access token.